Commit Graph

4 Commits

Author SHA1 Message Date
Zoltan Kochan
a9fc72c3ed refactor: simplify to single-table schema
Replace the two-table design (metadata_index + metadata_blobs) with a
single metadata table storing etag, modified, cached_at, is_full flag,
and the raw JSON blob.

The separate index table added complexity without meaningful benefit —
we parse the full blob anyway to extract the resolved version's manifest
after picking. The single table keeps writes simple (1 INSERT with the
raw registry response) and reads simple (1 SELECT + JSON.parse).

The is_full flag ensures that abbreviated-only cache entries are not
served when full metadata is requested (e.g., for optional dependencies).
2026-04-01 17:31:57 +02:00
Zoltan Kochan
d09d9d8efb perf: store raw JSON blob instead of per-version manifests
Replace metadata_manifests (per-version rows requiring JSON.stringify
per manifest) with metadata_blobs (single raw JSON blob per package).

Write path: store the raw registry response text as-is — zero
serialization on the hot path. Only the compact index fields
(dist-tags, version keys, deprecated flags) are extracted.

Read path: parse the lightweight index for version picking, then
parse the blob and extract just the resolved version's manifest.

This eliminates the cold install regression caused by hundreds of
JSON.stringify calls per install. The index table still provides
cheap header lookups for conditional requests.

Also tracks is_full flag on the index to avoid serving abbreviated
metadata when full is requested (e.g., for optional dependencies).
2026-04-01 17:19:04 +02:00
Zoltan Kochan
d36a005dc5 perf: decompose metadata cache into index + per-version manifests
Split the single-blob metadata storage into two tables:
- metadata_index: dist-tags, version keys (with deprecated), time, and
  cache headers — one row per package, ~10KB
- metadata_manifests: per-version manifest objects, keyed by (name,
  version, type) — ~2KB each

During resolution, only the lightweight index is parsed to pick a
version. The full manifest for the resolved version is loaded separately.
For a package like typescript with 200+ versions, this avoids parsing
~400KB of unused manifest JSON.

The index is shared across abbreviated/full metadata types — only the
per-version manifests differ. This eliminates the type column from the
index and simplifies the abbreviated→full fallback to the manifest level.
2026-04-01 15:32:15 +02:00
Zoltan Kochan
89ea578e68 perf: replace file-based metadata cache with SQLite
Replace the per-package JSON file cache (metadata-v1.4/, metadata-ff-v1.4/)
with a single SQLite database (metadata.db) for registry metadata caching.

Benefits:
- Cheap conditional request header lookups (etag/modified) without parsing
  the full metadata JSON — enables If-None-Match/If-Modified-Since with
  minimal I/O overhead
- Full metadata can serve abbreviated requests — if a package was previously
  fetched as full (e.g., for trustPolicy or resolutionMode), the resolver
  reuses it instead of making another registry request
- Eliminates hundreds of individual file read/write/rename operations per
  install, replaced by SQLite WAL-mode transactions
- Removes the runLimited/metafileOperationLimits concurrency machinery —
  SQLite handles concurrent access natively

New package: @pnpm/cache.metadata — SQLite-backed MetadataCache class
modeled after @pnpm/store.index, with getHeaders() for cheap lookups,
get() with abbreviated→full fallback, and set()/updateCachedAt().
2026-04-01 14:54:13 +02:00