Skip to content

pnpr: store only the zstd tar for hosted tar registries #226

Closed

Description

@zkochan

Decided on 2026-10-27 while discussing pnpr's level-19 zstd variant cache (pnpr/crates/pnpr/src/server/tar_variants.rs).

Hosted registries with tarballs: tar

  • Store only the tar, compressed with zstd at level 19 when the version is published, plus its tar hash (.tar-integrity/). Don't store the published .tgz.
  • At startup, reject a config where a router without tarballs: tar lists such a registry as a source. That router would serve .tgz files that don't exist.
  • Serve zstd clients the stored bytes. Decode them for clients that accept only gzip, which get them re-gzipped as they stream, and for clients that accept no compression.
  • What stops working for these packages, all of which tar registries already lack: installs with npm, Yarn and pnpm older than 12.15, npm signatures and provenance (both sign the .tgz digest), and a byte-identical .tgz from pnpr export.
  • Their tars no longer go through the per-replica variant cache.

Other hosted registries

  • Keep the published .tgz. Its sha512 is the dist.integrity that clients, lockfiles and provenance pin, and gzip can't reproduce the same bytes from the tar.
  • Optional: also store the level-19 .tar.zst next to the .tgz at publish, maybe in the background, so the first zstd request doesn't stream at level 3 and no replica has to compress it again.

Rejected

  • Serving a .tgz re-gzipped by pnpr and hashed by pnpr. The hash in every lockfile would change whenever the gzip library changes its output (Yarn Berry's compressionLevel checksum churn), and provenance would stop verifying.
  • Any layout-version bump or migration. pnpr is experimental.

Upstream packages keep the disposable variant cache. pnpr doesn't own their bytes.


Written by an agent (Claude Code, claude-opus-5-5).

Activity

  1. zkochan commented on Oct 27, 2026

    @zkochan
    MemberAuthor

    Version-to-version deltas were measured and dropped. On 38 forward same-major upgrades of popular packages, the whole tar compressed with zstd --patch-from against the previous version's files was 3.9% of the level-19 tar (median 4.2%). Sending only the changed files was 33% (median 57%), because bundled builds rewrite most files every release. The gain applies only to updates on a warm store, which already average under 1.5 MiB as level-19 tars. Delivering it needs a dictionary rebuilt from the store, zstd windows past pnpm's 8 MiB limit (184 MB for Next.js), a per-pair delta cache on the server, and Cloudflare's shared dictionaries, which are still in beta. That isn't worth it. Storing the level-19 tar, as this task describes, helps cold installs too.


    Written by an agent (Claude Code, claude-opus-5-5).

  2. zkochan commented on Nov 8, 2026

    @zkochan
    MemberAuthor

    pnpm/pnpm#17437 stores only the level-19 zstd tar for hosted tar registries and rejects the bad router config at startup. Only the optional item was left.

    Written by an agent (Claude Code, claude-opus-5-5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions