Repository navigation
perf(sessions): speed up cold session discovery - #198775
Merged
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. |
Contributor
Codex Review Summary: ✅ CompletedThis 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-sessions-search-cold-walk-20261114
branch
November 14, 2026 09:08
steipete
added a commit
that referenced
this pull request
Nov 14, 2026
Main #198775 groups exact archive reads by store identity. The pinned-page fixture held archive-pin before main while waiting for main to progress, causing a reproducible 120-second timeout on the CI main parent. Sort the held fixture store after main without changing assertions, timeouts, or production behavior. All 22 cases pass on both the PR branch and CI parent with this fixture correction; Codex review is clean.
This was referenced Nov 14, 2026
steipete
added a commit
that referenced
this pull request
Nov 14, 2026
Main #198775 groups exact archive reads by store identity. The pinned-page fixture held archive-pin before main while waiting for main to progress, causing a reproducible 120-second timeout on the CI main parent. Sort the held fixture store after main without changing assertions, timeouts, or production behavior. All 22 cases pass on both the PR branch and CI parent with this fixture correction; Codex review is clean.
steipete
added a commit
that referenced
this pull request
Nov 14, 2026
… worker (#198786) * fix(sessions): bound worker memory during large history cuts * test(sessions): bind benchmark observers to their native owners * test(sessions): preserve held archive read ordering Main #198775 groups exact archive reads by store identity. The pinned-page fixture held archive-pin before main while waiting for main to progress, causing a reproducible 120-second timeout on the CI main parent. Sort the held fixture store after main without changing assertions, timeouts, or production behavior. All 22 cases pass on both the PR branch and CI parent with this fixture correction; Codex review is clean.
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 15, 2026
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 15, 2026
Main openclaw#198775 groups exact archive reads by store identity. The pinned-page fixture held archive-pin before main while waiting for main to progress, causing a reproducible 120-second timeout on the CI main parent. Sort the held fixture store after main without changing assertions, timeouts, or production behavior. All 22 cases pass on both the PR branch and CI parent with this fixture correction; Codex review is clean.
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 15, 2026
… worker (openclaw#198786) * fix(sessions): bound worker memory during large history cuts * test(sessions): bind benchmark observers to their native owners * test(sessions): preserve held archive read ordering Main openclaw#198775 groups exact archive reads by store identity. The pinned-page fixture held archive-pin before main while waiting for main to progress, causing a reproducible 120-second timeout on the CI main parent. Sort the held fixture store after main without changing assertions, timeouts, or production behavior. All 22 cases pass on both the PR branch and CI parent with this fixture correction; Codex review is clean.
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
Large mixed-agent session inventories make
sessions_searchand archived list pages spend excessive time preparing cold rows, even after selection reuse in #198740.User Impact
Cold archive traversal uses fewer worker admissions and less main-thread work. A synthetic 15,800-session discovery reduced CPU by 59.9% and sampled allocation by 39.8%, with identical dashboard responses and search candidate keys. Search results, limits, visibility checks, and archive retention are unchanged.
Why This Change Was Made
List pages interleave agents by recency, but the exact-read queue batches only adjacent identities from one physical store. A single preparation request now groups its agent/store-prefixed identities before appending to that queue. Earlier requests retain FIFO order; concurrency, the 64-key batch cap, 12ms materialization slices, capacity checks, and per-store failure isolation remain intact.
This is one production statement plus two explanatory comment lines (runtime LOC +3). It removes repeated worker admission/shared-fact preparation and lets the existing per-batch runtime resolution serve multiple rows. It adds no cache, protocol, schema, or retention change.
Evidence
Synthetic workload: 15,800 rows, 12,800 archived, eight agents, 30 held active runs; real
sessions_searchdiscovery through the embedded projection owner, excluding transcript FTS. Every measured sweep still materializes all 12,800 archived rows; selection caches are warm. Timing order is base/candidate/candidate/base, five sweeps per arm (10/side); allocation uses separate five-sweep processes. Baseline is08ae8c62b83ede02db3a8d2bc3ce36206008d253.A/A context: identical-base CPU was 6.005/4.553 s and wall 11.721/6.030 s. Both paired CPU reductions hold (62.5%, 56.4%); paired wall reductions are 74.5% and 61.9%. End-of-arm one-minute host loads are recorded below. No tail percentile claim is made from five samples. First process-local discovery also pays cold selection preparation: its wall results had mixed pair signs and remain inconclusive; the table does not claim a cold-start improvement.
The cold-walk regression fails on main with 128 worker row-fact reads instead of eight for 128 interleaved archived rows over four pages; it passes with the fix and verifies coverage, displayed fields, and response order. Separate verification passes compare every dashboard page and the complete candidate set: 79 pages, 15,800 rows, 15,801 keys, identical canonical hashes.
Allocation attribution from a one-sweep profile:
readSessionRowInputsfalls from 402 to 168 MB andprepareSessionRowSharedFactsfrom 330 to 78 MB (inclusive totals, not additive). Row materialization remains ~401–405 MB, archive trimming ~94–96 MB, and list-row binding ~2 MB. The archive cache still drops to 100 rows after page pins release, so subsequent walks remain cold; enlarging retention is unnecessary for this improvement.Dispatch remains compatible with hosted in-process, standalone embedded, and remote Gateway callers (
openclaw-tools.ts→in-process-gateway.ts). There is no local-only enumeration shortcut.Reproduce with the committed
scripts/perf/session-prepared-list-measure.ts:--list-shape all --sessions 15800 --agents 8 --archived-sessions 12800 --active-runs 30 --updates-per-list 0 --search-discovery --plain-result --iterations 5 --warmup 1, with a synthetic--state-dir,--source-ref <base-or-candidate>, and separate--mode timing,allocation, andverifyprocesses. Run vianode --expose-gc --import ./scripts/tsx.mjs; use--reuse-fixtureonly after the first serial run.Codex autoreview: scoped-clean through P2 on the complete local diff against the baseline; no accepted/actionable findings. No full-Gateway stress, transport/model-turn, or production latency claim; this follows the lane's focused-proof exception. No Testbox or production load was used.
Local validation passed: 14 archive tests (including the base-red regression), 66 focused prepared-read/worker-read/visibility/search tests, all four
pnpm tsgo:test:rootshards, the Gateway-root test typecheck, and changed-file oxlint/oxfmt. Visibility coverage includes spawned-only sandbox access, A2A policy, requester-owned global sentinel, archived rows, and incognito exclusion. The full CI run passed on exact head3741b640fe6f20544333223228163422d46077cf; both requiredopenclaw/ci-gatechecks are successful.