Skip to content

perf(remote): load session history pages on demand - #3203

Merged
wgqqqqq merged 2 commits into
GCWing:mainfrom
wgqqqqq:wgq/on-demand-session-history
Sep 23, 2026
Merged

wgqqqqq merged 2 commits into
GCWing:mainfrom
wgqqqqq:wgq/on-demand-session-history

Conversation

@wgqqqqq

@wgqqqqq wgqqqqq commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Opening a long remote conversation currently reads and projects every persisted turn before cutting the first stream page. Load historical turns on demand until the requested page reaches its event/byte budget instead. Android, iOS and HarmonyOS keep the existing read_stream protocol.

Type and Areas

Type: Performance / bug fix.

Areas: Rust session persistence and Remote Connect host streams; native mobile transport regression tests.

Motivation / Impact

An opt-in benchmark compares both production persistence/projection/stream paths against the same 128-turn fixture (128 KiB input per turn). Fresh hubs are used for each of five samples, and the first-page payloads are asserted identical apart from revisions.

Local first-page work Full materialization On-demand history
Median, debug build 1,580 ms 38.5 ms
Turn bodies read 128 3

This is approximately 41x faster in this local synthetic fixture, not an end-to-end phone/relay measurement. All five samples are printed by the reproducible benchmark; there is no machine-dependent timing assertion in CI.

Verification

  • cargo test --locked -p openbitfun-core --no-default-features --features remote-connect,git --lib agentic::persistence::manager::tests:: — 57 passed, 2 opt-in tests ignored.
  • Same Core target with load_relay_session_turns_ — 1 passed, including paged/full content equivalence after unloading the session.
  • Same Core target with history_page_benchmark -- --ignored --nocapture — passed; measurements above.
  • cargo test --locked -p openbitfun-services-integrations --no-default-features --features remote-connect --lib remote_connect::host_stream — 20 passed. Covers bounded reads, large-turn continuation, live updates, source gaps, epoch resets, eviction/backscroll and the existing Rust subscriber.
  • node --test src/apps/mobile/harmonyos/tools/tests/host-stream.test.cjs — 10 passed.
  • From src/apps/mobile/shared: ./gradlew :core-transport:jvmTest --tests '*HostStreamTest' — 19 passed, exercising the shared Android/iOS reader with JS-safe history/live cursors.
  • pnpm run fmt:rs and git diff --check — passed.
  • pnpm run mobile:architecture — existing failure. A pristine worktree of base faf5d4a41 produces exactly the same output: one sharedReachesPlatformTrees entry in ClientBuildContractTest.kt and three defaultArgsInFeatureApi entries. No baseline was loosened.

Remote scenario exercised: Remote Connect host/readers in local fixtures. HarmonyOS hardware validation could not run because hdc list targets returned empty. No live relay, SSH workspace, peer-device or detached-dispatch verification is claimed.

Reviewer Notes

  • Historical backfill uses decreasing JS-safe sequences below the live sequence range, so it never advances the forward cursor. The existing per-session source gate orders backfill and live publication. Wire fields and persisted formats are unchanged; legacy clients retain their current path.
  • Undo/import, source delivery gaps and reads across evicted cache ranges use an epoch fence. Backscroll can continue beyond the resident body budget without silently skipping records.
  • File-name indices remain authoritative when a legacy catalog is absent or stale; unrelated turn bodies are not parsed. In-progress context overlay remains in the coordinator.
  • The pending source batch is at most one persisted turn. A single very large turn still requires reading/projecting that file; this PR does not claim to eliminate that cost or cold-start connection setup.
  • Based independently on upstream main, without bundling fix(mobile): let the host's transcript and catalog be the single mobile authority #3201. Both PRs touch the coordinator history reader; preserve both changes when resolving their merge overlap.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable (no UI copy changes; owner verification guides updated).

@wgqqqqq
wgqqqqq merged commit 52780ea into GCWing:main Sep 23, 2026
13 checks passed
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