Skip to content

perf(todos): reduce read startup and lineage costs - #7121

Merged
huangruiteng merged 3 commits into
loopx-project:mainfrom
hhyykk:codex/todo-read-cost-20261023
Oct 23, 2026
Merged

huangruiteng merged 3 commits into
loopx-project:mainfrom
hhyykk:codex/todo-read-cost-20261023

Conversation

@hhyykk

@hhyykk hhyykk commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Healthy todo list still paid for a fresh source-read thread pool and legacy history/mutation imports after #6874. This follow-up uses the existing ordered reader sequentially, imports registry/path functions from their canonical owners, and loads mutation error types when mapping an error. It also reuses request-local lineage facts and the existing succession context vocabulary, then materializes selected evaluations after complete graph validation and indexing.

The production delta is +3 net lines across seven files. Full-byte fingerprinting, post-read freshness checks, path validation, failure mapping and source lineage remain covered. The paired RFC checkpoint retains the original performance holds.

Measured on main 01f61ee9f versus head 3bfe577e6 with Python 3.13.12, Node 24.21.0 and the same synthetic 279-record SQLite exact-Todo query:

Complete CLI main candidate
p50 352.70 ms 256.49 ms
p95 444.34 ms 337.71 ms

p95 -24.00% / -106.63 ms. There were 64 alternating pairs plus one warmup per arm, ordinary managed IPC and one stable runtime PID per arm. All 130 complete JSON responses, including envelopes, matched after normalizing only four named ISO clock fields. Client CPU p50 was 243.29 → 169.10 ms. No concurrent author test/build jobs ran during this cohort.

Validation:

  • 73 native tests, 99 Python tests and 371 integration tests on isolated real PostgreSQL passed at 698529452. The final rebase absorbed only fix(research): make recorded measurements readable as a group #7119 frontend changes; the complete backend, relevant test and dependency trees are byte-identical. TypeScript checking and changed-path Ruff passed.
  • Fresh final-head wheel and sdist: 24 installed File/SQLite checks, including provider failure/recovery; ten source parity cases; installed Chat HTTP assets and the existing synthetic conversation-activity browser scenario passed.
  • Standard premerge passed (6 direct checks and 19 selected checks), including the complete CLI output matrix within the unchanged 120-second timeout. An initial long temporary namespace made the quota JSON budget fail identically on main and head (20,569 > 20,500 chars); the full gate passed with an ordinary short owned namespace. The initial failure and both baseline controls are retained; no budget changed.
  • Open-PR file census and hunk review found no duplicate implementation. Shared RFC/event-log files have unrelated hunks.

Owner review hold remains. Native diagnostics on that identical backend used 16 cold starts (p50/p95 236.69/468.73 ms), 128 warm one-record requests (2.25/4.29 ms), 64 complete in-process reads (67.51/114.05 ms), and RSS 210.96 → 243.88 MiB over 256 reads. The 2 ms warm p95 target is still missed. Sequential baseline batches had lower cold-start/complete-read tails (381.80/96.17 ms); this PR claims the matched full-CLI benefit. The earlier TS-only candidate's +8.51% full-CLI p95 regression is retained as a failed candidate. Performance limits are unchanged.

Local validation is Linux; cross-platform CI remains pending. This proposal does not grant merge readiness.

Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com>
Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com>
Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · max

APPROVE — 既有 Todo 读取路径的有界性能增量

审查完整 head:3bfe577e69937d71938406869e8e526c0e481df9;独立 base:01f61ee9f3b993bfafc11419ea1842e722906957。本轮没有发现需要修改的代码问题;批准范围是本 PR 的读取优化,现有暖请求 hold 与完整迁移验收仍保留。

动机

受影响的是通过 Todo 读回安排下一步工作的维护者和 Agent。

例如,新进程从包含279条记录的 canonical 来源读取一个 Todo,原路径仍要为包指纹创建读线程池、加载历史/变更模块,并重复准备部分血缘投影;本提案减少这些读取准备成本。

