Repository navigation
Conversation
Avoid repeated suffix searches when settling a long transcript and defer boundary work until append/head checks need it. Fixes ranxianglei#6839
Owner
(ai: vllm-qwen/qwen3.8-27b) Reviewed PR #6843 against current master ( What I verified (evidence, not "should work")
Why the fix is correct (independent read of the diff)
Minor (non-blocking)
结构化八问
判定:可合并。 范围清晰、修法打到根因(线性化 + 惰性求值,不是堵症状)、回归测试有牙(在 master 上真实失败、PR head 通过)、对照充分。CI 测试车道全绿,仅剩 6 个次要 guard/docs 检查在排队(非失败)。 |
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6839
Problem
Settling a normal appended turn can block the proxy event loop for seconds once the retained transcript reaches a few MiB.
messagesArrayCloseOffsetperforms separateBuffer.indexOfsearches for quotes, backslashes and structural delimiters from every segment. Searches that find no delimiter, or a distant array boundary, repeatedly traverse the same remaining body.Change
Scan each byte once while retaining the existing string, escape-parity and UTF-8 byte-offset rules. Run the array-boundary and semantic-insertion checks only after the cheap append/head decisions need them. Both compression modes share this bookkeeping; request bodies, compression behavior and diagnostic classifications are unchanged.
Add a regression through the public
noteForwardedBody/settleUsageReportpath. It measures native search spans without a wall-clock assertion: unchanged source searches 793,522,314 bytes for a 219,319-byte transcript and fails the bound. Additional controls cover all three history keys, nested arrays, escaped delimiters, CJK text, actual mid-history edits and an unlocatable array.Validation
npm run build, test-import-graph gate andgit diff --check: passed.2e3cfc973b8620b1f7bc8a415ddcbd31e7f4aaeebefore publishing. Remote tree19a3d90dd77c9131e31c14deaac07294bb8b424cexactly matches the tested local index.Local benchmark
Node v24.22.1, Linux; alternating user/assistant prose, followed by one appended user message. Capture and settling are included; body construction is outside the interval. One warmup and three measured iterations, each checking the existing
tailclassification:Reproduce with
node --import ./tests/preload-test-env.mjs --import tsx scripts/bench-cache-array-scan.mjs 1000 4000 8000. Timings vary with machine/load; these are local bookkeeping measurements, not end-to-end proxy throughput claims. CI uses the deterministic work-bound test instead of timing thresholds.Prior work
Checked all 134 Afloat16 PRs plus all-state body-stability/suffix-scan searches and relevant commit history. #2139, #2870, #2983 and #3479 establish the retained classifications; #6722 optimizes ordered usage alignment and is already on master. This change addresses the remaining boundary scanner.