Repository navigation
fix(memory): avoid session rendering during index scans - #181594
Draft
vincentkoc wants to merge 5 commits into
Draft
vincentkoc wants to merge 5 commits into
vincentkoc wants to merge 5 commits into
Conversation
Contributor
|
🦞👀 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. |
vincentkoc
marked this pull request as ready for review
October 23, 2026 11:44
Contributor
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
vincentkoc
marked this pull request as draft
October 23, 2026 12:20
This was referenced Oct 25, 2026
This branch has not been deployed
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
Session-index statistics load the broad session inventory and rendering runtime into a retained indexing worker, even though the scan only needs grouped transcript statistics.
User Impact
The candidate removes those unused imports while preserving results, incognito checks, cancellation authority, and worker lifecycle. The completed comparison observed lower median sampled Gateway RSS, but failed the frozen CPU/latency acceptance gate. This PR is held; these benchmark observations do not establish that the code change caused every observed slowdown.
Why This Change Was Made
The memory host SDK owns a narrow guarded statistics reader. The indexing worker loads it lazily; the existing session facade re-exports the same operation for current callers. The SQLite query kernel, configuration, scheduling, and public SDK contract are unchanged.
Evidence
Performance acceptance — frozen before scored runs
Baseline package:
9827935108e185e3f290d622dcccec07ff3814ae. Candidate package:5826994e5e33ec25f48c5c3fff77c5656bb9684e. Common harness:387e559d45cc95bde5394481a11bbcaddfe0bd87. Later changes relative to the candidate package concern benchmark evidence and a test inventory only; runtime source and dependencies are identical.Both packages run on macOS arm64 / Node 24.22.1 with the same committed harness and byte-identical compiled worker sampler. This is the trusted local fallback after the requested Testbox allocation remained queued and was stopped before executing its payload. Linux correctness/build evidence above remains separate.
Seed 32 SQLite-backed sessions with 20 messages of 1,024 characters each. Run the existing owner-routed memory search after seeding; require owner RPC observations, successful indexing-worker tasks, and retained native worker identity. Pool telemetry does not identify individual task kinds: separate, unscored activation profiles establish execution of transcript statistics.
Then run two concurrent sessions, one warmup turn and two measured turns each, 20 fixed probe rounds, two history clients with burst one, one subscriber, and control-plane probes. Compare one and five synthetic plugins with five serial, interleaved A/B pairs per plugin count. Alternate pair order. Keep cold readiness and memory-scan timing separate from warm load. Disable CPU and heap profiling for scored runs.
Require successful behavior and clean teardown, measurable process RSS reduction with attributable removal of unused worker imports, and user-facing CPU/latency/count metrics that hold or improve. Report median, p95, spread, host load, all failed attempts, and work counts. Any worsening requires explicit maintainer acceptance; a 20% regression in any cell stops landing. Worker heaps are attribution only, not additive RSS.
The harness records embedding input ordinals, counts, character lengths, and exact ordered SHA-256 digests before fixture cleanup. Clipped or unparseable input evidence stays unknown and cannot establish matched work. Informational memory-index rebuild notices are preserved; stale/unavailable results fail qualification.
Full-corpus activation passed on both installed packages: four verified turns each, 33 successful indexing tasks, and the guarded reader plus SQL kernel observed in each indexing-worker CPU profile. All 109 ordered embedding request payloads matched exactly (651 inputs, 816,449 characters); raw arrival ordinals remain recorded separately. Both fixtures shut down cleanly. These profiled runs are unscored.
Completed performance qualification — HOLD / DO NOT LAND
All 20 scored attempts completed with exit 0: five serial, alternating-order A/B pairs for each of one and five plugins, with no exclusions. The observed median RSS reduction is modest: one plugin, 2,904.078 → 2,840.281 MiB (-2.20%); five plugins, 3,096.172 → 3,065.719 MiB (-0.98%). The indexing worker's stable post-load heap fell approximately 35.4%, with the same sampled worker counts (30 / 34). Worker heap is attribution, not additive process RSS.
The frozen acceptance gate FAILED. Stop conditions include:
The history p95 run ranges were 11.435–19.133 → 12.031–21.447 ms. The cron.list run-p50 ranges were 1.804–2.074 → 2.010–3.039 ms; cron.status, 1.819–2.073 → 2.017–3.049 ms. Their paired median p50 changes were +26.46% and +24.06%. Pooled request percentiles below do not erase these run-level regressions.
Additional worsening of at least 20% appears in readiness-window utilization/CPU-core ratios below, and in one-plugin pre-scan main-heap p95 (+20.39%), pre-scan array-buffer p95 (+35.11%), and post-load main array-buffer median (5.983 → 7.483 MiB, +25.06%). Array buffers are not RSS. Candidate five-plugin pair 05 also recorded five degraded readiness samples, versus zero elsewhere; all remained HTTP 200 with
ok=true.This is an observed benchmark acceptance failure, not proof of a product regression or a causal explanation for each slowdown. Host noise, lower medians elsewhere, and successful exits do not waive the predeclared stop condition. The candidate remains draft/held. No merge or deployment.
Run-level memory, CPU, and phase results
Each variant/cohort has five independent runs. Entries show median [minimum, maximum]; with five runs, nearest-rank p95 equals the maximum. Percentage changes compare the marginal medians or p95 values, not paired deltas. CPU values are milliseconds. Harness setup includes preparation; it is not isolated listener-startup latency.
Paired RSS-after-load changes differ from ratios of marginal medians:
Retained residency anomalies: one-plugin candidate pair 05 ended at 2,132.234 MiB versus baseline 2,917.547 MiB, with 30 workers; five-plugin candidate pair 02 ended at 2,731.359 MiB versus baseline 3,069.953 MiB, with 34 workers. Neither sample was excluded or assigned a cause. Index-worker heap samples are complete and stable; some aggregate worker snapshots have pending workspace-memory-worker samples, so aggregate heap must not be summed as process RSS.
Request latency and readiness-window telemetry
Pooled request samples are descriptive, not independent run replicates. Per variant/cohort: history has 200 samples; readiness, sessionsList, Control UI, load subscriptions, and each cron method have 100; initial subscriptions and fresh connections have five.
Readiness-window utilization and CPU-core ratio are separate from integrated load CPU:
Zero histogram observations are retained literally and do not establish zero latency. The five degraded readiness samples in candidate five-plugin pair 05 reported delay p99/max 45.7 ms, utilization 0.195, and CPU-core ratio 1.099.
Work equivalence, behavior, and attribution
All 20 runs used the same corpus and matched the ordered embedding evidence after dropping only the separately recorded global arrival ordinal: 109 requests, 651 inputs, 816,449 characters per run, with no unknown hashes/counts/lengths.
Reproducibility identities:
25a55faab541747521e70a7c8efb3b8941be952b703b8d594f18c757738198d5.34d2e393372aa46b8a27397d7591a1f65360af850547dc355d587b6ddf42e667.f984fafc7704736e5d21e9b3090d24412c04a74bf392c6ff0c219bd1f5c41138.Host conditions and interpretation limits
The host was macOS arm64, Node 24.22.1, 18 available CPUs, 48 GiB RAM. Load averages below are load1 snapshots, shown as median [min, max].
These snapshots do not identify a causative competing process, memory pressure/compression, or thermal state. No sample was removed and no causal explanation is assigned to the outliers or slowdowns.
Separate CI / merge status
At exact head
387e559d45cc95bde5394481a11bbcaddfe0bd87, GitHub reports a merge conflict (mergeable=false,mergeable_state=dirty, no merge SHA), and no current-headci.ymlrun exists. Security Review 39951492021 completed, but its combinedopenclaw/ci-gatestatus is pending, waiting for CI. This is separate from the failed performance gate. No rebase, close/reopen, CI dispatch, or additional review round is requested while this candidate is held.The three older Bun failures (Telegram callback drain, hooks error formatting, subagent completion) remain UNKNOWN in attribution. The corrected mock, SDK documentation, and bridge inventory do not establish that those unrelated failures are inherited or repaired.