Skip to content

perf(sync-client): prefetch pull metadata pages - #37

Merged
hhhjin merged 1 commit into
mainfrom
codex/pull-page-prefetch
Sep 5, 2026
Merged

perf(sync-client): prefetch pull metadata pages#37
hhhjin merged 1 commit into
mainfrom
codex/pull-page-prefetch

Conversation

@hhhjin

@hhhjin hhhjin commented Sep 5, 2026

Copy link
Copy Markdown
Member

Pull currently waits for each batch's downloads, vault writes, and checkpoint before requesting the next metadata page. Prefetch one page of metadata and decrypt it while applying the current batch, reducing idle time between batches while preserving ordered vault changes and cursor checkpoints.

Prefetch failures are observed immediately and propagated when consuming that page. On failure, pull waits for outstanding page work; metadata workers settle before returning a failed page. Tests cover one-page lookahead, pagination parameters, retained checkpoints on request/decryption failures, and cleanup when the current download fails. Includes the Obsidian release note and reproducible pull latency benchmarks.

Validation

  • Shared sync-client suite: 324 tests passed.
  • Sync-client and Obsidian plugin type checks passed.
  • All benchmark runs verified file contents, cursor, and pending queue after timing.
  • git diff --check passed.

Benchmark comparison

Compared against main at 39be8238c6514a89286881835dcb1e122b35fd3e, with identical benchmark harnesses in isolated source copies. Each implementation pulled 500 distinct 4 KiB Markdown notes using the real SyncEngine.syncNow(), crypto, and filesystem vault, with an in-memory sync store. Setup and verification were excluded. Two invocations per implementation, each with one warmup and five measured runs; execution order was before → after → after → before. Node v24.12.0, Vitest 4.1.4.

Metadata page / blob GET delay Before mean After mean Duration change
0 / 0 ms 129.29 ms 132.05 ms +2.1%, within observed variation
40 / 5 ms 716.26 ms 481.36 ms −32.8%
120 / 5 ms 1,194.01 ms 730.11 ms −38.9%

Delays are independent synthetic per-request waits, not real Cloudflare/R2, shared-bandwidth, or Obsidian/mobile measurements. These results demonstrate the benefit when metadata pagination incurs latency; they do not establish a production speedup percentage.

Reproduce the scenarios with pnpm -C packages/sync-client bench --run -t pull-notes. The benchmark README documents baseline comparison, and the Vitest benchmark settings now live under test.benchmark.

@hhhjin
hhhjin merged commit ffdefd2 into main Sep 5, 2026
4 checks passed
@hhhjin
hhhjin deleted the codex/pull-page-prefetch branch September 5, 2026 10:11
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