同一合成来源的 File/SQLite 完整读回、筛选及失败恢复保持一致;32对 SQLite 完整 CLI 交替测量支持本次启动成本下降。

本轮不宣布 TS 迁移、默认后端资格或长期净收益完成,不改变调度、权限、Todo 状态或安装版本。

既有暖请求2 ms p95目标仍是 owner review hold;跨平台、长时间运行和完整迁移验收继续由原验收边界负责。

这里的价值是让同一项已授权读取更快结束。减少 RPC、变小的 helper 或绿色检查都不能单独证明这个价值,因此本轮直接比较完整 CLI 与完整返回内容,而不只测继任计算。用户继续使用原命令、原结果和原恢复路径,没有新增设置、确认或需要手动同步的状态。

改动思路

复用 canonical 读取、完整图继任 owner 和原有有序文件读取器,能减少准备开销而不另建缓存、账本、RPC或第二个规则 owner。

当前 PR 交付的是既有 Todo 读取路径的性能增量,保留完整来源、错误和新鲜度语义;它不晋升整个迁移阶段,也不免除现有暖请求目标。

我比较了不改、只优化 TS helper、缓存包指纹/血缘、以及当前方案。只改 helper 不能覆盖新进程导入和指纹准备;持久缓存则引入新的失效判断。当前方案复用已有顺序读取模式和 canonical 模块,让完整图继续决定结果,只避免重复准备与生成随后丢弃的评估。它没有增加跨语言往返、持久状态、独立 provider 或用户控制面。

最有力的反对理由是:顺序 IO 在不同文件系统上可能有不同代价,局部加速也可能掩盖完整命令尾延迟。因此下面保留真实入口、完整来源、失败恢复和同负载比较;没有用更大的预算、删字段或放松新鲜度换取通过。更大的缓存/provider/语言迁移不属于本切片。

具体改动

完整差异为 12 个文件,+85/−53:7 个生产文件净增加3行,2份英/中文 RFC 和3个相关测试。没有新增模块、RPC、公开参数、协议字段或生成文件。

独立规范:spec_ref=docs/architecture/rfcs/typescript-control-plane-migration-v0.md,spec_revision=01f61ee9f3b993bfafc11419ea1842e722906957。先读已接受的 source checkpoint、§5与§6,再读实现;本 PR 新增的说明不是它自己的验收依据。按原文标题映射:

  • Todo read transaction source checkpoint — implemented:完整活跃/归档血缘、全部源码字节与读后新鲜度检查保留;读取不产生执行或完成权限。
  • Payoff-phase PR contract — implemented:活跃读入口上的机制成本有界,没有新 bridge;净行数只说明维护成本,不作为收益证明。
  • Caller-observable semantic parity is a promotion gate — implemented:immutable base/head 的真实 File/SQLite 配对、完整诊断与恢复、以及故意丢失覆盖字段的敏感性检查均执行。
  • Performance — deferred(完整阶段资格):完整 CLI 的本轮观察支持优化;原暖请求2 ms目标及后续发布/持续运行验收仍归原 owner,不把这个增量说成整个性能阶段通过。

关键代码与调用关系:

  1. _runtime_fingerprint_for_snapshot 给现有有序读取器传 max_workers=1。仍按 snapshot 顺序哈希名称和每个字节,并执行原来的读后重扫;省去线程池创建,没有磁盘缓存或跳过文件。
  2. projectCanonicalTodoFields 在两个角色摘要前准备一次 lineage facts。context_fields 使用继任 owner 已有的字段集合;旧 decoder 本来就按该集合过滤、排序,因此不是删除有意义上下文或引入新的分类规则。
  3. evaluateTodoSuccession 仍先解码每条来源、拒绝重复身份并构建完整索引,再从 resultStart 开始生成需要返回的评估。未显示的归档依赖仍参与判断;其他调用者默认0,继续取得完整结果。新增测试也把无效或重复来源放在省略段,确认它仍会拒绝。
  4. todo_error_payload 只延后导入已有错误类型,实际失败仍进入相同映射。cli_rollout/list_readback 直接使用 registry_codec.load_registry,rollout_event_log_path 使用同一个 canonical 路径验证器,健康读取不再借由 history 加载变更模块。

