Repository navigation
perf(memory): narrow workspace file worker imports - #181891
Merged
steipete merged 2 commits intoOct 23, 2026
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
steipete
marked this pull request as ready for review
October 23, 2026 20:08
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
force-pushed
the
steipete/perf-micro-worker-heap-retention-20260919
branch
from
October 23, 2026 20:19
bd2e973 to
e43b26b
Compare
steipete
deleted the
steipete/perf-micro-worker-heap-retention-20260919
branch
October 23, 2026 20:44
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 24, 2026
* perf(memory): narrow workspace file worker imports * test(memory): follow focused watcher logger import
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
Workspace memory file workers eagerly load the memory database, indexing, and embedding SDK surfaces while serving filesystem watches. Those module graphs remain reachable for the isolate lifetime, even after its watches close.
User Impact
The worker uses the same filesystem and watcher implementations through narrower imports. Watch selection, file content, notifications, error handling, and shutdown behavior are unchanged. In the compiled-worker workload below, post-GC retained heap falls by 61.66 MB per isolate (77.3%).
Why This Change Was Made
Route filesystem operations and path selection through the existing private-local filesystem facade, and logger creation through the diagnostics facade. No new functions, state, cache, configuration, dependency, or SDK subpath. Production LOC: +18/-7 (net +11), entirely import/export declarations; explicit exports preserve the existing SDK ownership boundary while avoiding unrelated runtime owners.
Evidence
Two swapped pairs reduce retained worker heap by 77.3%, GC time by 21.5%, and promotion by 10.7%, with no regression gate triggered. Focused tests and current-head type/lint/changed-test CI pass. Full measurement details and remaining validation limits follow.
Paired measurements and retained-heap analysis
Two concurrent, CPU-swapped pairs on Linux/Node 26.12.1 under one exclusive measurement slot and the shared production-load guard. Each side used 16 interleaved logical CPUs on separate physical cores, with memory/CPU/IO limits. No guard interruption. Both artifacts came from base
4d13198000c5f47561581e28b1d25e676b8334a4, with only this production patch applied to the candidate. Later rebases retained that patch; CI tests current head.The actual compiled
workspace-memory.worker.jsserved 12 synthetic workspace roots with 24 memory files each. Each side completed 1,000 waves / 12,000 file-change notifications, with exactly 12,000 change events. Forced collections and snapshots ran outside the timed interval. Change latency measures write-start to first notification, not indexing completion; observations within each wave are correlated. This is a worker-specific filesystem workload, not a full Gateway/session-database replay.Values are baseline → candidate. Paired mean is the arithmetic mean of the two relative deltas; MB means decimal MB.
GC tail context, with collection counts beside each row:
Decision under v5.3/v5.2: no regression gate triggered. Minor pause-tail mean deltas are below 1 ms and are context. Major tails lack 200/1,000 samples. Pair 2's maximum pause rises but remains below
max(50 ms, 2 × 69.112 ms) = 138.225 ms; it is reported rather than discarded. Parent event-loop p99 is inconclusive under the opposing-sign rule: +0.008 ms (+0.62%) and −0.004 ms (−0.20%), both below regression thresholds. GC time and promotion improve in both pairs, and worker event-loop p99 is effectively neutral.Separate post-GC sandbox snapshots identify the retained owner: loaded file-script nodes fall from 2,453 to 481; strings from 33.86 to 8.38 MB, code from 17.27 to 6.71 MB. Baseline strong root paths include
ModuleLoader → LoadCache → ModuleJob → ModuleWrapand global registrations retaining unrelated runtime code. Storage/embedding facade, Kysely, and bundled channel-configuration scripts appear in the baseline and are absent from the candidate. Snapshot node self-size totals include native/snapshot accounting and are not substituted for the worker heap measurements above.Proof and Limits
file-watcher.filter,memory-files-worker,memory-watch.worker), 62.14 seconds including compilation/import setup.sourcePerformancebuild passed. A complete distributable build is not claimed by this benchmark.e43b26be2feaff2992702aebca7aa572fe64ce53: exact-head run. No Testbox/Crabbox lease was allocated.