Repository navigation
[PR] fix(#5337): long-session per-turn freeze — quadratic compress screening goes linear - #5361
Conversation
…uadratic recommend screen goes linear The recommend node re-screened every candidate unit through projectUnit, and each projection rebuilt its full-history derivations from scratch: five indexless linear id lookups (.find/.includes) plus repeated whole- array rescans (protected/latest/aged tool-call sets, tool-pair map, last-user anchor, turn-integrity pre-scan). Cost: O(units x n) on top of O(n) — ~17s of blocked event loop for one processTurn at 23k core messages on the #5304 repro machine; every turn of every large session paid it (#5337). buildProjectionShared(messages, state, config) computes each derivation ONCE per screening pass; screenRecommendedUnits shares it with every unit in that pass. projectUnit accepts an optional shared context and falls back to the exact legacy inline computation when absent, so the single-shot apply/report paths stay byte-identical. Id lookups go through a built-once raw-id->index map; the truncation-check dropped- set membership becomes Set-based (was includes-in-some). The judgment itself (#3236 one-judgment discipline) is unchanged — only how its inputs arrive. Same-machine same-corpus wall clock (warm, best-of-3): real recommend chain n=20000 9028ms -> ~572ms (~16x). kernel v0.0.174.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.7575-pr.5361.ccc0c1eThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5361.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 本 PR(#5361)是 #5337 决策申请中选项 A(纯算法优化,O(n²)→O(n),判定行为零变化)的实施,与症状报告 #5304、更早的让出类修复 #4528/#4544(机制不同:相位边界让出事件循环,已合并但单独不够)均非重复——检索 open+closed 无同机制的既在途 PR。 标签: 初审状态(进行中):
完整八问结论稍后在本帖补上。 |
… foldability screen too The acp_status uncompressed view (#3236) runs projectUnit once per displayed row without the shared context — the same per-row full-history O(n) rescan family this PR removes from the recommend node. The issue report names status refresh as a freeze victim ('every compression, every status refresh waits'); wire buildProjectionShared into that loop so the fix covers both surfaces. Judgment is unchanged: shared vs non-shared projections are byte-identical (pinned by tests/issue5337-shared-screening.test.ts).
(ai: vllm-qwen/qwen3.8-27b) 审核结论:技术面通过(独立复核,非照抄 PR 声明);合并被一个人工门禁卡住——PR 正文缺 ① 原 issue 方向关:方案 = #5337 选项 A(纯算法优化、判定零变化),与决策申请一致;修的是 O(n²) 的生产者(每单元从零重推导),不是症状层拦截。方向正确。#5337 线程里没有你的明确批准记录(仅"等待你拍板"结尾的评论),PR 由 ranxianglei 账号提交——若你本人所提视同已批准,在 #5365 回一句确认即可。 ② 回归审查(既有行为逐项清点):
③ 代码审查 + 顺手修掉的两处(review 发现,已 push,独立标注 commit):
④ CI 现状:head d24ff55 上 kernel-guard=红(缺声明)、lock-sync=红(kernel lockfile,已修)、test 矩阵因 needs 这两个门被 skip——全量测试尚未跑过。push ac057ca 后 lock-sync 应绿;kernel-guard 等 #5365 拍板后补声明即绿,test 矩阵随后开跑做最终把关。 结构化八问:
收工判定:开发侧闭环(代码+等价性测试+lockfile+status 视图漏网补齐,定向验证绿,已 push ac057ca);合并卡在人工门禁——#5365(kernel authorization request,p1):A 批准 → PR 正文补 附:过程中误建了一个垃圾帖 #5364(建单 API 路由探测的副作用),已留评论说明,待你关闭。 |
|
retrigger: pick up updated PR body (kernel-change declaration) for kernel-guard |
|
retrigger again: kernel-change declaration line had stray markdown bold; fixed to plain token |
(ai: vllm-qwen/qwen3.8-27b) 已核对,retrigger 已生效:
下一步:等 test 矩阵全量结果;kernel 变更恒 human-only,我不合并。有红我第一时间定向排查。 |
(ai: vllm-qwen/qwen3.8-27b) 进展:两个红门已绿,test 矩阵开跑了。 kernel-guard(声明已识别)+ lock-sync(kernel lockfile 修复生效)通过——test 矩阵的 11+ 个分片(ubuntu/windows × node 22/24)与 static-gates 已创建并开始排队执行。全量结果出来我再报;有红我第一时间定向排查。 |
# Conflicts: # CHANGELOG.md
… 0.0.174 (version collision on merge; order coupling noted here)
(ai: vllm-qwen/qwen3.8-27b) retrigger 生效了,但期间分支状态变了两轮,我已全部处理完并重新推上——当前 head 发生了什么、我做了什么:
PR 正文里「v0.0.173 → v0.0.174」的表述现在实际是「master 的 0.0.174 → 0.0.175」;CI 只 grep 下一步:test 矩阵结果出来我报;绿了之后这一步就剩 human-only 合并。 |
什么坏了
长会话每回合把 Node 主线程卡死十几秒:网页面板冻结、新请求排队。2.3 万条核心消息的会话,单个回合实测约 17 秒(报告见 #5304 / #5337)。每次压缩、每次状态刷新都要等它跑完。
为什么
每回合的「压缩筛查」把历史切成若干可折叠单元,逐个问一遍"这段能不能折"。问题在每个单元都从零重算整套全史推导:
.find()/includes(2.3 万条时单次几毫秒);V8 profile 签名(#5337 里已附)与本报告复现一致:热点全部落在这一族函数上。
怎么修的
把这套 O(n) 推导提升为每轮筛查构建一次(
buildProjectionShared),同一轮的每个单元共享;id 查找改为一次建好的序号表;截断检查的"已丢弃"成员判断从includes-in-some改为 Set(这处单独还是单元宽度平方)。判定逻辑本身一字未动——"能否折叠"的判据(#3236 单一判定纪律)不变,只是输入到达判定的方式变了。
projectUnit的新参数是可选的:不带共享上下文的调用方(apply/report 单次路径)走原来的内联计算,输出逐字节不变。同机同语料实测(预热后 3 次取最快):
曲线回到线性量级。
为什么不担心回归
备注
kernel-change: #5337 option A(owner 于本会话批准开工,2026-10-31)——把每轮压缩筛查的 O(n) 全史推导从"每单元重算"提升为"每轮一次共享",长会话每回合的二次方卡死降为线性;判定输出不变,由等价性测试逐字段钉住。kernel v0.0.173 → v0.0.174。