Repository navigation
perf(gateway): stop per-row store and registry rediscovery in sessions.list - #114659
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 2:33 PM ET / 18:33 UTC. ClawSweeper reviewWhat this changesThis PR makes Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain Keep this PR open for normal maintainer review. It presents a bounded performance refactor across the gateway session-listing path, but the available evidence still contains tests and prior baseline measurements rather than inspectable after-fix behavior from a real deployment; the protected Priority: P2 Review scores
Verification
How this fits togetherThe gateway’s flowchart LR
A[Control UI or gateway client] --> B[sessions.list handler]
B --> C[Session store discovery]
B --> D[ACP metadata lookup]
B --> E[Active-run registries]
C --> F[Sharing and row projection]
D --> F
E --> F
F --> G[Session list response]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +220, Tests +224, Other +1. Total +445 across 17 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the cache and batching changes at their current owner boundaries, then attach redacted before/after diagnostics from a real Do we have a high-confidence way to reproduce the issue? No high-confidence after-fix reproduction is available in the supplied review evidence. The PR describes a concrete production workload and adds focused tests, but it does not include inspectable post-change timing, diagnostics, or a redacted live trace. Is this the best way to solve the issue? Unclear until real behavior proof is attached. The cache placement, batching, and write-side invalidation align with the repository’s prepared-facts and process-stable-metadata guidance, but the user-visible performance and restart-scoped registry behavior still need direct confirmation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3923a9c8b9ca. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
6eb2f2e to
e2ce398
Compare
|
Merged via squash.
|
…s.list (openclaw#114659) * perf(gateway): stop per-row store and registry rediscovery in sessions.list * fix(gateway): satisfy kysely guardrail and knip on sessions.list rediscovery fix * refactor(state): split registered agent database listing from the registry * chore(state): allowlist the split registry listing module for raw sqlite probes
What Problem This Solves
sessions.liston team.openclaw.ai (avg 587ms, max 2.8s at ~300 sessions/3 agent stores) spent its dominant flag-independent cost on per-row rediscovery: every returned row re-ran session-store target discovery (readdirSyncover the agents root, 3-4lstatSync/realpathSync.nativeper agent dir, and three full state-DB registry reads — each re-running schema-migration detection probes), plus a per-row ACP metadata query, a structuredClone of every entry for the sharing lookup, and a rebuild of the live-run registries per row. The whole sharing/membership stage was also the only part of the handler with no diagnostics span, making it invisible in production timelines.Why This Change Was Made
Five bounded fixes at their natural owners:
GatewaySessionStoreCachepattern): at most one discovery per agent per request.listOpenClawRegisteredAgentDatabasesgains a single-slot process-level memo keyed by resolved registry path, invalidated by this module's own write paths post-commit — registry metadata is process-stable per repo policy; other-process changes take effect on restart, and the comment names that contract.IN (...)query per request (~300 queries → 1).clone: false(that path reads onlycreatedActor.id/visibility; the cache doc-comment already required read-only use).gateway.sessions.list.sharingdiagnostics span.User Impact
The Control UI's most frequent heavy call drops its dominant per-row costs: roughly 7,500-9,000 SQLite statements and 9,000-18,000 filesystem calls per request reduced to low tens and ~90-180 respectively (>99%). No response-shape or behavior change.
Evidence
git diff --checkclean; Testbox run: https://github.com/openclaw/openclaw/actions/runs/30286706316