Repository navigation
perf(sessions): reduce maintenance worker prewarm memory - #171697
Merged
steipete merged 1 commit intoOct 14, 2026
Merged
Conversation
Keep foreground history prewarm eager while maintenance admits its SQLite reader without retaining unused chat presentation modules. Preserve existing reader admission, worker lifetime, and cancellation behavior.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
steipete
deleted the
steipete/perf-micro-worker-heap-retention-20260919
branch
October 14, 2026 04:24
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 15, 2026
…71697) Keep foreground history prewarm eager while maintenance admits its SQLite reader without retaining unused chat presentation modules. Preserve existing reader admission, worker lifetime, and cancellation behavior.
This was referenced Oct 21, 2026
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.
What Problem This Solves
Gateway startup prewarms its maintenance reader with the same chat presentation imports as its foreground history reader, retaining a second module graph in an isolate that does not serve chat pages.
User Impact
Less worker memory after startup while preserving foreground history prewarming and maintenance database admission. No schema, configuration, worker-count, or retention-policy changes.
Why This Change Was Made
The private prewarm request now identifies foreground history work. Maintenance still opens and retains the same admitted SQLite reader, but leaves chat presentation modules lazy. Existing worker lifetime, cancellation, rotation, and database cleanup remain the owners of those resources.
The +9 production LOC increase carries this distinction through the existing typed request, rather than creating another pool or prewarm implementation. Full foreground warmup is an existing startup-latency contract.
Evidence
Matched synthetic fixture: 5,000 sessions, 6,000 retained runs, 200 approvals, 100 disabled cron jobs, 12 real project worktrees, 1,500 MiB logical transcript text, 4,641,595,392-byte agent database. Six fresh maintenance workers per version on the same read-only fixture; Node 26.8.2, real owned task pool and transcript worker entry, source execution via the repository loader. Isolated benchmark sandbox, CPU 64–127, 64 GiB cap, nice 10 / idle I/O. No production data, service changes, or benchmark traffic to a live Gateway.
Sampling interval: 32 KiB, including objects collected by both major and minor GC. Retained heap and process RSS are sampled after explicit GC; GC time includes that final collection. RSS covers the whole harness process, not a deployed Gateway. Source execution includes loader allocations, so exact production-bundle savings remain unmeasured.
This removes about 15 MiB of retained live heap (22.5%) and 16.25 MiB of worker heap capacity after real maintenance reads, with 27.5% fewer allocated bytes across prewarm plus the first 20 reads. Some loading shifts into the first maintenance read; the combined path still allocates less. A subsequent 20-read batch allocated a median 783,394 → 749,226 bytes/read (three runs each; neutral within sampling noise). Its median GC was 126 → 104 ms per batch. Combined prewarm/read GC ranges overlap (297–420 → 209–333 ms); no strong steady-state GC improvement is claimed.
Foreground eager-prewarm control retains 66.54 → 66.56 MiB after reads, effectively unchanged. Only the prewarmed maintenance isolate changes; these results must not be multiplied by every transcript worker. The rest of the worker fleet remains future investigation.
274f05d9253e44097b8bad052db07867b76d08eb(types, lint, selected test shards, boundaries, build, UI checks).pnpm test src/config/sessions/session-history-read.imports.test.ts src/config/sessions/session-transcript-worker-lanes.test.ts src/config/sessions/session-transcript.worker.schema-freshness.test.ts --maxWorkers=1: 3 files, 35 tests passed.Local validation follows the perf-lane policy: changed-file oxfmt/oxlint and three focused test files with one worker; broad gates belong to PR CI. No Testbox/Crabbox lease.
Read-only production inventory that selected this owner
One observation showed 41 tracked workers across 20 kinds: 1,982.6 MiB live worker heap, 2,378.5 MiB worker heap capacity, and 5,408.3 MiB process RSS. This is a census, not before/after deployment evidence.
session-transcript.worker.jssqlite-store.worker.jsgit-operation.worker.jscode-mode-node.worker.jsprepared-model-catalog.worker.jsopenclaw-state-read.worker.jsmemory-search.worker.jssession-accessor.sqlite-archive.worker.jsdiscovery.worker.jsfile-tool-planning.worker.jsprovider-prompt-state.worker.jsproxy.worker.jsattachment-processor.worker.jsidentity-file.worker.jsfs-safe-copy.worker.jsimage-processor.worker.jsidentity-avatar-file.worker.jsworker-native-lifecycle.worker.jsopenclaw-state-lease-heartbeat.worker.jsgateway-state-owner-heartbeat.worker.js