Repository navigation
improve(sessions): avoid redundant shared history copies - #154552
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 maintainer review before merge. Reviewed September 21, 2026, 3:23 AM ET / 07:23 UTC. ClawSweeper reviewWhat this changesThe PR avoids one deep copy per shared session-history read by giving the final receiver the original result, with cancellation coverage and an opt-in benchmark. Merge readiness✅ Ready for maintainer review Keep open: this is a useful, bounded optimization that current main does not implement. No actionable correctness or security findings were identified. Priority: P2 Review scores
Verification
How this fits togetherGateway history requests share equivalent queued SQLite reads through the session-history worker owner. The owner returns independently mutable results for callers to present to clients. flowchart TD
A[Gateway history requests] --> B[Admission and capacity checks]
B --> C[Group equivalent queued reads]
C --> D[Worker reads history snapshot]
D --> E{Receiver canceled?}
E -->|Yes| F[Reject caller]
E -->|No| G[Clone for earlier receivers]
G --> H[Final receiver takes original]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +2, Tests +43. Total +45 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain the existing history-read owner and snapshot boundaries while eliminating the final receiver's unnecessary copy. Do we have a high-confidence way to reproduce the issue? Yes, from source: equivalent reads queued before dispatch cause current main to clone once per successful receiver. The focused regression exercises that path, but no runtime reproduction was executed in this read-only review. Is this the best way to solve the issue? Yes. Receiver counting removes the redundant copy within the existing owner while preserving mutable isolation, cancellation, and snapshot freshness. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 057492fa6da7. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…question-layout-restart-recovery-20260921 * 'main' of https://github.com/openclaw/openclaw: (110 commits) perf(infra): collect and retire idle worker heaps (openclaw#154408) perf(sessions): hand shared history to the final reader (openclaw#154552) fix: clarify Codex onboarding migration scope (openclaw#151383) fix: recover conflicted PRs after accepted auto-merge perf(update): defer Gateway maintenance during candidate validation (openclaw#154548) perf(test): advance llama.cpp reload deadlines virtually (openclaw#154536) refactor(skills): prepare pinned library resources off-thread (openclaw#148560) fix(tooling): preserve Node compiler policy in script subprocesses (openclaw#154509) ci: select supported Node and cover packaged Node 26 (openclaw#154298) fix(release): preserve Telegram rerun evidence (openclaw#154561) docs: follow pending PR merges through completion fix(gateway): avoid stuck shutdowns after lifecycle errors (openclaw#145241) fix(ui): let focused dashboard widgets fill the task area (openclaw#154440) feat(release): add non-Latest extended-stable releases (openclaw#154515) fix(release): project 7.35 package Telegram config (openclaw#154546) refactor(config): derive host contracts from schemas (openclaw#153936) fix(ui): remove finished subagents from inline activity (openclaw#154469) refactor(config): derive core channel contracts from schemas (openclaw#153935) refactor(config): derive boundary contracts from schemas (openclaw#153937) fix(ui): keep thread activity current across cached updates (openclaw#154540) ...
What Problem This Solves
Equivalent queued history reads share one worker result but then deep-clone that entire result for every waiting caller, including the final caller who could own the original.
User Impact
Concurrent readers of the same history page allocate and copy less data while retaining separate mutable results. Single-reader behavior, cancellation, capacity limits, and read authority remain unchanged. No configuration, protocol, storage, or migration changes.
Why This Change Was Made
Count registered receivers and hand the original to the final receiver after earlier receivers have finished cloning. Dispatch already removes the group from the queue before the snapshot begins, preventing late joins. Decrement before cancellation; a canceled final receiver discards the original and simply forfeits this saving.
This complements #149219's lazy history-query preparation and the separately owned hydration/storage work. It does not change worker concurrency or bypass snapshot boundaries.
Evidence
pnpm test src/gateway/session-history-worker-runtime.test.ts --maxWorkers=1: 28.83 s wrapper wall time including compilation/import; opt-in benchmark remains disabled in normal CI. The benchmark-enabled run passed all 23 cases.node scripts/check-changed.mjs: passed, including core/test typechecks, lint, dead-export scans, and applicable repository guards.