对主干的风险

本轮当前 exact head:81项相关 Python 回归、59项原生 Todo/继任检查、真实隔离 PostgreSQL authority-store 套件通过;TypeScript typecheck、Ruff、配置内 mypy(17个文件)及标准 premerge 的6项直接检查、19项选择检查通过。PostgreSQL 实例使用已缓存镜像、单独数据库和回环端口,结束后已清理。没有读取、轮询或等待远端 CI。

独立真实 CLI 比较覆盖 24组 File/SQLite 分支:完整、精确、thin、limit、角色/Agent/完成状态筛选、缺失身份、非法组合、provider 缺失与恢复。279条 canonical 来源包含归档与两种角色;完整查询应返回219条活跃记录,限制显示不能把完整来源变成不存在。base/head 完整返回仅排除经时区验证的生成观测时钟,没有去掉错误、修复提示、状态、身份、路径、来源哈希或权限字段。

敏感性通过同一个真实 SQLite CLI:在内存中故意把成功结果的 included_count 改成0,独立的219条覆盖 oracle 以 exit 1失败;未修改源码工作树。原 base/head 的同一 oracle 都通过。源码消失、持续 churn、未显示的无效/重复血缘以及健康入口不加载 history/mutation owner 也有相关回归覆盖。

同一物理合成来源,验证构建完成后顺序执行2对预热、32对交替完整 CLI 测量,正常 managed IPC,全部测量返回语义一致:

SQLite 完整 CLI base head
p50 234.55 ms 176.13 ms
p95 254.88 ms 188.02 ms

这是本机 Python3.12.15/Node24.21.0 的有界命令观察,支持启动优化;不是稳定跨平台 SLO、长期完整成本或 profiler 因果分解。作者保留的早先回归候选、长临时路径预算失败和暖请求 miss 仍是其原始观察;本轮没有重命名为通过。Reviewer 合成 fixture 曾遗漏 schema、临时 PostgreSQL 初始化检查曾把镜像自带匿名数据卷当作主机绑定,均在产品测试前拒绝;修正准备条件后运行,原记录保留,未降低任何产品断言。

我的整体评价

APPROVE 这个增量。 它解决了实际读入口的可测准备成本,复用边界比另建缓存或再迁移一个 leaf 更合适;完整来源与失败恢复没有为了速度被削弱。已应用的 bounded improvement 是 canonical import、上下文字段集合与请求内事实复用;没有证据要求进一步造框架或扩大切片。

长程效果判断为 preserved:没有改变后续工作准入、完成、重试或归属。用户体验在已测 CLI 任务上改善:结果和恢复相同、等待缩短、额外必需交互为零。完整差异没有渲染 UI 改动,已有 App/Lark 使用同一返回合同,不需要为内部优化制造新页面或视觉证据。安装后的 Host、WebView、其他平台/Python版本、整套仓库测试与真实 Agent 采用未验证。

原验收中的暖请求目标仍需原 owner 处理,本评论不授权合并、安装或迁移晋升。经验中“先判断实际有用结果、沿已有 owner 验证真实任务”的建议在本轮用于完整 CLI/恢复比较;上下文送达或检查通过本身不构成经验效用或长期收益证明。

English verdict: APPROVE — 3bfe577e69937d71938406869e8e526c0e481df9 as a bounded Todo-read performance increment. 24 real File/SQLite paired branches preserve full observable semantics; 81 relevant Python, 59 native Todo, real isolated PostgreSQL, typecheck/Ruff/mypy and selected premerge checks pass. In 32 alternating SQLite CLI pairs, p50/p95 improve from 234.55/254.88 to 176.13/188.02 ms. Complete lineage/fingerprint validation remains; the existing warm-request hold, sustained/cross-platform qualification and merge authority remain separate.

@huangruiteng
huangruiteng merged commit 7191199 into loopx-project:main Oct 23, 2026
25 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants