Skip to content

Epic(compare): 在 macOS 上对比 Lithe 与 GoLand、VS Code、Zed 的资源占用和 Go 交互延迟(不合入,基准测试集,后续基准测试perf/ide-comparison分支中进行补充) - #1997

Draft
xiaoyumuxi wants to merge 2 commits into
mainfrom
perf/ide-comparison

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

背景 / Why

我们需要一组可复现的数据,说明 Lithe 和常用编辑器相比的资源占用和交互速度,既用来对外介绍 Lithe,也用来对内发现性能退化。仓库里原来只有 Viva 编辑器自己的基准(editor-bench.sh),没有办法在同一台机器上,用同样的项目和步骤,把 Lithe 和 GoLand、VS Code、Zed 放在一起比较。手工比较又没法复现:各编辑器的缓存、插件、窗口状态都不一样,计时只能靠肉眼。

本 PR 在 scripts/desktop/perf/ 增加一组只在 macOS 本地运行的对比脚本(不进 CI),结果写到 .artifacts/ide-compare/,报告用中文。

改动 / Changes

资源对比:ide-compare.mjs 和 ide-compare-sampler-macos.c(第一个提交 adf46f5)

  • 每个编辑器各克隆一份项目,用全新的隔离 profile 打开;除了安装包自带的东西,什么都不装。
  • 关掉会干扰数字的首次运行行为:
    • 所有编辑器的更新检查;
    • GoLand 的新 UI 导览(这个模态框会拖住索引)和 What's New 页;
    • Zed 自动下载 HTML 扩展。
  • 每次启动都用 open -n,和从 Finder 打开一样。采样器按进程树和 macOS responsibility 汇总 phys_footprint(和 Lithe 状态栏的算法一致),同时记录 CPU 时间和窗口。
  • 每次启动后结束实例,并确认没有残留进程。
  • 第一次打开和重新打开分开记录。输出 results.json 和 Markdown 报告,内容包括:项目窗口出现时间、到空闲的时间、稳态和峰值内存、空闲 CPU、进程数、线程数、安装大小和 profile 大小。

Go 模式:ide-compare.mjs --go FILE --lithe-plugin ID(本次提交)

  • 每个编辑器除了打开项目,还会打开 FILE。
    • Lithe 装上 --lithe-plugin 指定的 Go 插件:照原样复制本机 Lithe 已安装的版本,并带上用户对这个版本的授权。脚本自己不写死任何插件 ID。
    • Zed 用内置的 Go 支持,GoLand 用自带的 Go 支持。
  • Lithe 和 Zed 用 PATH 里的同一个 gopls。每次启动都在 profile 里使用独立的 GOPLSCACHE:第一次打开时是空的,相当于 GoLand 的索引。
  • Go 就绪的判断:Lithe 和 Zed 看处理器是否安静下来(这时 gopls 也已经加载完工作区);GoLand 看它是否退出了索引。
  • 采样器新增 childCpuUs(ri_child_user_time + ri_child_system_time)。在两次采样之间启动又退出的子进程(例如 go 命令运行的编译器)也能算进 CPU 时间。已经统计过的进程退出时,它的时间不会再重复计入。
  • 内存和 CPU 按进程组拆分,例如 gopls 和它启动的 go 命令归为一组,这样报告能单独给出语言服务器占的份额。
  • 新增 --source DIR 和 --name NAME,可以用其他仓库做对比(例如 Kubernetes)。
  • 新增 Go 报告:记录打开到 Go 就绪所需的时间和资源、gopls 启动延迟,以及索引和缓存的磁盘占用。

