Repository navigation
perf(sessions): serve sessions.list from an incrementally maintained order - #163941
Conversation
…order Maintain per-scope ordering from accepted projection metadata while preserving federation, visibility, archive and pagination behavior. Remove the superseded candidate cache and per-request order rebuilds.
|
🦞👀 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 maintainer review before merge. Reviewed October 2, 2026, 11:00 PM ET / October 3, 2026, 03:00 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR maintains session-list ordering as accepted metadata changes, removes the previous candidate cache, and updates search preparation, regression coverage, and protocol documentation. Merge readiness✅ Ready for maintainer review The optimization remains useful on current main, and the previous review’s concrete concerns are addressed. No actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway’s session projection receives committed session metadata and prepares the session roster. List and search requests apply current visibility and activity filters before returning selected session details to clients. flowchart TD
A[Committed session metadata] --> B[Resident session projection]
B --> C[Incrementally maintained orders]
D[List or search request] --> E[Current visibility and activity filters]
C --> E
E --> F[Pagination and selected row preparation]
F --> G[Client response]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +70, Tests +123, Docs +2. Total +195 across 13 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep ordering derived from the existing projection owner while applying current viewer and clock-dependent decisions synchronously for each response. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug report; the recorded same-host production-handler benchmark provides a concrete comparison for the performance problem, without reviewer-side execution. Is this the best way to solve the issue? Yes. Extending the existing projection’s publication lifecycle and removing the superseded candidate cache provides one ordering owner while preserving request-time visibility checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0e17a464f0d3. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Prepare static discovery facts with accepted metadata and reuse maintained ordering for ready search identity reads. Preserve cold-page ordering coverage while removing a comparator counter that did not observe the original module-local sort.
…order (openclaw#163941) * perf(sessions): serve sessions.list from an incrementally maintained order Maintain per-scope ordering from accepted projection metadata while preserving federation, visibility, archive and pagination behavior. Remove the superseded candidate cache and per-request order rebuilds. * perf(sessions): reuse prepared discovery facts for list readers Prepare static discovery facts with accepted metadata and reuse maintained ordering for ready search identity reads. Preserve cold-page ordering coverage while removing a comparator counter that did not observe the original module-local sort.
What Problem This Solves
Repeated
sessions.listcalls rebuild candidate arrays and sorted pages after one session changes or clients alternate filters.User Impact
Lists maintain their order incrementally while preserving current visibility, activity, archive, pinning, owner-first, and pagination behavior. No configuration or storage migration is required.
Why This Change Was Made
The existing revision owner publishes compact accepted metadata after row/index updates and owns listener disposal and board-fact invalidation. The list reader updates the affected physical competitor and winner, retiring orders on topology replacement or disposal. This removes the single-filter candidate cache, option-key serialization, and intermediate visible/candidate arrays for ordinary requests.
Cron/system classification joins the existing selection facts at metadata acquisition, and ready search identity reads reuse maintained order. Transcript search prepares complete selection metadata at its existing awaited boundary. Viewer decisions and time-dependent filters remain per request.
Production delta against main: +70 lines (283 added, 213 removed). Growth preserves concrete federation and lifecycle contracts: deleting a sentinel winner must expose its next physical competitor; ordinary duplicate keys remain read-time errors without failing committed writes; topology/disposal retire derived orders; callback failures cannot interrupt accepted row maintenance. The superseded candidate-cache machinery is deleted, and maintained orders retain metadata rather than materialized row graphs. Raw catalog reads preserve resident order, and direct/child reads retain their existing selection boundary.
This builds on the corrected archive-only projection behavior. It adds no live-row eviction or subscription-pinning hook.
Evidence
Synthetic production-handler rig: 5,000 initial SQLite sessions, ten concurrent clients, mixed sorts/filters, 1,000 calls, 100 inserts, and 100 updates. Timing and sampled allocation use separate processes.
Allocation falls 27.6% from the pre-eviction baseline and 27.6% from same-host corrected main, clearing the 15% threshold. The final same-host pair measured p50 −28.0%, p95 −16.6%, and workload time −16.5%. Historical latency used a different host/Node version and is not an attributable speedup; these are synthetic measurements. All four final selection digests match the historical digest.
Final proof used provider blacksmith-testbox, profile openclaw-check, lease tbx_01m3zrbb5b6c4hhxmekqm1nj7v, Node 24.19.0, comparing base
ff96d47c3506with the complete candidate:OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 CI=1 node scripts/check-changed.mjs --stagedand the four paired rig phases: passed, exit 0, 1,489.701 s combined command time. Gate coverage included production types, all 27 test type graphs, lint, dead-code checks, line caps, and runtime import-cycle checks.node scripts/run-vitest.mjs <focused files> --maxWorkers=1: 104 tests passed across ten files, including both CI-failing files and Gateway/TUI siblings; one existing opt-in benchmark remained skipped. The two perf files took 34.030 s and 18.897 s wall; the sibling invocation took 69.30 s. Targeted lint passed with zero warnings/errors.session-row-selection.test.tssession-row-projection.retention.test.tsserver-methods/sessions-search-scope.test.tssession-utils.perf.test.tssession-list-viewers.perf.test.tsThe earlier search-file cost was dominated by its existing 205-session/five-agent case (81.733 s), which protects discovery beyond historical scope limits using real stores. Main has independently optimized that fixture; the current repair sibling run includes the updated file. Current-head CI passed on
ae04a53355f2: 50 executed jobs, 8,119 summed job seconds and 420 seconds from first job start to last completion (21 conditional jobs skipped). Job seconds are elapsed job time, not billed CPU time.The selection regression failed on corrected main
b60f9e200987at its intended assertion: three full-roster selections after metadata changes instead of zero. All preceding ordering/archive assertions passed. Candidate coverage also preserves delete order, paging, pinning, callback failure, and disposal. Deletion's topology publication intentionally rebuilds its scope; the test separately verifies incremental updates before and after that reset.Initial CI run 37087849005 exposed repeated provenance classification and a search-identity roster rescan; both are repaired at their owners. Viewer coverage now also proves classification changes when an operator removes a heartbeat label and proves warm filter changes reuse accepted facts. A comparator-export spy reported a separate failure: a Testbox probe on unchanged base
ff96d47c3506produced the correct sorted 256-row page while the spy observed zero module-local comparisons. The first-page order/count oracle remains; only that invalid comparison budget and unused spy were removed.Fresh independent Codex review of the complete PR and CI repair: scoped-clean, no actionable P0–P2 findings. Preparation line-cap and missing-brace failures were fixed without suppressions. Native sync timeouts were resolved with fresh leases and serialized proof payloads. All four owned leases were stopped.
The rig covers the production handler, projection, and response serialization; WebSocket authentication and live deployment load are outside its scope. Allocation includes collected objects and workload writes and is sampled rather than exact.