Repository navigation
feat(desktop): 重载、语义高亮与小地图的编辑器性能 (#1816) - #1946
Merged
Merged
Conversation
- Content 带着基线计算出的变更范围(PrepareAgainst),窗口线程只应用它,不再复制整篇文本作为 OnEdit 的编辑 - 基线与磁盘内容是否相同改为逐块比较(rope.EqualBytes),不再复制基线 - 历史记录的文本副本改在后台 job 里生成,窗口线程不复制 - 新增 BenchmarkEditorViewReload 与预算:10 MiB 重载从约 420 µs、10.5 MB 分配降到约 70 ns、0 B
- PrepareSemantic 在工作线程转换 token,窗口线程只调用 SetPreparedSemantic 应用结果(原先 provider 路径在窗口线程上转换) - buildSemantic 按 Chunks 顺序读一遍文本,行号用换行符定位,只复制含 token 的行;同一行的 token 向前游标推进,不再从行首重新扫描 - 超长行 400 个 token:15.5 ms -> 84 µs;100 KiB Go 文档:191 µs -> 40 µs - 新增 BenchmarkEditorSyntaxSemanticBuild、跨 leaf 的参考对比测试,以及线性预算
- BenchmarkEditorViewType 新增 longline-wrap-minimap 变体,覆盖小地图每次编辑重建的路径
xiaoyumuxi
marked this pull request as ready for review
November 14, 2026 18:30
Lithe Review结论: ❓ 审查未完成 已由服务器取消。可以重新评论 |
…t-paths # Conflicts: # desktop/internal/workbench/semantic_tokens.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
#1816 列出的编辑器性能债务。本 PR 处理其中的重载、基线比较、语义高亮和小地图相关项。
改动 / Changes
PrepareAgainst在工作线程算出变更范围,窗口线程只应用它,不再把整篇文本复制成字符串给OnEdit。diskEdit在基线不匹配时才回退到rope.Diff。historyTexts可携带不可变 rope,字节副本在后台 job 中生成。rope.EqualBytes逐块比较,不再复制基线。PrepareSemantic在工作线程转换 token,窗口线程只调用SetPreparedSemantic;buildSemantic按 Chunks 读一遍文本,行内用游标推进。BenchmarkEditorViewReload、BenchmarkEditorSyntaxSemanticBuild、BenchmarkEditorViewType/longline-wrap-minimap,并在editor-budgets.json补预算。不在本 PR 范围内 / Out of scope
StateStack分配):做过 slab 分配,分配次数 27.7k → 7.1k,但耗时不变(约 54 ms),字节数 +15%,已撤回,不做。regexp编译,其余需要前后查找、占有量词、原子组或\G。真正解决需要支持这些特性的非回溯引擎,单独立项。(?:\n|$)首字符剪枝):未做,需要改首字符分析,收益只限这一类模式。BenchmarkEditorViewType/longline-wrap/10MiB从约 78 µs 到约 94 µs(+20%),两轮测量一致。二分确认来自view.go的改动(单独还原rope.go无效),在输入路径上没有找到原因。仍低于 1 ms 预算。类型专属:feat
多平台对齐
范围检查 / Scope checks
性能与内存 / Performance and memory
同一台 Apple M4,空闲时运行,
-test.count 3,基线为origin/preview(295ee28d6),新版为本分支。无用代码与重构 / Dead code and refactoring
wholeDocumentEdit,widestLine等仍在使用,保留。验证 / Verification
scripts/desktop/desktop-go.sh test ./internal/editor/... ./internal/editorview/ ./internal/workbench/go vet(editorview、editor/...、workbench)gofmt -lnode --test scripts/desktop/perf/editor-perf-report.test.mjs未能执行的检查和原因:
scripts/desktop/verify/verify-runtime-bundle-immutability.sh未运行;本 PR 不新增运行时资源或写入路径。提交前确认 / Final checks
preview创建(295ee28d6),目标分支preview