交互延迟:ide-compare-latency.mjs、ide-compare-input-macos.swift、ide-compare-lsp-proxy.mjs(本次提交)

  • 编辑器的准备方式和 Go 模式相同。每个编辑器就绪后,各测 --reps 轮(默认 5 轮):
    • 跳转到定义;
    • 悬停;
    • 查找引用;
    • 打字:在注释末尾打 10 个字母,再用 Backspace 删掉并保存,文件恢复原样。
  • 每轮先通过编辑器的文件搜索打开 FILE,再用“跳到行”把光标放到目标位置,所以每轮的起点相同。
  • 驱动程序:
    • 用 ScreenCaptureKit 录制编辑器窗口(不录光标),用 CGEvent 发送按键和指针事件。
    • 只在目标进程处于前台时才发送事件。检测到 Mission Control 或其他窗口挡住时,记为中断,不计入结果。
    • 计时从按键或指针落点开始,到第一帧变化(首次响应)为止,再记录到画面稳定的时间。时间来自 mach 时钟。
  • 悬停用鼠标指针触发,不按 F1,因为 F1 可能被其他应用占用。
    • 驱动先按 → 再按 ←,用帧差找到光标所在的字符和那一行的位置。
    • 指针沿着同一行从左边移过来:先在左边两个字符处停 150 ms(短于每个编辑器自己的悬停等待),再落到目标字符上,计时从落点开始。
    • 定位失败会重试,最多 3 次,并保存失败时的画面。报告中单独有一列“失败”。
  • 测试时临时把输入法切到 ABC,结束后恢复原来的输入法。
  • LSP 代理夹在编辑器和 gopls 之间,记录每个请求在 gopls 里花的时间,用来区分是编辑器慢还是语言服务器慢。
    • 悬停请求连位置一起记录,只和目标那一行的请求配对,不会误配指针经过时的请求。
    • 其他消息只记录方法名,不记录内容。

其他

  • .agents/skills/develop-lithe/references/scripts.md:在 scripts/desktop/perf/ 一行登记三个新脚本。

不在本 PR 范围内 / Out of scope

结果摘要 / Results

机器:Apple M4(10 核,24 GiB),macOS 27.3。版本:Lithe 0.7.0(本地 dist 包)、GoLand 2026.2.4、Zed 1.28.1,go1.27.4,gopls v0.23.0。

测量前做过两项预热,均对所有编辑器一致:go mod download,以及用 go build ./... 预热 GOCACHE。机器保持空闲。完整报告由脚本生成,不提交(.artifacts/)。

第一层:Lithe-IDEA 仓库,重新打开,中位数

编辑器 窗口 Go 就绪 稳态内存 其中 gopls 总 CPU 空闲 CPU
Lithe 0.66 s 3.17 s 794 MB 519 MB 10.3 s 2.13%
Zed 0.63 s 3.23 s 948 MB 735 MB 8.7 s 0.57%
GoLand 2.25 s 12.8 s 2558 MB — 185 s 125.7%

第一层:Kubernetes(c50e5395f,31268 个文件),重新打开,中位数

编辑器 窗口 Go 就绪 稳态内存 其中 gopls 总 CPU(其中 gopls) 空闲 CPU
Lithe 0.71 s 41.1 s 1482 MB 1234 MB 61.6 s(33.0 s) 2.24%
Zed 0.62 s 11.7 s 1343 MB 1117 MB 51.2 s(40.1 s) 0.49%
GoLand 2.87 s 26.6 s 3088 MB — 135.8 s 6.46%

Lithe 在 Kubernetes 上的 Go 就绪时间,大部分花在 gopls 启动之前(约 30 s):Core 在启动语言服务器前,为了算出要传给 gopls 的 Git 忽略目录,逐个目录启动 git check-ignore。原因和修复方案见 #1994。

第二层:交互延迟,Lithe-IDEA 仓库,desktop/internal/workbench/app.go,每项 5 轮

