Repository navigation
perf(chat): bound history pages and reuse recovery cursors - #165897
Merged
steipete merged 1 commit intoOct 6, 2026
Merged
Conversation
Use a smaller response target without shortening history recovery reads or splitting readable source-row projections. Reuse existing transcript cursors for outbox recovery while preserving fresh custody and legacy delivery proof. The synthetic full page drops from 4,633,114 to 522,667 bytes; unchanged refetches return 1,245 bytes. The 80% main-thread target is not established.
Contributor
|
🦞👀 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. |
steipete
marked this pull request as ready for review
October 6, 2026 01:35
steipete
enabled auto-merge (squash)
October 6, 2026 01:40
steipete
deleted the
steipete/perf-micro-chat-history-page-bytes-20260919
branch
October 6, 2026 01:46
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 6, 2026
…165897) Use a smaller response target without shortening history recovery reads or splitting readable source-row projections. Reuse existing transcript cursors for outbox recovery while preserving fresh custody and legacy delivery proof. The synthetic full page drops from 4,633,114 to 522,667 bytes; unchanged refetches return 1,245 bytes. The 80% main-thread target is not established.
steipete
added a commit
that referenced
this pull request
Oct 6, 2026
50f38c6 (#165897) intentionally changed ordinary history responses to a 512 KiB target and documented continuation through nextOffset. The old single-request assertion measured scrolling through all 900 messages under the previous 6 MiB policy from #152979; it did not measure opening a chat. Match older requests to committed pagination steps, check contiguous coverage and bounded nonempty responses, and allow at most one staged successor. Assert that all three startup samples issue no older-history requests. Preserve the ordered transcript, initial-tail, identity, Home, avatar, and cache assertions. The real Gateway reproduces the old failure with eight requests for eight backscroll steps. Startup remains one reply with 59 messages and 260,813 history bytes. The updated file passes locally, as do type-aware/boundary lint, its test-type graph, formatting, full local check-changed, and independent P2 review. No production or dependency changes; security-fast's source-map-js advisory (#165918) is inherited. Testbox-congestion exception: the lease timed out after 15 minutes queued, before sync or execution. Use the authorized ready-PR fallback; three Linux real-Gateway runs and the complete owning UI e2e config remain unrun.
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 7, 2026
815d4c3 (openclaw#165897) intentionally changed ordinary history responses to a 512 KiB target and documented continuation through nextOffset. The old single-request assertion measured scrolling through all 900 messages under the previous 6 MiB policy from openclaw#152979; it did not measure opening a chat. Match older requests to committed pagination steps, check contiguous coverage and bounded nonempty responses, and allow at most one staged successor. Assert that all three startup samples issue no older-history requests. Preserve the ordered transcript, initial-tail, identity, Home, avatar, and cache assertions. The real Gateway reproduces the old failure with eight requests for eight backscroll steps. Startup remains one reply with 59 messages and 260,813 history bytes. The updated file passes locally, as do type-aware/boundary lint, its test-type graph, formatting, full local check-changed, and independent P2 review. No production or dependency changes; security-fast's source-map-js advisory (openclaw#165918) is inherited. Testbox-congestion exception: the lease timed out after 15 minutes queued, before sync or execution. Use the authorized ready-PR fallback; three Linux real-Gateway runs and the complete owning UI e2e config remain unrun.
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Chat history recovery and backscroll can repeatedly transfer multi-megabyte pages, including history the caller already checked.
User Impact
Ordinary history pages are smaller, and repeated outbox delivery checks resume from the existing transcript cursor. Transcript storage and visible UI behavior are unchanged; older messages remain available through pagination. No new configuration or protocol version.
Why This Change Was Made
The previous default allowed 1,000-entry requests to return roughly 4.7 MB. Initial chat loads already request a smaller budget and ordinary refreshes already use a delta cursor, but outbox recovery requested a full page on every check, including its second idle verification.
Use a 512 KiB default response target for ordinary pages and deltas, preserving the existing 6 MiB hard ceiling. Source-row projections stay together because numeric offsets cannot resume within one row. Anchored reads keep their previous budget because they have no continuation, and error-recovery lookahead retains its existing read budget independently of response sizing.
The outbox owner now retains the existing revision-backed cursor for the exact connection, scope, physical session and queued submission version. Every request still reads fresh session state and input custody. Resets clear the watermark before fetching a new tail. Legacy submissions without exact receipts search the former 1,000-message / 6 MiB message-and-activity window before accepting a negative tail cursor. Shared history reconciliation preserves distinct projected siblings across page overlaps; the temporary inspected window is bounded.
Production LOC: +291 net (+352 / −61), excluding tests and docs. Growth preserves concrete existing contracts: raw-row numeric cursor compatibility; legacy delivery proof outside the smaller first page; and connection/submission/session invalidation. The unconditional full-page reader is replaced, not retained as a competing path. Existing host reconciliation moves into its projection module to keep the outbox owner within its line cap.
Evidence
The staged gate passed on the authorized Linux rig after Testbox admission exceeded 20 minutes. Measurements passed on that rig. Current-head focused validation passed on Blacksmith Testbox
tbx_01m47dk1eefxqtfm3pfa5v46ez, providerblacksmith-testbox, profileopenclaw-check. The synthetic rig uses 640 messages of roughly 7 KB each, the real history handler and storage workers, Gateway frame serializer and a loopback WebSocket, with nine warm measured calls per variant. Baseline and candidate use the same checkout base.Linux rig, Node 26.8.1: 40 warmups for each path, then nine measured samples per variant; candidate ran before baseline. Main-thread CPU uses
process.threadCpuUsage(), and its total is the median of per-call phase sums.Every sampled full frame had exactly the listed byte count. Full pages were 88.7% smaller and unchanged refetches avoided 99.97% of the bytes. The unchanged cursor response already existed; the outbox now uses it. The shared rig showed substantial elapsed-time and scheduling variation between passes, so no latency improvement is claimed. Direct main-thread CPU improved only about 8.6% for full pages / 11.3% for repeats in this run: the 80% main-thread target is not established.
Focused Testbox validation passed 228 tests in eight files, plus three expected failing negative controls, in 3m19s total command time. The run verified all 14 source hashes against the published head before execution and after restoring the controls. Restoring the smaller read budget lost anchored siblings and exposed a recovered error; ignoring activity bytes inspected 18,941,250 bytes instead of staying within the bounded fixture window.
Costs for changed test files, each run as
pnpm test <file> --maxWorkers=1:ui/src/pages/chat/chat-outbox-transient-recovery.test.tssrc/gateway/server-methods/chat-history-request-budget.test.tssrc/gateway/server-methods/chat-history-pages.test.tsThe RPC/worker budget tests exercise real storage, projection and serialization because helper-only checks cannot detect the paging and recovery regressions. The remaining 192 tests cover chat send, pending-input pagination, send deadlines, history cursors and history-worker errors via
node scripts/run-vitest.mjs <focused files> --maxWorkers=1. These costs are measured on Testbox; hosted CI test costs are unavailable because the dependency audit cancelled that run.Independent Codex review: scoped-clean through P2.
node scripts/check-changed.mjs --stagedpassed on the Linux rig (exit 0, approximately 64 minutes), including all 27 core-test type graphs, UI/core typechecks, dead-code scans, changed-file lint and source/storage guards. The native command suppresses its timing table on success unless--timedis set; no checks were repeated merely to produce a table. No focused validation remains pending.Hosted CI blocker: run 37399958211 failed
security-fast / Audit production dependencieson GHSA-68fv-2mgg-jv7q, which flagssource-map-js >=1.0.0 <1.2.2. The failure cancelled the other CI lanes. This PR changes no dependency files; verified main381b1e05d7f0fa572fdf085e7714d4f90864d4b5still pins[email protected], and its lockfile blob is identical to this branch (5ef4235547392dcc35175fecd449052fb0c6dbaf). The dependency owner needs to land the fix on main, after which this branch can rebase. No audit exception or dependency change is included here.Limits: the same ordinary workload meets the <1 MB page and <2 KB unchanged targets. An indivisible projected group or anchored request can still exceed 1 MB under the preserved hard ceiling. JSON encoding already runs in a worker; authorization, session and receipt work remains per request. The measurements do not establish the 80% main-thread target.
A bounded 50-minute read-only production log sample contained 41 responses above 2 MB (182.7 MB total), including six responses of exactly 4,597,151 bytes on one uninterrupted Control UI connection. That sample does not reconcile the campaign aggregate of 120. Production logs omit history parameters and session keys. Repeated identical page sizes on an uninterrupted connection are consistent with outbox recovery, but exact session/caller attribution remains unproven. No production deployment is included.