bug: pnpm cache hits provide little install speedup because lockfile verification is not cached

Offen
#1,672 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 7 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
52/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
github-actions, node.js, typescript
Bereich
ci-cd, devops

Rechercherichtung

Read the pnpm cache handling in actions/setup-node and trace how it resolves, restores, and saves the package store cache. Check the existing tests for pnpm caching, then identify how a separate key can use the OS, architecture, and lockfile hash while keeping failures non-fatal. Done when the verification log is independently restored and saved, including on a store cache hit, with npm and Yarn behavior unchanged.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug needs triage

Description

With pnpm 11+, actions/setup-node's cache: pnpm can provide little or no installation speedup, even when the cache is successfully restored.

The reason is that setup-node caches only pnpm's package store, while pnpm stores lockfile verification results separately in <cacheDir>/lockfile-verified.jsonl.

These results allow pnpm to avoid repeating registry-backed verification of lockfile entries, including integrity checks and applicable supply-chain policies such as minimumReleaseAge and trustPolicy.

Because the verification log is not included in the cache, every CI job repeats the verification, even when the package store is fully cached and the lockfile is unchanged.

In workloads where verification dominates installation time, the store cache becomes largely ineffective.

Action version

actions/[email protected]

Platform

  • Ubuntu
  • macOS
  • Windows

Runner type

  • Hosted
  • Self-hosted

Tools version

  • pnpm: 12.16.1
  • Node.js: Not recorded
  • Lockfile: Approximately 2,000 entries (868 KB)
  • Configuration:
    • minimumReleaseAge: 1440
    • trustPolicy: no-downgrade

Repro steps

  1. Configure actions/setup-node with cache: pnpm in a repository using pnpm 12 and the supply-chain policies above.
  2. Run pnpm install --frozen-lockfile.
  3. Run the workflow again without changing the lockfile.
  4. Confirm that the package store cache is restored successfully.
  5. Compare installation times with and without the cache, and with the lockfile verification log restored separately.
Measurements
Scenario Result
GitHub Actions, warm store (27 install jobs) 13–22s/job, 392s total
Cold install without any cache 13–14s
Controlled test: warm store, verification log missing 26s
Controlled test: warm store, verification log restored 20s
Parallel CI fleet (25 jobs), before → after Median 32s → 18s; aggregate 818s → 455s

Despite a successful store cache hit, installation time was comparable to a completely uncached installation.

Restoring the verification log reduced dependency setup time by approximately 6 seconds per job in the controlled experiment.

The fleet-level improvement was larger, although it also included other configuration changes.

Similar results were reported in pnpm/setup#30: lockfile verification accounted for 16.6 of 17.6 seconds on Linux and 40.1 of 42.4 seconds on Windows.

Expected behavior

When the lockfile is unchanged and previously computed verification results remain valid, cache: pnpm should reuse those results along with the package store.

A successful cache hit should avoid redundant verification work, allowing subsequent installations to benefit from caching.

Actual behavior

setup-node restores only the package store.

The lockfile verification log is never restored, so pnpm repeats registry-backed verification on every job.

As a result, cache: pnpm provides almost no performance benefit in workloads dominated by lockfile verification, despite reporting successful cache hits.

Suggested solution

Cache <cacheDir>/lockfile-verified.jsonl independently of the package store.

  1. Resolve the cache directory using pnpm cache path, available in pnpm 12. If unavailable, retain the existing behavior.
  2. Use a separate cache key, incorporating the OS, architecture, and lockfile hash, without prefix-based fallback.
  3. Restore the verification log independently of whether the package store cache hits or misses.
  4. Save the verification log even when the package store cache hits. The current implementation skips saving on an exact store cache hit. Simply adding this file to the existing store cache paths would not populate verification logs for existing cache entries.
  5. Keep failures non-fatal. A missing or unusable verification cache should cause pnpm to perform its normal verification.
  6. Leave npm and Yarn unchanged.

Only the verification log should be cached, rather than the entire pnpm cache directory.

Security considerations

Restoring the verification log does not bypass pnpm's supply-chain protections.

pnpm itself determines whether previously recorded verification results can be trusted for the current lockfile and policy configuration. Unusable results trigger normal verification.

This approach is already implemented by pnpm/setup.

References

Vorherrschende Sprache
TypeScript
Sterne
5k
Forks
1.7k
Ø Merge
5 T. 1 Std.
Gemergte PRs (30 T.)
1

Entwicklungsumgebung

  • Kein Dockerfile und keine Docker-Compose-Datei
  • Hat eine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus actions/setup-node

Alle Issues in actions/setup-node

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.