perf(sync-client): prefetch pull metadata pages - #37
Merged
Conversation
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.
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
git diff --checkpassed.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 realSyncEngine.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.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 undertest.benchmark.