bundles: prefetch retained Itar cache entries concurrently#1379
Conversation
There was a problem hiding this comment.
Pull request overview
This PR accelerates cold-cache builds by teaching the bundles layer to prefetch a previously-recorded “working set” of bundle files concurrently, so the TeX engine’s later synchronous reads mostly hit the local cache instead of issuing hundreds of serial HTTP range requests.
Changes:
- Add a
CachableBundle::batch_openAPI (default serial implementation) to support batch fetching of bundle files. - Implement concurrent batch downloading in
ItarBundle(worker pool + per-worker range reader) and refactor retrying range reads into a shared helper. - Add a per-bundle prefetch manifest in
BundleCacheand a one-time-per-session prefetch step before the first file lookup.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| crates/bundles/src/lib.rs | Introduces batch_open on CachableBundle with a correct serial default implementation. |
| crates/bundles/src/itar.rs | Adds concurrent batch_open override for the .tar network bundle and shared retrying range-read helper. |
| crates/bundles/src/cache.rs | Records fetched file names to a manifest and replays them via prefetch() to warm the on-disk cache. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@CraftSpider ready for review |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1379 +/- ##
==========================================
+ Coverage 29.85% 29.90% +0.05%
==========================================
Files 273 275 +2
Lines 180530 180810 +280
Branches 180530 180810 +280
==========================================
+ Hits 53889 54064 +175
- Misses 54416 54525 +109
+ Partials 72225 72221 -4
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
37eb9e3 to
d6d4746
Compare
d6d4746 to
8419491
Compare
|
Status update since my earlier ping: this is now ready for code review. The branch is rebased onto current master and reduced to two focused commits. The existing review feedback is addressed, and the PR body now documents the narrower retained-metadata cache scope and current validation. The fork workflow is waiting for maintainer approval before GitHub will start it. |
CraftSpider
left a comment
There was a problem hiding this comment.
Thanks for the change! Improving our performance is a pretty significant goal right now, so this looks like a great speedup.
Summary
This PR lets the indexed-tar bundle cache refetch a previously used working set concurrently when its metadata is still present but the cached file blobs are missing.
It does not change a first-ever build on a new cache because there is no learned manifest to replay.
TTBNetBundleis also unchanged.Why
The TeX engine discovers support files synchronously. With an indexed-tar bundle, every cache miss becomes a separate HTTP byte-range request, so a high-latency connection pays the round-trip cost once per file.
After one successful build, the cache already knows which names were requested. Replaying that bounded list concurrently turns the later engine requests into local cache hits.
Implementation
BundleCachekeeps an append-only manifest keyed by bundle location. It records successful warm hits and downloads, deduplicates entries when loading, and caps the learned set at 512 names.CachableBundle::supports_batch_open, so backends without a concurrent implementation retain their existing on-demand behavior.ItarBundleuses a bounded worker pool with one range reader per worker. The default is 16 workers, with a hard cap of 64.Failure behavior
only_cachedmode never starts a network prefetch.Review guide
The two commits are intentionally separated:
bundles: connect Itar reader for cached indexesfixes the cached-indexreader == Nonepanic and adds its regression test.bundles: prefetch retained Itar cache entriesadds the opt-in API, cache-side manifest handling, and Itar worker pool.For the feature commit, the shortest review path is:
crates/bundles/src/lib.rs: the optional batch capability.crates/bundles/src/cache/prefetch.rs: manifest rules, cache filtering, fallback, and temporary-file placement.crates/bundles/src/itar/batch.rs: concurrency and memory bounds.cache.rsanditar.rs.Validation
A manual high-latency measurement used the same patched binary and identical cache state in both arms: retained bundle index and manifest, missing file blobs. Only
TECTONIC_PREFETCH_CONCURRENCYchanged.These absolute times depend on network latency. The relevant result is the reduction in serialized range-request waits for this specific retained-metadata cache state.
Related: #446.