Repository navigation
[PR] perf: bound the initial context profile sample - #6656
Conversation
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 — #6656 是 #6655 的唯一 PR,无并列 PR 修同一问题。 Review of #6656 — perf: bound the initial context profile sample I read the diff, traced the algorithm, and verified it independently (not from the PR description). Direction (①) — correct. The issue is real and framed at the right layer: What I verified (③/④):
Regression (②) — none. The returned CI — 2 of 30 checks red: Quality (②a/⑤b, external submission — strict bar) — high. Small focused diff (2 files, 1 commit), correct algorithm, real oracle-based tests, reuses the existing Base — not stale: master advanced only touched 结构化八问
判定:可合(approve)。 代码正确、质量高、测试有牙、diff 干净;唯一 caveat 是两个 Windows flake(与本 PR 无关,重跑即绿)。 |
Closes #6655
Problem
The initial context profile retains 100 message samples, but first allocates and sorts a second array as large as the complete history. This makes a bounded observability feature add avoidable temporary memory and synchronous latency to a long session's first request.
Change
Keep the largest 100 entries in a sorted bounded sample as messages are scanned. Reject candidates below the cutoff before allocating a sample entry, insert equal-size entries after earlier ones, and continue computing token and character totals over the entire request. The returned profile and first-observation behavior are preserved.
Validation
tests/context-analysis.test.tspass, including a mixed 513-message history checked against a full-sort oracle, thinking-token ranking, complete aggregate totals, and 250 equal-sized messages across the cap.src/context-analysis.tsandtests/context-analysis.test.tspasses with--target ES2022 --module NodeNext --moduleResolution NodeNext --strict --skipLibCheck --noEmit.npm run buildandgit diff --checkpass.The complete repository
npm run typecheckcould not finish in this environment: the process was killed at the default/2048 MiB settings and exhausted the V8 heap at lower limits. The focused strict check succeeded; the complete typecheck and full-suite verdict remain for CI on the published head.Scope and base
No kernel, compression policy, configuration knob, dependency or wire behavior changes.
e5e1647ba0f92dfc36a96220f3e5c0d454218e2f.3be4ed07567a5bf901f1563bb86a0f14fe4f1552.29df36873efe7c707b1ceced5adea9ae24ae3f58matches the tested local tree.Hosted CI follow-up
On CI run 43565791430 for the published head, all Linux test shards passed. The Windows 22 and Ubuntu 24 static gates also passed, including the complete repository typecheck and build.
Two Windows test shards are red, so the overall CI result is not green:
persist-metadata-fold-gatecases fail while removing an openindex.dbwith EBUSY. The same failures recur in the runner's automatic retry.persist-zstdcases fail with the sameindex.dbcleanup lock. These two suites still remove their temporary directories without closing theirSessionStoreinstances. This matches the existing upstream issue [bug][tests] #6480 makes two legacy-envelope suites red on every shard: notice-registry inherits the legacy pin, persist suites hold index.db past rmrf #6547 and fix PR [PR] test: unpin legacy envelope suites from the storage baseline #6561, which is still open; this PR does not duplicate that work.issue4817-anchor-miss-recovery-e2ehappy-path test as cancelled withPromise resolution is still pending but the event loop has already resolved. Its cause, and whether it is related to this change, have not been established.