Repository navigation
[pull] main from pnpm:main - #522
Merged
Merged
Conversation
A registry tarball was fully buffered, then integrity-checked, then gunzipped and CAS-written. For the biggest packages that ordering is the worst possible one: on a shared link their bytes take the longest to arrive, so they finish downloading last, and their whole verify-extract cost lands **after the install's final byte**. On the official benchmark's trusted-lockfile row, the trailing package (highcharts, 9.3MB) paid ~71ms of checksum+extract after the wire went quiet — pure install tail. **The change**: a gzip body ≥ 1MiB whose resolution pins an integrity now feeds every arriving chunk to an incremental integrity hash (`ssri::IntegrityChecker`) and to the existing streaming extractor (`extract_tarball_entries_streaming`, already generic over `Read`) running on a blocking thread — the CPU work rides the gaps between chunks. Unpinned, sub-threshold, or non-gzip bodies keep the buffered path, selected by sniffing the gzip magic on the first bytes so a malformed body still reports the eager path's decode error. **Failure semantics** stay at the retry boundary exactly as before: mid-body network errors, malformed archives, and integrity mismatches all fail the attempt and re-fetch (each covered by a new test). One deliberate change: an integrity mismatch is now known only after entries were CAS-written from the unverified archive. Those are the same self-consistent, unreferenced files a crash mid-extract already leaves today — each is keyed by its own content hash, and the store-index row that would make any package reach them is only queued after the attempt returns `Ok`. **Measured** (trusted-lockfile row shape: 1346 packages, cold cache + cold store, 50ms RTT / 200 Mbit/s emulated link, 4 cores): **3263ms → 3172ms mean** over 8 paired runs (6/8 pairs faster); the trailing package's checksum lands 2–9ms after its last byte instead of 71ms. Part of the #14015 effort, alongside #14020 — together they remove the two biggest fixed slices of the cold-install tail.
…#14020) Closing the store-index writer's SQLite connection runs a WAL checkpoint, and both install paths awaited that close inline — after the last byte of the install had already landed, making it pure install tail. **Measured** (alotta-files fixture, 1346 packages, cold cache + cold store, trusted lockfile, 50ms RTT / 200 Mbit/s emulated link, 4 cores): the final `StoreIndexWriter::drain` blocked the install for **39–46 ms** — after every row had long been committed. The wait is the checkpoint SQLite runs when the last connection closes (verified by timing `drop(conn)` directly: `close_ms: 46`). The rest of the writer's work is negligible — the whole install's batched flushes total ~3 ms. Two designs were measured and rejected before this one: - `SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE`: skips the cost entirely, but breaks `open_immutable` consumers — an immutable open ignores the WAL, so a store whose last writer never checkpointed would look empty on a read-only filesystem (two existing store-dir tests catch exactly this). - Incremental passive checkpoints from the writer thread (every 256 rows): the close-time cost barely moved (46 → 34 ms) — it is dominated by a fixed fsync/unlink floor, not by WAL volume — while adding five mid-install checkpoints. So the fix moves the *wait*, not the work: the writer handles are dropped at the same points as before (the flush and close start just as early), but the `JoinHandle` now rides the install outputs up to the top-level install driver, which awaits it only after the `.modules.yaml` and lockfile writes the close can overlap with. Paired A/B on the benchmark row above: **−30 ms mean wall** (6/8 pairs faster); the win should be larger on CI runners where fsync is slower. An error path that returns before the final await just drops the handle: the teardown finishes detached, and an interrupted checkpoint is the crash case WAL recovery exists for. Part of the #14015 effort (official-benchmark trusted-lockfile row: pnpm 3.4s vs bun 3.0s over a 2.8s bandwidth floor — the gap is entirely lead-in + tail, and this removes a fixed slice of the tail).
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )