Repository navigation
perf(sessions): avoid full display rebuilds during resolution - #169082
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. What this changesThis PR resolves session targets using current selection metadata without waiting for unrelated session display rows to rebuild. Example: Resolve session ID target-id while agent:main:unrelated-display fails to rebuild.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this PR makes a useful, focused improvement that current main still lacks, and source review found no introduced correctness defect. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherGateway session resolution accepts keys, IDs, labels, and references, prepares projection metadata, applies current visibility rules, and returns canonical session targets or ambiguity errors. flowchart TD
A[Client session selector] --> B[Gateway resolve handler]
B --> C[Prepared session resolver]
C --> D[Session row projection]
D --> E[Worker metadata reads]
D --> F[Background display refresh]
C --> G[Current visibility and selection]
G --> H[Canonical target response]
Technical reviewBest possible solution: Use the existing selection-preparation owner while preserving exact-key readiness, ACP checks, and synchronous current-viewer resolution. Do we have a high-confidence way to reproduce the issue? Current main visibly awaits the entire display drain for discovery selectors, and the supplied RPC regression targets a sibling display failure; this read-only review ran no target code. Is this the best way to solve the issue? The change addresses the dependency at its existing owner rather than adding caching or suppressing failures, while preserving metadata reconciliation and response-boundary visibility checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d1618ccd0b27. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -5, Tests +47, Docs +1. Total +43 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 11, 2026, 7:39 AM ET / 11:39 UTC. |
|
The author’s temporary validation hold is resolved. The final candidate tree exactly matches head The slower-cadence comparison (2,000 sessions, approximately 18.4 writes/second, one-second gaps between requests, 30 samples per version) measured raw-ID average 726.1 → 338.9 ms, median 711.4 → 329.3 ms, and p99 944.1 → 536.0 ms. The 100 ms cold p99 target remains unmet; the improvement is 2.14× on average. All 78 focused tests passed on that candidate tree, and required CI run 38136002901 passed on the exact PR head. Independent review and ClawSweeper identified no introduced code defect. The PR body now contains final measurements, test cost, and the remaining measurement limits. |
First-parent upstream 75df19c..5ed6a30 (23 commits, including openclaw#169005 infrastructure SQLite work and runtime-write offload, openclaw#169062, openclaw#136677, openclaw#169070, openclaw#168857 plugin-sdk SQLite runtime writes into workers, openclaw#169038, openclaw#168916, openclaw#169053, openclaw#169052 closed-turn transcript work in workers, openclaw#168974, openclaw#168811, openclaw#169082, openclaw#169084, openclaw#166581 worker heap limits). Conflicts: - openclaw-state-worker-runtime.ts: upstream routes more update-run mutations to the worker; our continuation custody dispatch stays ahead of that branch. - worker-access inventory: regenerated (632 files, 2429 calls). server-restart-sentinel.ts auto-merged: upstream's awaited update-run writes; our continuation restart delivery is unaffected. Refs #1475 Co-Authored-By: Claude Opus 5.5 <[email protected]>
What Problem This Solves
Session ID, label, and link resolution waits for every dirty session display row to rebuild. A broad invalidation can therefore turn a small lookup into a long wait, and an unrelated display failure can reject resolution.
User Impact
Session targets resolve from current metadata while unrelated display rows refresh in the background. Existing visibility, canonical readiness, ambiguity, and exact-key behavior remain intact. There are no schema, stored-data, configuration, or upgrade changes.
Why This Change Was Made
Use the session-row projection's existing selection preparation through
withReadySessionRows, replacing the separate full-materialization wait. The projection remains the sole owner of indexes and committed invalidation. Production LOC: 15 added, 20 removed (net -5).Evidence
Final same-host RPC-handler comparison: 2,000 synthetic sessions, approximately 18.4 committed background writes/second, one-second gaps between resolve requests, 30 observations per version. A broad store invalidation precedes each request. Baseline
f1fbf170dea3; candidate tree exactly matches49886f8c40b3474cb09898d6d524f3dff0634669.That is a 2.14× average speedup. The 100 ms cold p99 target is missed: broad invalidation still requires metadata reconciliation. This change removes the additional full-display drain and its unrelated failure dependency.
An earlier higher-frequency comparison on
b690de6fbb42measured cold ID p99 905 → 368 ms, label p99 712 → 402 ms, and reference p99 627 → 310 ms. Under ordinary writes, every selector's p99 stayed below 13 ms on both versions. The hypothesis that every ordinary write rebuilds the ID index was not reproduced; committed publications already maintain that index.Validation:
Unrelated display unavailableand passes with the change.pnpm test src/gateway/sessions-resolve-projection.test.ts --maxWorkers=1: 19 passed, 65.55 seconds wall time. The added case took 3.20 seconds in that run; separate per-case CI seconds were not extracted.49886f8c40b3474cb09898d6d524f3dff0634669, including all production/test type checks, lint, tests, andopenclaw/ci-gate. The duplicate serial rig type run was stopped after CI established those results.All runtime measurements and focused tests ran on the authorized Linux rig, with isolated synthetic state and a dedicated temporary directory. Testbox
tbx_01m4n5qvqtn33y3zkj86efdzk2remained queued; AWScbx_a73fb99b8d51and Hetznercbx_6c21ab94c95csync attempts failed before any workload executed and were released. The old base had unrelated max-lines/dead-export failures; current-main max-lines and exact-head required CI pass. No production Gateway was accessed.Measurements cover the registered RPC handler and real isolated storage, excluding WebSocket transport and production-load effects. The sample p99 is the maximum of 30 observations per version.