Repository navigation
Boot warm set off by default: sessions hydrate on first touch (#3050 R3 step 1) - #3194
Conversation
…st touch (#3050 R3 step 1) sessions.warmMax default 8 -> 0. Measured on a production data copy (661 sessions / 117 MB index.db): warm=8 cost 151 MB RSS at idle boot (623 MB vs 432 MB warm=0). First touch now pays one on-demand load (unified-first lookup or envelope read) instead; bounded-storage already pins the lazy-reload path, and the knob/env stay for opting back in.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3752-pr.3194.43f8089This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3194.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…ager opt-in leg The boot-restore contract (restored flag, lastSeen=savedAt, freshness-keyed truncation) now has two legs: the new default (boot warms nothing; the first loadSync carries the same restored/lastSeen stamps) and the opted-in eager warm set (BILI_SESSION_WARM_MAX=2 keeps the original truncation assertions). _resetSessionsForTest also resets the initSessions flag so a test can boot twice — a fresh process starts with it false either way.
…p the bounded view (#3050 R3 step 2) writeNow/flushSync foldResidentTail: after a successful save of a session with inFlight===0, session.lastMessages drops to boundedFoldedSnapshot() and lastMessagesFolded=true — exactly the shape buildSession restores on restart. Mid-turn saves (inFlight>0) keep the raw tail; snapshotMessages re-arms the raw copy on the next request either way. Envelope re-saves are idempotent (pinned), the shadow oracle snapshots the live tail it handed the ingest before the fold, and the unified table keeps raw rows via the ⑤ rawTail override + #3166 watermark (append-only past the boundary). tests/memory-tail-folding.test.ts: fold/idempotence/restart-parity/re-arm.
|
R3 step ②a added (eac26ac): Resident effect: the raw tail's ceiling drops from 'whole resent history' to |
(ai: vllm-qwen/qwen3.8-27b) Reviewed both heads of the branch. Summary: step 1 (c6e62d9) had one real regression — now fixed by 50288b5; step ②a (eac26ac) reviewed clean. No code pushed by me (I had prepared an equivalent #404 test fix locally, discarded it when I saw your commit landed — yours is better, it also pins the new lazy default). The step-1 regression (fixed in-branch): under Step ②a review (eac26ac): verified the safety chain rather than trusting the tests alone:
Local evidence at eac26ac: memory-tail-folding + issue404 + storage-unified + bounded-storage + knobs-config-precedence = 42 pass / 0 fail / 1 skip; persist-tail + multi-instance-live = 8/8; tsc clean. CI at eac26ac: 42 check-runs, zero failures so far (test shards still running). Behavior changes to disclose (old → new):
中文结构化八问:
判定:可合并 —— 等 eac26ac 的 CI test shard 全绿即可 merge(人工操作)。此前唯一的真回归已在分支内修复并有测试钉住。 |
…a re-materializable shell (#3050 R3 step 3) LazyBlockContents (Map subclass, store-bound loader closure): after an idle save, dropResidentBlockContents swaps the resident map for a dropped shell; any read/write/iteration re-materializes the full set through SessionStore.loadSync (one disk read per burst). deepSizeOf reports the shell at ~0 without materializing (diagnostics stay non-invasive). An unrecoverable drop THROWS on access — a save iterating a silently-empty set would otherwise erase block contents from the persisted record. plugin-fork deepEqual updated to content-level compare (constructor changed by design).
|
R3 step ②b added (c89e550): idle sessions fold their resident block-contents map to a Measured effect on the fattest dogfood session: blockContents 27.4 MB → ~0 while idle. Combined with ②a (raw tail 46.9 MB → bounded view), the three big resident fields of an idle session now all fold: ~75 MB off per idle fat session. |
(ai: vllm-qwen/qwen3.8-27b) Correction to my previous review — I retract "step ②a reviewed clean". After my reply, CI went red on Mechanism (verified by probe, not guessed):
Bisect evidence: green at c6e62d9, red at eac26ac; deterministic locally on Linux (so the 4th OS×node combo will go red too when its shard finishes). Suggested fix direction (your call — host-side, since
The other five red shards are the known flake classes, unrelated to this PR: port-zone-live ×2 + performSelfRestart (fixed-port 18787 EADDRINUSE / live-process timing, #3044/#394 family) and hook e2e pinned-port ×2 (claude-native; passes standalone 50/50). Step ②b review (c89e550): design checks out — drop only after a successful capture (control-flow guard; writerOff/full-mode sessions re-materialize from index.db via the store-bound loader); unrecoverable drop throws on access instead of persisting a thinned set (correct fail-fast); Map accessor override surface is complete ( Updated verdict: NOT mergeable yet — blocked on the ②a reorder/drift regression above; once fixed, re-run full CI (expect the storage-save-path shard to flip green; the flake-class lanes may need a rerun regardless). |
(ai: vllm-qwen/qwen3.8-27b) Status check (no new branch activity since my correction above):
Verdict unchanged: not mergeable until the ②a regression is fixed and CI is green (human merge, as always). |
…keeping to a re-materializable proxy (#3050 R3 step 4) lazyMetadata(): transparent Proxy over the metadata record; after an idle save the record folds away and any trap (get/has/ownKeys/set/delete/ defineProperty) re-materializes the PERSISTED shape through the store-bound loader — the exact record a restart restores (buildRecord stamps biliVersion/storageMode, so the materialized shape carries them). Persisting walks the proxy and materializes the full set: no thinned erase; an unrecoverable drop throws on access instead. ResidentFieldBreakdown gains a metadata column (deepSizeOf reports the dropped proxy at ~0 without materializing). Measured: metadata was 19.6 MB on the fattest dogfood session (foldAnchors/cacheLedger/ foldPositions dominate).
|
R3 step ②c added (28ba72e): idle sessions fold their Measured on the fattest dogfood session: metadata was 19.6 MB (foldAnchors 1.9 MB JSON / cacheLedger 1.3 MB / foldPositions+order 0.8 MB — tiny-object overhead inflates them to 19.6 MB in RAM). R3 ledger after ②-0+②a+②b+②c (same idle fat session): raw tail 46.9 MB → ~65 KB · blockContents 27.4 MB → ~0 · metadata 19.6 MB → ~0 · warm pool −151 MB at boot. All four steps in this PR. |
(ai: vllm-qwen/qwen3.8-27b) Step ②c review (28ba72e): design checks out. Traps are complete for a record-shaped object ( But the ②a regression from my correction comment is still unfixed at this head. Re-verified locally at 28ba72e: Reminder of the two suggested directions (either works, host-side): skip the fold when Also still open: the one-line indentation nit at Verdict unchanged: not mergeable until the ②a regression is fixed and CI is green. Everything else in the PR (①, ②b, ②c, the #404 test leg) is verified and sound. |
…3194 CI) Two defects surfaced by the storage-ext / sampled-verification CI legs: 1. dropResidentMetadata crashed on hand-built sessions with no meta (TypeError reading 'protocol') — guard with optional chaining, the lazy loader degrades to the id-only lookup. 2. After ②a's foldResidentTail folds an idle session's tail, subsequent saves still presented the folded re-render as the ⑤ rawTail override. The re-render reorders fold summaries (#2755: the summary yields to the leading user message on first re-render), but the equal-length watermark delta trusted the claimed rawness and skipped the tail-pointer rebuild — the unified table kept the pre-fold ordering while the record moved on, and the sampled digest correctly flagged drift on every 21st save. The override now requires lastMessagesFolded !== true: folded saves present the envelope render (no override), which planIngestDelta already routes to the full ingest, rebuilding tailSeqs in the render's order. Raw rows interned by earlier raw saves stay put (append-only). storage-unified oracle updated: parity compares against the override input when a live raw tail exists, else against the written record. Tested: storage-ext 5/5, storage-save-path 3/3, storage-unified 13/13, memory families + persist-tail + corpus + issue404 42/42.
|
重新review 8问 |
(ai: vllm-qwen/qwen3.8-27b) 重新 review 完成,基于当前 head 75c609a(含你的 ②a 修复 98206bb + 我落的 2 行缩进对齐 style commit)。本地定向验证全绿:storage-save-path / storage-unified(oracle 已按新契约更新)/ storage-ext / storage-corpus / storage-ingest-watermark / memory-tail-folding / memory-blockcontent-lazy / memory-metadata-lazy / memory-diagnostics / persist-tail / issue404 / bounded-storage / knobs-config-precedence / plugin-fork = 135 pass / 0 fail / 1 skip,tsc 干净。CI 在跑(写作时 21 queued / 3 in progress),绿了再补确认。 八问:
判定:代码面已验证可合(head 75c609a,定向 135/135 + tsc 干净);剩余动作只有 CI 全局绿(test shards 在跑,flake 类 lane 若偶发红按已知类 rerun 即可)。合并照例由人来。 |
(ai: vllm-qwen/qwen3.8-27b) CI 确认(head 75c609a,全部 check-runs 完结):41 success / 1 failure。 唯一红:
处置建议:rerun 该 windows lane(或整组 test shards)即可;若再红且仍停在同一断言,那时才值得当作真问题立项。 其余 41 项全绿,含全部 storage/memory 相关 test shards(②a 修复后 storage-save-path 已转绿)、static-gates、各 guard、hermetic registry e2e、real-client lanes。 最终判定:可合。 代码面(本地定向 135/135 + tsc 干净 + 我独立走完的回归审计,见上一条八问)与 CI 均已过;唯一动作是 windows 时序 lane 的 rerun。合并照例由你来。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.442-master.fc0f6c1 # this exact build
npm install -g billion-context@master # always the newest merged build
|
What
sessions.warmMaxdefault 8 → 0 (#3050 R3 step ②-0). Lanes no longer hydrate the eight most-recently-saved sessions before listening; every session loads on first touch (unified-first lookup underfull, envelope read otherwise).Why
Measured on a production data copy with
GET /__bili/memory(#3051):-151 MB per lane at idle boot — and machines that run many lanes (15+ bili processes here) pay it per process. The warm set only bought faster first-touch for a guess about which sessions come back; an un-warmed session pays one on-demand load (milliseconds) instead.
bounded-storage.test.tsalready pins the lazy-reload path (boot({maxSessions:0})→ transparentloadSync).Surface
src/knobs.tssessionWarmMax()default8→0(knob +BILI_SESSION_WARM_MAXunchanged for opting back in)tests/knobs-config-precedence.test.tspins the new default in all three tiersTests
Part of #3050 (R3 memory plane). Next steps on that issue: lastMessages turn-end tabling (②a), blockContents lazy load (②b).
prepared by an agent under the local git identity (ranxianglei), human merge required