项目 Lithe Zed GoLand
就绪 8.31 s 6.59 s 26.0 s
跳到定义:首次响应 / 稳定(中位数) 61 / 78 ms 62 / 149 ms 79 / 165 ms
悬停:首次响应(中位数) 552 ms 382 ms 569 ms
悬停:扣除编辑器自己的悬停等待 52 ms(等待 500 ms) 82 ms(等待 300 ms) 69 ms(等待约 500 ms)
查找引用:首次响应 / 稳定(中位数) 78 / 94 ms 63 / 113 ms 82 / 1365 ms
打字:输入 / 退格(中位数) 32 / 46 ms 64 / 64 ms 62 / 64 ms
gopls 自身耗时:定义 / 悬停 / 引用 1 / 1 / 23 ms 1 / 1 / 22 ms 不用 gopls
会话期间峰值内存 / 累计 CPU 2163 MB / 62.5 s 2119 MB / 71.5 s 4540 MB / 524.3 s
  • 所有操作都是 0 超时、0 失败、0 次被打断。
  • Zed 每轮悬停前,第一次定位光标都没找到,重试后成功。定位不计入时间。
  • 悬停等待是各编辑器的默认值:Lithe semanticHoverDelay、Zed hover_popover_delay、GoLand 编辑器提示延迟。扣除后剩下的是编辑器自己的开销。
  • Zed 和 GoLand 保存时会按 goimports 整理 import 分组,所以报告里它们的“项目文件被改动”一列是“是”。Lithe 默认不整理,打字后保存,文件和原来完全一致。

后续改动请在后面进行补充,不要修改上面的内容

xiaoyumuxi and others added 2 commits November 15, 2026 20:49
ide-compare.mjs opens the Lithe repository in Lithe, GoLand, VS Code and
Zed with new, isolated profiles and nothing installed, samples every
launch with ide-compare-sampler-macos.c (phys_footprint per process tree
and macOS responsibility, CPU time, windows), terminates the instance and
checks nothing is left before the next launch. It writes results.json and
a Markdown report: time to the project window, time to idle, steady and
peak memory, idle CPU, processes, threads, install and profile size.

First-run behaviour that would distort the numbers is turned off: update
checks in every editor, GoLand's new UI tour (a modal dialog that holds
back indexing) and its What's New page, and Zed's automatic HTML
extension download. Profiles live in a short /tmp work directory because
VS Code refuses socket paths over 103 bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ide-compare.mjs gains a Go mode (--go FILE --lithe-plugin ID): every
editor also opens FILE, Lithe with the Go plugin the option names, copied
as installed in Lithe on this machine (the scripts name no plugin
themselves), Zed with its built-in Go support and GoLand as it ships.
Lithe and Zed use the same gopls from PATH with a gopls cache of their
own per launch. Memory and CPU are split into process groups so the
language server's share is reported, and the sampler now records the CPU
time of children a process waited for (childCpuUs), so short-lived go
command children are counted. --source and --name compare another
checkout, such as Kubernetes.

ide-compare-latency.mjs times Go to Definition, hover, Find References
and typing from the key press or pointer landing to the first changed
frame and to a settled screen. ide-compare-input-macos.swift records the
editor window with ScreenCaptureKit and sends CGEvent keys and pointer
moves only while the editor is frontmost, discarding samples Mission
Control or another window interrupted. Hovers use the mouse pointer, not
F1: the pointer comes along the target line from two characters to the
left, rests shorter than any editor's hover delay, then lands on the
character found by stepping the caret. ide-compare-lsp-proxy.mjs sits
between the editor and gopls and logs the server time of each request;
hovers are matched by their position.

scripts.md lists the three new scripts.
@ghfind-review ghfind-review Bot added the review: high ghfind author score; see https://ghfind.com label Nov 15, 2026
@xiaoyumuxi xiaoyumuxi changed the title feat(perf): 在 macOS 上对比 Lithe 与 GoLand、VS Code、Zed 的资源占用和 Go 交互延迟 Epic(compare): 在 macOS 上对比 Lithe 与 GoLand、VS Code、Zed 的资源占用和 Go 交互延迟(不合入,基准测试集,后续基准测试perf/ide-comparison分支中进行补充) Nov 15, 2026
Repository owner locked as too heated and limited conversation to collaborators Nov 15, 2026

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

review: high ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant