Skip to content

integrated-benchmark: add a cold pnpr resolution-cache scenario #31

Closed
pnpm/pnpm
#16246

Description

@zkochan

Summary

Every integrated-benchmark scenario measures the pnpr accelerator with a hot resolution cache. The accelerator's pnpr-storage (its resolution + packument cache) is wiped once in WorkEnv::benchmark()'s upfront wipe, primed by the hyperfine warmup run, and never wiped per iteration — so every timed iteration hits a warm accelerator. The "cold" dimensions in the scenario names are all client-side (the client's packument cache and CAS store), plus the mock's tarball cache in the new …cold-store.cold-pnpr scenario.

So one cold dimension is untested: a cold pnpr resolution cache — the accelerator having to rebuild a resolve response from cold packuments (refetching them from origin) rather than answering from its warm cache.

Cold dimension Covered
Client packument cache (cold-cache) ✅
Client CAS store (cold-store) ✅
pnpr tarball cache (cold-pnpr) ✅ (pnpm/pnpm#12729)
pnpr resolution cache ❌

Why it matters

The pnpr accelerator's win is resolution offload, and that path has an auth-aware resolution cache (pnpm/pnpm#12700). A cold-resolution scenario would measure (and guard against regressions in) the accelerator's cold-start resolution cost — the first request after a deploy/restart, or for a package the server hasn't resolved yet.

Proposed scenario

A fresh-install scenario (resolution must run — a frozen lockfile would skip it) that wipes the accelerator's pnpr-storage per iteration, so each timed run forces the accelerator to resolve from a cold packument cache:

  • Add pnpr-storage to the scenario's per-iteration cleanup.remove (today it's only in the one-time upfront wipe).
  • Keep the client cold too (fresh-install.cold-cache.cold-store) or warm — TBD; the point is the server's resolution cache is cold each iteration.
  • Bencher consumes pnpr@HEAD; the metric is the accelerator's cold-resolution latency.

Note: this is the resolution path, orthogonal to the tarball-streaming work in pnpm/pnpm#12729 — it guards pnpm/pnpm#12700's territory, so it belongs in its own change.

Context

Came out of the proxy-tarball streaming PR (pnpm/pnpm#12729), which added the cold tarball cache scenario; this is the matching cold resolution cache scenario.


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

Activity

  1. transferred this issue frompnpm/pnpmon Sep 26, 2026
  2. officialaritro commented on Sep 26, 2026

    @officialaritro

    I would like to work on this.

    I read the code and tested it with a local pnpr server. The proposed fix does not make the pnpr resolution cache cold. There are two problems:

    1. pnpr keeps its caches in memory, including the resolution cache (the entries map in pnpr/crates/pnpr/src/resolver.rs). The pnpr server runs for the whole benchmark. When I deleted pnpr-storage while the server ran, the next install took 1.7 s. A warm install took 1.7 s, and a cold install took 12.7 s.
    2. The benchmark puts htpasswd in pnpr-storage, and pnpr puts tokens.db next to it. So we must restart the server to clear the memory. But after a restart with an empty pnpr-storage, the client gets 401 Unauthorized.

    Test setup: the benchmark fixture, pnpr and pnpm built from main (a8994c61d8), the npm registry, a hot client store and an empty client cache.

    My plan:

    1. Move the benchmark's htpasswd path out of pnpr-storage, for example to <bench_dir>/pnpr-auth/htpasswd. tokens.db follows it. I tested this layout: after a restart with an empty pnpr-storage, the old token still works and the install is cold again. I will also run one existing pnpr scenario before and after, to show that the numbers do not change.
    2. Add a scenario isolated-linker.fresh-install.cold-cache.hot-store.cold-pnpr-resolve. The client store stays hot, so the only variable cost is resolution on the pnpr server.
    3. In --prepare for that scenario, stop the pnpr server, delete pnpr-storage, start the server again on the same port, and wait until it is ready. In my test, the restart took about 0.04 s.

    Questions:

    1. Do you agree with the scenario name, or do you prefer a different one?
    2. Is restarting the pnpr server in --prepare acceptable? Or do you prefer a different way to clear the in-memory cache?
  3. added a commit that references this issue on Nov 21, 2026
    dcf7a3c
  4. added a commit that references this issue on Nov 21, 2026
    97275ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions