Repository navigation
[PR] fix: three performance and ID alignment issues (#5898 review fixes) | fix: 三处性能与 id 对齐问题(#5898 评审修复) - #5902
Conversation
…pter The tail-alignment check that binds client msgids to store rows had two loopholes, both of which let an even row shift pass undetected: 1. It role-checked only the last four positions where both sides expose a role. In an alternating user/assistant transcript an even shift preserves every role check, including those four. Now the full role sequence is checked wherever both sides have a role. 2. Nothing compared ids across turns. A store-side rewrite that moved a pinned row (compaction) could still hand its new ids to the client's rows. Each session now remembers the ids it last stamped plus the store row count, and the next alignment must agree with that record on every overlapping row. Append-only stores pass trivially; a moved row degrades the turn instead of misbinding (cost: that turn's pinning is skipped — the pre-fix residual behavior, which cannot leak ids across sessions because ids are never reused). Header doc no longer claims misbinding is impossible: it now states the cross-session guarantee (id reuse would be required) and the residual pure-even-late-append case, which no role observation can decide and which the continuity check bounds to pin drift. Default-off rollout lane (identityChannelHarvest 0%); tests cover the new even-shift, mid-window role-flip, and rewrite-moved-row paths plus the per-session state/eviction behavior.
…fire tryAnswerEarlyHold received a pre-parsed request model, so handle.ts ran requestModelFromBody — a full-document O(body) JSON walk — on every proxied POST. The early-hold gate itself bails for bodies under 1 MiB before the model is ever consulted, so sub-MiB traffic paid for a value that is discarded. The call site now passes a supplier; relay resolves it only after the protocol and byte-size thresholds clear. Sub-threshold and unknown-protocol bodies are never scanned (pinned by requestModelScanCountForTest: 0 scans below the gate, 1 at it). Plain-string callers keep the exact old behavior.
The #5744 rewrite compared every stored block against the incoming blocks with Array.some, making the stale sweep O(stored x incoming) per ingest; the pre-#5744 code had a Set for exactly this. Both the SQLite and MySQL engines get the Set back (behavior identical, membership only changed from a linear scan to O(1)).
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.8555-pr.5902.285201bThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5902.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 无其他在途 PR 修复同样这三处。#5907 是同一 #5898 评审的另一批发现(429 throttle 饱和/作用域、media-refs 携带过滤、oversize 拒绝文案、doc typo)——主题不同、互补不冲突;本 PR 只覆盖性能/id 对齐这三处。 结论先行:可合(建议合并)三个 commit 各自独立、最小化、互不影响回退。我逐个做了代码级回归审查,未发现回归;CI 在分支头 下面按三处分别给判断,再给结构化八问。 ① #5795 热路径白付的大 JSON 扫描 —— 干净,可合
② #5865 id 对齐两漏洞 —— 正确、测得扎实,默认关闭零影响
③ #5744 丢掉的 O(1) 集合 —— 铁板一块,可合
结构化八问
交付状态:PR 已打 (说明:本地无 node_modules,未重复本地跑测试——全量裁决以远程 CI 为准,我做的是代码级回归审查 + CI 核实;若你要我装依赖定向复跑某一条,我可以补。) |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1077-master.0ca35ee # this exact build
npm install -g billion-context@master # always the newest merged build
|
…es and the v0.1.213 release bump Upstream delta cda6e73..133f352 (13 files, 6 commits): - 8bf5317 fix: ranxianglei#5795 pay the early-hold body-model scan only when the gate can fire (tryEarlyHold now accepts `requestModel?: string | (() => string | undefined)`) - 8c6f07a fix: ranxianglei#5744 rebuild the O(1) incoming-block-id set the ingest diff lost - d29c73c fix: ranxianglei#5865 close the id-misalignment holes in the channel-harvest adapter - 98cd8a1 release v0.1.213 Overlap with the lane footprint was src/server/relay.ts and src/storage/mysql.ts; both hunks are disjoint from the lane's, and the merge was automatic. Verified after the merge: the lane's non-streaming egress is still at src/server/relay.ts:2070, MYSQL_SCHEMA_VERSION is still exported at src/storage/mysql.ts:77 with 6 consumers in the ranxianglei#4666 test, and the upstream requestModel supplier branch plus the incomingBlockIds Set are both present. Gates: tsc 0, four guards 0, gen-config-docs fixed point. Tests: issue5175 58/0, tag-echo 79/0, issue2190 32/0, golden-storage-render 5/0, storage-engine-proofs 12/0, issue4666 2/0, native-compact-terminal 1/0, issue5744-ingest-diff 5/0, issue5865-model-scan-memo 4/0.
这是什么
对 #5898(v0.1.212 → v0.1.213 大 diff)评审发现的三个问题,每个一个独立 commit,都带回归测试:
热路径上白付的一次大 JSON 扫描([bug][dsh] 429-hold + host retry ladder re-upload 51.2 MiB per retry (36/37 attempts failed) | 429-hold 与宿主重试叠加:每次重试重传 51.2 MiB,单步放大 2-5 倍 #5795 早退判定)
src/server/handle.ts不再预先解析,改传一个惰性求值函数;src/server/relay.ts的tryAnswerEarlyHold只在协议已知、字节数过门槛之后才真正调用它。requestModelScanCountForTest()钉住——过门槛的 body 扫描 1 次、低于门槛 0 次、协议未知 0 次;旧版直接传字符串的调用方式行为完全不变。渠道 id 对齐的两个漏洞,会把 id 贴错到错误的行上([PR] chore: empty PR — trigger ci:full on master head #5865 渠道收获适配器,默认关闭的灰度通道)
0.1.212: per-turn ingest is still O(history) — 96.5% of proxy CPU in StatementSync.run, event loop starves with 8 concurrent sessions (#4528 / #5469 follow-up) #5744 重构丢掉的一个 O(1) 集合,每次入库都变成 O(N×M)
能不能合并
tsc --noEmit干净。