Repository navigation
[PR] Fix #4178: Space-separated citation strings trigger catastrophic backtracking (28 citations take 11 s; upstream streamin | 修复 #4178:空格分隔的引用串触发灾难性回溯(28 个引用 11 秒,上游流式一卡一卡) - #4180
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g [email protected]This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4180.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 检索 open+closed issue/PR(按失败签名:REFS_RUN / 灾难性回溯 / tag-echo 流式卡死),无其他在途修复或立项——本 PR 是 #4178 的唯一修复;#3198(determinism 语料长度)、#2023(orphan 引用形状)是 #4178 引用的背景条目,机制不同,不构成重复。 开始独立审核(不复读 issue 结论):
结论稍后按八问给。 |
5aa67ba to
c3b4985
Compare
c3b4985 to
62252d2
Compare
(ai: vllm-qwen/qwen3.8-27b) 结论先行:修复正确,独立复核通过;本 PR 自身的全部 CI 车道绿。当前 6 个红 shard 是 master 自身的回归(与本 PR 零交集),已单独立项 #4196。master 转绿后即可合并(若期间 master 再动,rebase 应无冲突——本 PR 只碰 八问:
行为变更披露:无用户可见行为变化——正则语言旧值→新值完全相同,唯一变化是匹配耗时从指数降为线性。 收工判定:代码侧收工;等 #4196 把 master 拉绿后即可合并。 |
…racking The refs-run separator \s*[–—,-]?\s* admits two parses of the same whitespace span; when a later alternative fails (ORPHAN_REF_CLOSE, PARTIAL_TAIL), the engine replays 2^N partitions over an N-ref run. One push of 28 space-joined refs took 11s (34 ≈ 1.2h); comma-joined and whole-text stripAcpTags were unaffected. Rewrite as \s*(?:[–—,-]\s*)? — same language (4352-shape equivalence corpus, 0 diffs), exactly one parse per span. After: 200 space-joined refs = 0ms. REFS_RUN is shared by ORPHAN_REF_CLOSE / PARTIAL_TAIL / ORPHAN_RUN_BEFORE / REFS_ONLY / PAIRED / PENDING_REF_SPAN, so all six callers get the fix. Found by BEX bounded-exhaustive sweep (label verif工具发现, issue #4178). Adds a linear-cost timing pin (40/200 refs < 1s; regression = minutes).
Review follow-up on the #4178 fix (labeled, same mechanism family): PENDING_REF_SPAN and PARTIAL_TAIL arm 5 each carried their own inline copy of the old ambiguous separator idiom (\s*[joiner]?\s* before the partial-ref tail). They are single optional groups, not iterations, so their worst case is linear in trailing whitespace — NOT the exponential DoS of REFS_RUN — but they are the same defect family and the same trap for whoever next nests them. Rewritten to the one-parse-per-span form (\s*(?:[joiner]\s*)?), language-equivalent per site. Verified: 300k-string differential fuzz of old vs new forms over the run pattern (leftmost match span from every m-anchor) plus the full PENDING_REF_SPAN / PARTIAL_TAIL-tail anchored patterns — 0 divergences; tag-echo suites (tag-echo, chunking-determinism, SSE CRLF cross-chunk, e2e-tag-echo) + new timing test: 91/91 pass.
62252d2 to
2e0fd7c
Compare
(ai: vllm-qwen/qwen3.8-27b) CI 修复完成:PR 已 rebase 到绿色 master,全量 CI 通过。 新 head 结构化八问1. 是什么问题:本 PR 的 CI 有 6 个 test 分片红,但逐条核对失败清单后确认:没有任何一条失败与这个 PR 的代码改动(tag-echo 正则)相关——全部落在 window/preflight/models.dev 域(models.dev 查询、codex UA clamp、#1339 beta-1M、sideRequestGuard #554、storage-render golden、nudge 分母等)。红是分支基座太旧拖进来的 master 侧存量问题,不是本 PR 引入的。 2. 什么原因导致的(两层):
3. 影响范围与严重程度:对本 PR——无用户面影响,代码本身此前已被独立审核验证正确(floor 3-4 的 differential fuzz 0 差异),红的只是合并门禁。对 master——win22-1 这个 drain 让 master 自身当前是红的:master 在同一 head 4. 怎么修复的:不改任何代码。① rebase 到绿色 master(机制:让分支吃到 #4198 的修复),force-with-lease 推送;② 对残留 drain 使用 CI 系统为 #3665 家族预设的处置——新 runner 重跑失败 job。 5. 是否有回归问题:无。本会话未改任何行为:rebase 前后 PR diff 逐字节相同(已用 6. 是否破坏缓存:不涉及——未触碰缓存、重试、增量游标、去重键逻辑。 7. 是否改了设计方向:没有。 8. 是否引入了新的配置:没有。 给 owner 的两件事
收工判定:PR #4180 CI 全绿,具备合并条件;合并仍归人。 |
这是啥问题(#4178)
模型在输出里复读一串空格分隔的内核引用(
m1111 m1111 m1111 …)时,流式过滤器一个 push 就会指数爆炸:28 个引用 11 秒,34 个约 1.2 小时——期间这条流式管线完全卡死。上游只要这么回声一次,后面的 token 全部排队等待。逗号分隔的同样内容只要 2ms,所以只在「空格 + 后续匹配失败」这个组合上爆炸。根本原因
src/loop/tag-echo-filter.ts的REFS_RUN分隔符写成了\\s*[–—,-]?\\s*——两端的\\s*都能吞同一段空格,同一段文本有 2^N 种切法。后面的分支(ORPHAN_REF_CLOSE/PARTIAL_TAIL)一旦匹配失败,引擎就回放所有切法。经典嵌套量词灾难性回溯。如何解决
改成首字符互斥的等价写法
\\s*(?:[–—,-]\\s*)?(先吞前导空格,再可选一个连接符+尾空格)——同一跨度只有一种解析。语言完全等价:4352 个形状的等价性对比 0 差异。修复后 200 个空格引用 = 0ms。REFS_RUN被 6 个正则共享(ORPHAN_REF_CLOSE / PARTIAL_TAIL / ORPHAN_RUN_BEFORE / REFS_ONLY / PAIRED / PENDING_REF_SPAN),一处修完全部受益。验证
tests/issue4178-refs-run-backtracking.test.ts:40/200 个空格引用 + 失败尾巴形状,计时 < 1s(回归时会到分钟级)来源
verif 工具链 BEX 穷举发现(issue #4178,标签
verif工具发现)。Closes #4178