Repository navigation
perf(infra): collect and retire idle worker heaps - #154408
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. Reviewed September 21, 2026, 3:57 AM ET / 07:57 UTC (Revision 8). ClawSweeper reviewWhat this changesThe PR collects unused worker heap after completed operations, retires idle workers under critical memory pressure, and requests 512 MiB database-worker heap limits. Merge readiness⛔ Needs changes before merge - 2 items remain The work remains useful and is absent from current main. One previously reported P3 documentation error remains; no additional blocking runtime defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw runs database and transcript operations in reusable workers. Completion hooks reclaim garbage, while diagnostic memory samples ask existing lifecycle owners to retire idle workers without interrupting active work. flowchart TD
A[Database and transcript requests] --> B[Reusable workers]
B --> C[Operation completes]
C --> D[Deferred idle garbage collection]
E[Enabled diagnostics heartbeat] --> F[Critical memory pressure]
F --> G[Existing cleanup owners]
G --> H[Retire idle workers]
C --> A
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +186, Tests +329, Docs +10, Other +4. Total +529 across 28 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep reclamation within existing worker lifecycle owners and clearly distinguish independent idle GC from diagnostics-driven pressure retirement. Do we have a high-confidence way to reproduce the issue? Yes for the remaining documentation defect: disabling diagnostics stops the only production heartbeat that publishes memory pressure. This is source-proven; no runtime reproduction was executed during review. Is this the best way to solve the issue? Yes, the runtime approach reuses existing cleanup ownership and has focused native-worker evidence; the remaining correction should change documentation rather than introduce another pressure sampler. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 11263ceb18ca. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
b5b69fd to
34935a6
Compare
|
Catalog-worker retention coordination update: the final fix removes two independent retaining paths: the inline generation-release closure chained every predecessor, and the plugin cache retained successfully disposed instances. The cached registry loader is preserved; terminal successful physical disposal now releases each instance from its birth inventories. Active, adopted, draining, and failed instances retain custody. The real-worker synthetic benchmark now passes 1,000 preparations across four plugin-config revisions with one retained callback after settlement, versus 1,000 before. Post-GC worker heap is 87.3 MB versus 178.4 MB. All 235 focused worker/plugin tests pass, including one shared runtime-source graph across agent publications. Both catalog-worker host paths request 512 MiB old-generation limits. Generic idle GC, pressure retirement, and task-pool lifecycle files remain untouched. The process-wide heap-flag override and large-working-set limitations will remain documented. Final changed checks and build are running before PR publication. Published as #154568. The exact-head CI workflow passed, as did all selected Testbox checks and the full build; all task-owned Testboxes are stopped. |
34935a6 to
2d7254b
Compare
2d7254b to
f627ead
Compare
f627ead to
65635a7
Compare
65635a7 to
ea738de
Compare
|
Merged via squash.
|
…question-layout-restart-recovery-20260921 * 'main' of https://github.com/openclaw/openclaw: (110 commits) perf(infra): collect and retire idle worker heaps (openclaw#154408) perf(sessions): hand shared history to the final reader (openclaw#154552) fix: clarify Codex onboarding migration scope (openclaw#151383) fix: recover conflicted PRs after accepted auto-merge perf(update): defer Gateway maintenance during candidate validation (openclaw#154548) perf(test): advance llama.cpp reload deadlines virtually (openclaw#154536) refactor(skills): prepare pinned library resources off-thread (openclaw#148560) fix(tooling): preserve Node compiler policy in script subprocesses (openclaw#154509) ci: select supported Node and cover packaged Node 26 (openclaw#154298) fix(release): preserve Telegram rerun evidence (openclaw#154561) docs: follow pending PR merges through completion fix(gateway): avoid stuck shutdowns after lifecycle errors (openclaw#145241) fix(ui): let focused dashboard widgets fill the task area (openclaw#154440) feat(release): add non-Latest extended-stable releases (openclaw#154515) fix(release): project 7.35 package Telegram config (openclaw#154546) refactor(config): derive host contracts from schemas (openclaw#153936) fix(ui): remove finished subagents from inline activity (openclaw#154469) refactor(config): derive core channel contracts from schemas (openclaw#153935) refactor(config): derive boundary contracts from schemas (openclaw#153937) fix(ui): keep thread activity current across cached updates (openclaw#154540) ...
What Problem This Solves
Persistent database workers can retain garbage from completed large operations during their 30-minute reuse window. This raises process memory while the workers are idle.
Related: #153601, #154295.
User Impact
Idle workers release transient heap while remaining reusable. Critical memory pressure retires idle workers through their existing cleanup owners. Busy tasks, accepted replies, resource cleanup, and database write settlement keep their existing ownership guarantees.
SQLite broker, shared-state reader, history/usage, transcript read/export/reconciliation, archive/cold-storage/reclamation, and canonical-validation workers request 512 MiB old-generation limits. An explicit process-wide
--max-old-space-sizeoverrides the effective V8 limit even thoughworker.resourceLimitsstill reports 512. Native and external allocations are outside that limit. There are no configuration, schema, stored-data retention, or update-procedure changes.Why This Change Was Made
Completion hooks defer major collection until the operation releases its payload stack, and collect only after used heap grows by 32 MiB. A successor cancels scheduled collection. One worker-owned inspector session performs collection without changing process-global V8 flags; it remains attached until worker teardown. Generation and idle state handle operations that begin or finish while collection is pending. Buffered write-admission replies are filtered before cancellation, so they cannot cancel collection for an operation that already finished.
Critical-pressure notifications reach cleanup owners independently of diagnostic event recording and log throttling. Custom history/reclamation/database custody stays with its existing retirement owner. The generic pool retires only idle slots whose retirement it already owns.
The change adds 186 net production lines. Existing state-operation adapters moved unchanged to a sibling module to preserve line caps. The materialized PR-wrapper inventory includes both new runtime modules, and the V8-specific regression stays on Node through the existing CI runtime partition.
Evidence
Current head:
ea738de9893c98dbc244c3d7ca0e0505e15fb1f8, a single commit with the original subject. The final rebase preserves byte-identical contents for all 28 files in this PR. Fresh full-candidate and focused follow-up Codex reviews found no actionable P0-P2 findings. Exact-head hosted CI passed, including the requiredopenclaw/ci-gate.The native regression exercises the real task-pool server and preserves the worker thread and V8 compile-cache identity:
On Testbox run 35565808025, the memory regression passed through the actual CI entry point with the Bun-compatible policy selecting Node. The following runtime-partition, eager-import, wrapper-source, and unchanged native compile-cache suites passed 125 tests in 33.91 s. Core typechecking and targeted core/script/test lint passed. The memory case took 497 ms, with 14.71 s cold file wall including worker compilation. The runtime-partition file's standalone regression-cost measurement was 3.82 s file / 5.12 s wrapper wall.
On Testbox run 35567975516, the admission-reply regression failed before the ordering repair, then passed with native reclamation and heap siblings: 4 tests in 19.74 s. The port-loop regression measured 4 ms test / 363 ms file / 1.17 s wrapper wall. It uses a real MessageChannel with synthetic database boundaries, no process boots, polling, or sleeps.
CI exposed a test cleanup typing error and a type-graph root budget overflow. Run 35569653790 proved both on the candidate while pure main
beaf348df2306d9199bd2419e6f003c4892cd890passed. The iterator cleanup now respects its optional return method. The earlier config/CLI typecheck excluded sessions; the correct graph was then checked. Run 35570995203 passed all 24 graph-ownership tests in 17.31 s, both affected canonical type graphs, and the docs audit (14,258 links, zero broken links). Main independently landed the same graph rebalance inf6f59497b50(#154497); the duplicate configuration/docs changes were removed from this PR during rebase.CI repair history and limitations
openclaw/ci-gate. Main repairf76d38a4ac5eis incorporated. Planning passed on pure main and the candidate, producing 68 compact shards.--expose-gcleak, missing wrapper inventory entries, and the V8 test being routed to Bun. Pure-main comparisons and failing regressions confirmed these defects before repair. Existing exact compile-cache-directory assertions remain intact.2d7254b8fe57038c68483848b3f64f2fde86674ccompleted hosted CI green, ignoring superseded rollup entries. Subsequent heads add the admission-reply regression and its test-only type cleanup.Maintainer decision: Retain the requested 512 MiB limits alongside idle GC and critical-pressure retirement. The caps affect active-operation capacity as well as idle heaps. Large live working sets and a post-deployment RSS curve remain unvalidated; the synthetic garbage proof does not establish those properties. No live Gateway or stored user data was modified.