Repository navigation
improve: reduce Gateway stalls during session indexing - #147234
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: blocked before merge. Reviewed September 13, 2026, 3:21 PM ET / 19:21 UTC (Revision 5). ClawSweeper reviewWhat this changesMoves session transcript preparation into background workers, preserves redaction and reset boundaries, and rebuilds older memory indexes through existing recovery paths. Merge readiness⛔ Blocked before merge - 3 items remain Keep open: this remains useful work beyond fetched main and the latest release. The previous worker-failure blocker is resolved, and the reviewed head preserves the production code used for the supplied performance and upgrade evidence. No actionable patch defects remain. Priority: P2 Review scores
Verification
How this fits togetherMemory Core turns stored conversations into searchable text and embeddings. This change moves transcript reading and preparation off the Gateway thread while leaving index publication with the existing memory manager. flowchart TD
A[Stored conversations] --> B[Read-only SQLite snapshot]
C[Current redaction snapshot] --> D[Background transcript worker]
B --> D
D --> E[Prepared text and reset boundaries]
E --> F[Memory index publication]
G[Foreground context requests] --> H[Separate context worker]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +306, Tests +431, Docs +15. Total +752 across 22 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep transcript preparation on the bounded worker path, preserve existing publication and recovery owners, and track remaining synchronous indexing pauses separately. Do we have a high-confidence way to reproduce the issue? Yes for synchronous indexing preparation and lost reset metadata: the source paths are clear and the supplied paired runs exercise them. This read-only review did not execute tests or reproduce the broader multi-minute Gateway incidents. Is this the best way to solve the issue? Yes. The patch extends the existing worker mechanism, keeps foreground work separate, and reuses the established index invalidation and atomic publication paths without adding public configuration or schema changes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 01d9d686ef35. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
Addressed the operational-failure finding in a59f01c361d1bc27338dc1a630230e0d0d9c7d75. Worker admission and transport errors now reach the existing failed-rebuild owner. The real manager regression fills all 128 shared admissions, verifies that published source/chunk/FTS rows survive unchanged with dirty/error state retained, then drains capacity and verifies ordinary retry recovery. It fails before the fix and passes afterward. I also verified the unchanged-index upgrade path. The existing private chunking revision advances from 4 to 5, so previously indexed reset chunks rebuild once even when source hashes and timestamps match. The legacy-index regression fails before that invalidation and passes afterward; all 52 final manager/upgrade cases and checks pass. There are no database schema, transcript codec, public protocol, or configuration changes. Existing cached embeddings remain reusable. The PR description now records these repairs. Fresh paired Linux measurements and same-database upgrade proof are running on the current head; I will update the evidence before landing. |
Use the shared session-transcript worker with separate context and background queues. Preserve exact-secret redaction and reset recall metadata through preparation and index publication.
Propagate operational worker errors through existing shadow-rebuild recovery. Advance the private chunking revision so unchanged reset-bearing indexes rebuild through the existing owner without changing transcript hashes or schemas.
a59f01c to
db829a1
Compare
|
Reviewed the remaining merge-risk notes. The bounded worker tradeoff is intentional, and the PR explicitly limits the startup/RSS numbers to source execution; it makes no packaged-runtime cost claim. The existing-index compatibility proof is complete: two processes opened the same saved database, verified its bytes before upgrade, and repaired the reset chunks with ordinary sync while preserving transcript and source metadata. Raw-log access being blocked in the review environment does not change the executed results, which were collected and inspected during this task. The previous operational-failure finding is fixed, the current-head CI run is green, and native prepare has passed. No actionable code findings remain; proceeding with the scoped landing under the requested maintainer authority. |
|
Merged via squash.
|
* perf(sessions): offload transcript preparation Use the shared session-transcript worker with separate context and background queues. Preserve exact-secret redaction and reset recall metadata through preparation and index publication. * test(sessions): expect preserved transcript fence errors * fix(memory): preserve indexes when transcript preparation fails Propagate operational worker errors through existing shadow-rebuild recovery. Advance the private chunking revision so unchanged reset-bearing indexes rebuild through the existing owner without changing transcript hashes or schemas. * test(ci): include QA profile status routing coverage
Related: #138042
What Problem This Solves
Preparing large session transcripts for background indexing keeps the Gateway event loop busy with SQLite reads, redaction, text processing, and hashing.
User Impact
Background session preparation leaves substantially more time for the Gateway to handle other requests. The existing foreground context queue stays separate from background work. Reset recall boundaries also survive index publication, preventing chunks from spanning a conversation reset.
This trades worker startup and memory for main-thread availability; complete warm indexing time and the longest remaining pause stay essentially unchanged. The existing chunking revision triggers a one-time derived-index rebuild so previously indexed reset chunks are repaired too; unchanged chunks can reuse cached embeddings. No configuration, transcript format, or database schema migration is required.
Why This Change Was Made
Generalize the existing model-context worker into the session-transcript worker, with separate bounded foreground and background queues. Export text, statistics, and classification come from one read-only SQLite snapshot; preparation carries the current exact-secret redaction policy and returns reset metadata explicitly. Archives, incognito state, and caller-owned observers retain their existing local paths.
The actual indexer proof exposed an existing copy that discarded non-enumerable reset metadata. Preserve the prepared entry through that handoff. Operational worker failures now reject the rebuild so its existing failure path retains the published index and retry state.
Evidence
Three alternating baseline/candidate process pairs on the same Linux Blacksmith Testbox, each forcing five rebuilds of 10,000 synthetic messages with 512-character payloads. Across all 30 pre-reset rebuilds, content, line maps, timestamps, provenance, and indexed fingerprints match exactly. The baseline fails the reset-boundary assertion; all three candidate reset checks pass. The added overload regression preserves source/chunk/FTS rows under 128 held worker admissions and recovers after capacity drains. An unchanged legacy-index regression fails before the private chunking revision advances, then repairs through ordinary sync without force.
These preparation measurements execute TypeScript source. First sync includes source/module and worker startup: 1.29 s baseline versus 4.51 s candidate. RSS includes fixture setup, imported source, and all workers; it is not a packaged-runtime memory measurement. A separate warm-sync CPU profile locates the remaining main-thread work in synchronous index population and final index publication. Those write owners remain unchanged by this read/preparation cutover.
Focused storage/redaction/context coverage passed (321 tests), followed by sibling checks and the complete manager race suite. The final recovery/upgrade run passes 52 tests across the 24-case manager file and existing upgrade suites. The new reset regression fails before the fix and passes afterward. All selected changed checks passed, including all four typecheck lanes, lint, dead exports, import cycles, and storage guards. Independent review found no actionable P0–P2 findings. CI exposed an outdated generic-error expectation in the source-deletion review test; the exact domain-error assertion was updated, and all 22 cases in that file, its changed checks, and review pass. The unrelated Workboard lint failure was already fixed on main.
Both Linux builds completed. The untouched baseline already exceeded the Control UI startup gzip budget by 35 bytes; the candidate exceeded it by 64 bytes. UI module/request counts and CSS totals match; build identity is not pinned between those builds.
Remote proof: https://github.com/openclaw/openclaw/actions/runs/34775319507 . The paired run and the two-process upgrade of the same saved database both passed; the owned Testbox lease is stopped. The upgrade verifies closed-state bytes before the candidate opens them, then repairs the reset chunks through ordinary sync while preserving transcript rows and source hash/mtime/size.
Measurements were captured at a59f01c361d1bc27338dc1a630230e0d0d9c7d75. The touched production files remain byte-identical after refreshing onto current main; package/dependency metadata was refreshed, and exact-head CI passed for that integration before native merge. A separate one-line CI follow-up updates the exact QA Profile routing expectation for a test newly added upstream; its full 602-case suite and scoped review/checks pass.