← Back to Pull requests

perf(install): map cached packuments, skip re-hashing unchanged ones and prefetch the OSV bloom #2016

Open
unknown opened this pull request with 593 lines diff across 7 files
View on GitHub
unknown unknown commented on Nov 30, 2026 22:05 UTC
Author

Repeat installs that reuse aube's packument cache (vlt's "cache" benchmark: no lockfile, no node_modules, warm cache) spent much of their resolve time copying and hashing cached packuments. Every warm read loaded each full packument into memory and recomputed its BLAKE3 digest before trusting the derived resolution index, so cost grew with packument size even when only a few releases were used.

This PR makes those installs 4–26% faster on vlt's fixtures and cuts their peak memory by more than half:

  • Cached packuments are memory-mapped on Unix instead of read whole. A resolve now pages in only the releases it decodes. Windows still reads the file, because a mapped file can't be renamed over by a concurrent install. aube only replaces cache entries by rename (atomic_write), so a mapped entry never shrinks under a running install.

  • The full-file digest is skipped when the file provably hasn't changed. The resolution index sidecar (now .resolution-index-v3) records the file's ctime and when its digest was last checked. The digest is trusted without re-hashing only when that check happened more than 2 seconds after the file's ctime, the same racy-clean rule git uses for its index. ctime can't be set by users, so any in-place rewrite moves it and forces a fresh hash. A file changed close to its last check is still hashed, and the first matching hash outside the window records the new check time. Non-Unix platforms always hash. derived_index_rejects_same_length_rewrite_with_unchanged_timestamp still passes, and a new test covers both sides of the window.

  • The per-release {/} peek is dropped from ResolutionIndex::into_resolution. The index is used only after the content is known to match, and that peek touched a page of the mapped file for every release.

  • The OSV bloom filter refreshes while the resolver runs for fresh installs that will be gated through it. The filter doesn't depend on the graph, so a cold cache (vlt's "clean" benchmark) no longer waits for that download after resolve. The gate awaits the prefetch, and falls back to refreshing itself if the prefetch panicked. When the install ends without reaching the gate (no new picks, an error, or a cancellation), the prefetch is aborted, so it never outlives the install in an embedder's runtime. --offline installs never start it.
  • Benchmarks

    vlt's fixtures, aube install --ignore-scripts --silent with CI=true (global virtual store off, as on vlt's runners), release build, 4-vCPU Linux VM. The base is main at 4741bcb. Runs are interleaved round-robin because this VM's load drifts too much for back-to-back hyperfine blocks. Times are median wall seconds.

    cache (warm ~/.cache/aube and store, no lockfile or node_modules; 10 rounds):

    | fixture | main | this PR | change | bun |
    |---|---|---|---|---|
    | astro | 0.69 | 0.62 | −9% | 0.24 |
    | babylon | 4.94 | 4.72 | −4% | 4.25 |
    | large | 2.93 | 2.75 | −6% | 1.08 |
    | next | 1.10 | 1.04 | −5% | 0.45 |
    | svelte | 0.26 | 0.19 | −26% | 0.08 |
    | vue | 1.21 | 1.06 | −13% | 0.41 |

    Resolve phase (AUBE_DIAG_SUMMARY, 12 interleaved rounds): next 362 → 191 ms, large 415 → 274 ms. Peak RSS on next: 681 → 280 MB.

    clean (store and caches wiped every run; 5 rounds, 3 for babylon): astro 2.65 → 2.67, babylon 16.6 → 18.1, large 5.80 → 5.69, next 4.90 → 4.98, svelte 1.13 → 1.16, vue 2.64 → 2.57. These differences are within this VM's noise. The bloom prefetch can't be measured here because the proxy blocks the OSV hosts, so these runs used AUBE_ADVISORY_CHECK=off.

    What's left

    Most of the remaining "cache" gap to bun is materializing the per-project .aube/ tree: about 750 ms of hard links on next and 1.6 s on large. Lowering link parallelism (2/4/8/64 permits) made no difference to wall time, so that needs a different approach.

    AI-assisted — Tool: Claude Code; model: anthropic/claude-opus-5-5; version: unavailable.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Improvements
    Dependency resolution reuses cached package metadata more efficiently while checking that cached data remains valid.
    On supported systems, package metadata can be read more efficiently; other platforms retain their existing read behavior.
    Security advisory data can begin refreshing during eligible online dependency resolutions. Checks refresh again before use if the early refresh fails or the data is no longer fresh.
    * Cached security advisory data is checked for freshness and consistency before it is reused.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    ---
    _Generated by Claude Code_

    Diff: 593 lines (+444 / -149) across 7 files Reviewer: jdx Review duration: 294m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.50) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 593 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.382
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #2016"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50% (MEDIUM) · Higher = larger blast radius
    50%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26.7% · Safe to merge
    26.7%
    Repository