Skip to content

Speed up browser journal replay - #309

Merged
fitchmultz merged 2 commits into
mainfrom
perf/replay-native
Oct 30, 2026
Merged

fitchmultz merged 2 commits into
mainfrom
perf/replay-native

Conversation

@fitchmultz

@fitchmultz fitchmultz commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Why

Find and fix serious browser-extension performance costs without weakening browser behavior or journal safety. Large sessions currently reparse selected browser records through the streaming tokenizer even when those records qualify for the existing bounded native path.

Summary

  • Use the existing bounded native-or-token projector for selected browser journal records that fit the framer's existing 1 MiB retention limit; larger records continue to stream through the existing tokenizer.
  • Apply it to replayed transitions and winning snapshot definitions, without changing journal publication, selection, or the memory threshold. Document the path in docs/PERFORMANCE.md.

Measurement

On macOS arm64 with Node 24.22.2, three interleaved baseline/candidate/candidate/baseline blocks ran against copies of two real journals. Each revision had six independent runs with 15 warm replay samples each. Pooled warm replay medians were 263.20 → 166.09 ms for a 114 MB journal (2,179 projected entries) and 152.05 → 119.64 ms for a 153 MB journal (1,813 entries). Output digests matched on every run. Host load varied, and cold measurements were inconclusive; this is replay work only, not an end-to-end Pi startup or browser-call speedup.

Verification

  • npm run verify -- pre-pr with Node 24.22.2, npm 12.2.0, Go 1.27.1 and isolated agent-browser 0.39.2: passed build, strict quality policy and lint, formatting, typecheck, generated docs, live command reference, package verification, and both test stages (1,511 passed / 49 skipped; 66 passed / 9 skipped).
  • node --max-old-space-size=128 test/helpers/large-browser-journal.mjs: passed with a 1,614,664,908-byte journal, including a string over Node's string ceiling, 34,683 refs and three branches. Actual V8 heap limit was 335,544,320 bytes and peak RSS 363,008 KiB; the old-space flag is not a total-memory limit.
  • Interactive checkout-only Pi smoke: opened a loopback page, snapshotted, clicked a current ref and verified the state; after exit and exact-session-ID relaunch, confirmed the same title and page state, then closed the browser. Pi session journals were retained.
  • Independent review checked replay parity for documented append-only journals. Existing malformed-input, branch, legacy, recovery, and large-journal coverage remains unchanged. Simultaneous corruption and truncation of an already-validated prefix can alter which error is reported first, outside the append-only contract; both paths fail closed.
  • Pi Durable reviewed the full diff at the current head and reported no new findings. Its check summary records 20 completed commands and one failed command; the underlying private command detail was not available without signing in.
  • Cursor's automated review returned “Automation encountered an error” on the initial head and a retry; GitHub marks these neutral, not a successful review. A manual Bugbot request reported that Bugbot is disabled for this repository, and a Cursor Cloud review also ended with ERROR. As a separate fallback, the current Cursor CLI reviewed the supplied complete diff and surrounding code in sandboxed read-only Ask mode and reported no defects; that review was static and ran no tests. No repository settings were changed.

@fitchmultz

Copy link
Copy Markdown
Owner Author

cursor review

@cursor

cursor Bot commented Oct 30, 2026

Copy link
Copy Markdown

Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings.

@fitchmultz
fitchmultz merged commit d096e37 into main Oct 30, 2026
13 checks passed
@fitchmultz
fitchmultz deleted the perf/replay-native branch October 30, 2026 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant