Agent 与自动化 4.0 · 优秀 2026-11-12 · 文章

Worshipping at the altar of Brendan Gregg

Rewind 作者给确定性 Linux VM(单 vCPU)加了 rewind time 命令,对一次 libuv build+test 录制做关键路径分析:78.0 秒实际耗时,关键路径下限 47.4 秒,其中 67% 在睡觉,CPU profile 采不到;make check 占 41.9 秒,lt-run-tests 把 287 个测试串行成链,核再多也压不下去数据免费是因为回放必须记录每次上下文切换,方法承自 Brendan Gregg 的 off-CPU 分析,还能导出 Perfetto trace

打开原文回到归档

Worshipping at the altar of Brendan Gregg

中文导读

Rewind 作者 Farid Zakaria 给他的确定性 Linux VM(单 vCPU、x86_64,引擎与 CLI 以 MIT 开源)加了 rewind time 命令,对一次 libuv build+test 录制做关键路径分析:78.0 秒实际耗时,关键路径下限 47.4 秒——即使给 64 核构建机,这个下限也不变。47.4 秒里 67% 在睡觉(epoll_pwait 23.1 秒、clock_nanosleep 8.53 秒、futex 100 毫秒),33% 在计算;睡着的线程在 CPU 采样器眼里不存在,这是 off-CPU 分析才看得到的。往下拆:checkPhase 占 42.0 秒,其中 make check 41.9 秒,lt-run-tests 把 287 个测试串行成链(每个 1–3 秒),链是单条,核再多也压不下去。drag 维度问"这部分归零全流程能提前多少":36.1 秒归于每个 lt-run-tests(600 个进程)、6.66 秒归于每个 cc1(283 个进程)。最有意思的收场:hrtime 测试在 clock_nanosleep 上睡 3.38 秒(占路径 7%),rewind where 回放到第 115,894 步、gdb 摊开栈定位到 uv_sleep(45)——但作者脚注承认这个 sleep 是测试目的本身,可省的 drag 为零。数据之所以免费,是因为 Rewind 为回放必须记录每次上下文切换,谁唤醒谁也就顺手记下了;方法直接承自 Brendan Gregg 的 off-CPU/wakeup profiling。rewind time --perfetto F 可导出 Perfetto trace 直接进 ui.perfetto.dev。

为什么值得关注

系统里某个硬需求逼着你把数据存下来时,性能分析可以变成顺带产物——这与真机上开 trace 的存储/功耗矛盾是同一个结构的解法。对调试 AI coding agent harness 的构建/测试耗时(同样长尾、同样睡多算少),关键路径 + drag 双维度加"回放到任意一步调 gdb"是活机器上目前少见等价物的组合。代价也明摆着:确定性是拿真实并发换的,只有单 vCPU,HN 评论已质疑其对高吞吐多线程流水线的意义。

关键信息

  • 命令:rewind time;对象:libuv build+test 录制
  • 数字:78.0 s elapsed / 47.4 s critical path(下界)/ 67% asleep(epoll_pwait 23.1 s、clock_nanosleep 8.53 s、futex 100 ms)/ 33% computing
  • phase:configurePhase 3.54 s、buildPhase 1.67 s、checkPhase 42.0 s、其余 99 ms;make check 41.9 s;lt-run-tests 36.4 s、287 个测试串行(各 1–3 s)
  • drag:36.1 s every lt-run-tests(600 processes)、6.66 s every cc1(283 processes);hrtime 测试 3.38 s 在路径上但 sleep 是故意的、可省 drag 为零
  • 回放:rewind where 7a29e716 115894 --pid 5412 → gdb 栈 uv_sleep(src/unix/core.c:1869) msec=45,75 次共 3.38 s
  • 产品口径:Rewind v0.18.0、x86_64 Linux、单 vCPU;引擎与 CLI MIT,桌面个人版 $49;确定性来自单核 + 隐藏时间源(timestamp counter/RNG 隐藏,KVM dirty-page log 每 0.25 s 做 keyframe,BLAKE3+zstd 内容寻址)
  • 方法源头:作者脚注声明思路来自 Brendan Gregg off-CPU / wakeup off-wake profiling;rewind time --perfetto F 导出 Perfetto trace
  • HN:2026-11-24 上 HN(item 50626413),11-25 08:40 CST 快照 219 分 / 41 评论;作者本人在评论(setheron)说明文章偏想法与调查过程

English Summary

Farid Zakaria, author of Rewind - a deterministic single-vCPU x86_64 Linux VM whose engine and CLI are MIT-licensed - added a rewind time command and applied it to a recorded libuv build-plus-test run: 78.0 seconds elapsed against a 47.4-second critical-path lower bound that would not shrink even with 64 build cores, with 67 percent of the path asleep (epoll_pwait 23.1 s, clock_nanosleep 8.53 s, futex 100 ms) and therefore invisible to CPU profiling; make check accounts for 41.9 s, with lt-run-tests serializing 287 tests at 1-3 seconds each. The drag view attributes 36.1 s to every lt-run-tests (600 processes) and 6.66 s to every cc1 (283 processes), while an hrtime test that sleeps 3.38 s on the path is intentional, so the removable drag is zero. The data is free because replay requires recording every context switch and wakeups come along; the method follows Brendan Gregg's off-CPU and wakeup profiling, and rewind time --perfetto F exports a Perfetto trace. Determinism trades away real concurrency: one vCPU only. A useful methodology reference for profiling build/test-heavy AI coding agent harnesses.

Obsidian Notes

  • 全部数值锚定在 OpenClaw定时任务/X工作日草稿/2026-11-25-X工作日草稿.md:作者 GitHub raw markdown(commit e5810dd,19,074 B)逐字核对 + rewindvm.dev 产品页 + HN Algolia 评论树(41 条)。
  • 219 分/41 评论为 2026-11-25 08:40 CST 快照值;本机未实测 Rewind。