Repository navigation
Memory diagnostics: GET /__bili/memory resident-pool breakdown (#3050 R3 step 1) - #3051
Conversation
- session.ts: extract deepSizeOf; add residentBreakdown(session) and memoryReport() — per-session resident bytes split across lastMessages, pluginSnapshot, blockContents, contentStore, state, other (columns sum to the revision-cached sessionWeight total). - server/admin.ts: GET /__bili/memory (loopback-gated like all /__bili) returns process memoryUsage + VmHWM peak plus the pool report, top 25 sessions by bytes. - tests/memory-diagnostics.test.ts: field attribution, monotone scaling, pool sorting/budget context. - unused-export gate: reasoned waiver for the three test-consumed symbols. This is the measurement half of the R3 memory plane: the numbers decide which residents (blockContents originals, CCR store, lastMessages, pluginSnapshot) become lazy DB-backed views.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3528-pr.3051.cb76f09This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3051.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) PR #3051 review 结论:未发现回归,可合并——待最后 4 条全量 CI lane 转绿(当前 26/30 全绿:static-gates ×4 平台、kernel-guard、pi-subagents-guard、version-guard、config-surface-guard、lane-guard、docs-sync/docs-coverage、lock-sync、test-import-graph、unused-exports、hermetic registry e2e ×2、codex/pi/opencode/V2 真实客户端 lane、build-artifact、theorem 全部通过;仅剩 ubuntu/windows × node22/24 的 按八问:
三个小问题(均不阻塞,由作者决定是否合前顺手改):
为什么我没直接推这几个小修:#3050 里你明确说了先别在这里动手实现、两边写码前先划界,这个分支是你本地 agent 的活动工作面——所以我只做审查与验证,三条小修留给作者定夺。 验证证据:本地定向测试 3/3 通过、 判定:可合并,等最后 4 条全量 lane 绿即可,无阻塞项。 |
(ai: vllm-qwen/qwen3.8-27b) CI 已全绿(30/30),最终判定维持:可合并。 上一条回复后唯一红的 lane( 失败内容(非本 PR 引入): 判定为环境性 flake 的证据链:
家族归属:这是 #2799 族的第三次复发——#2799(storage-engine-proofs 清理 temp 遇 EBUSY/EPERM,windows leg 随机红)→ #2808 修自持句柄 → #2908 复发(c=4 并发下 EBUSY 超出旧重试窗口)→ #2914 把重试预算扩到 ~9.4s。这次是 Windows AV/indexer 外部锁超过了 #2914 扩后的预算才漏网。是否继续扩预算或另立跟踪,由你定夺(按来源链规则我在此评论记录,不擅自立项)。 结论:无阻塞项,可合并;win-node24 那条 lane 的重跑结果可作为本次 CI 的最终状态。 |
…op signal (#3090 follow-up) #3090 made the post-compress tail honor the kernel's shouldInject verdict: at the drive's fold turn the leftover sits below the kernel's threshold, so the receipt now ends with the stop signal instead of advertising a sub-threshold range. Wire-visible by design (the receipt text is resent history): turn-9 body digests shrink accordingly (-417 B on chat) and the persisted-view section digests (stats/ metadata/stateDigest) shift with the tail content they cover. Landmarks (foldAt/editedAt/summaryFrom) and all other turns are byte-identical. Restores the master test matrix (#3090's CI legs were red on the stale goldens).
(ai: vllm-qwen/qwen3.8-27b) 冲突已解除:PR #3051 现为 mergeable=True(状态 behind,非阻塞),等待人工合并。本轮我没有推送任何 commit。 按八问体例:
结论:无需进一步操作,状态会自动保持干净(若 master 再前进且再次触碰 CHANGELOG 同段,会再触发一次同类同步);可合并。 |
…review fix) memoryReport and residentBreakdown have cross-file references (admin.ts imports memoryReport; tests import both), so the gate does not flag them. Only the structurally-consumed interfaces need waiving.
…iew fix) Double-counted shared substructure makes the field legs exceed total, in which case other clamps at 0 and the columns no longer sum to total. State the invariant accurately instead of claiming an unconditional sum.
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.399-master.1fcfe52 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Step ① of the R3 memory plane (#3050): measure before lazy-loading.
What
src/session.ts— extractdeepSizeOf(the resident-accounting walker) and add:residentBreakdown(session)— per-field resident bytes: lastMessages / pluginSnapshot / blockContents / contentStore / state / other, columns summing to the revision-cachedsessionWeighttotal;memoryReport()— whole-pool snapshot: session count, MAX_SESSIONS, residentBytes vs MAX_RESIDENT_BYTES budget, per-field sums, sessions sorted heaviest-first.src/server/admin.ts—GET /__bili/memory(loopback-gated like all/__bili): processmemoryUsage()+VmHWMpeak (null on non-linux) + the pool report, top 25 sessions.tests/memory-diagnostics.test.ts— field attribution (a 200K-char lastMessages must land in the lastMessages column), monotone scaling, pool ordering/budget context.Why this shape
The R3 lazy-load order (blockContents → CCR → lastMessages → pluginSnapshot, gated on
storage.unified=full) should be decided by measured bytes, not guesses. This endpoint is the measurement: hit it on a fat dogfood session and the breakdown says which resident is worth making DB-backed first. Read-only, zero hot-path cost (per-field walks happen only on endpoint hit; the pool total reuses the existing revision-cached weights).Fixes the measurement half of #3050 (the lazy-load PRs follow separately, in the order the numbers dictate).
Tests
node --import tsx --test tests/memory-diagnostics.test.ts— 3/3prepared by an agent under the local git identity (ranxianglei), human merge required