Skip to content

bench(micro-benchmark): isolate the packument and lockfile parse paths - #12950

Merged
zkochan merged 5 commits into
mainfrom
claude/pnpm-micro-benchmarks-ndness
Jul 12, 2026
Merged

zkochan merged 5 commits into
mainfrom
claude/pnpm-micro-benchmarks-ndness

Conversation

@KSXGitHub

@KSXGitHub KSXGitHub commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two micro-benchmarks are added to the pnpm/tasks/micro-benchmark task that isolate the CPU-bound parse hot paths pacquet's own code owns, so a regression in pacquet's parsing is caught here instead of only in the combined tarball/download_dependency pipeline bench — which mixes HTTP, tokio, and filesystem work and cannot attribute a slowdown to a single step.

  • packument/parse deserializes a registry packument into pacquet_registry::Package, then picks and hydrates a version — the metadata parse Package::fetch_from_registry performs on the resolve hot path, minus the network. It exercises PackageVersions' lazy fragment capture and PackageVersion hydration, so it also guards that laziness: a change that eagerly hydrates every version would surface here as a parse blowup.
  • lockfile/parse_pnpm_lock parses the integrated-benchmark's real 12k-line pnpm-lock.yaml through pacquet_lockfile::Lockfile::load_wanted_from_dir, covering extract_main_document and the lockfile's custom deserializers.

Both are throughput benches over committed fixtures, so the suite runs from a clean checkout. The packument bench reads a committed abbreviated lodash packument (application/vnd.npm.install-v1+json, the metadata format pacquet fetches during resolution); the lockfile bench reuses the existing integrated-benchmark fixture. The packument fixture's base64 signature blobs are excluded from typos.

Squash Commit Body

Add two micro-benchmarks that isolate the CPU-bound parse hot paths
pacquet owns, complementing the combined download_dependency pipeline
bench with per-path attribution:

- packument/parse deserializes a registry packument into
  pacquet_registry::Package and picks + hydrates a version, exercising
  PackageVersions' lazy fragment capture and PackageVersion hydration.
  Because that parse is lazy, the bench also guards the optimization: a
  change that eagerly hydrates every version surfaces as a parse blowup.
- lockfile/parse_pnpm_lock parses the integrated-benchmark's 12k-line
  pnpm-lock.yaml via pacquet_lockfile, covering extract_main_document
  and the lockfile's custom deserializers.

Both run over committed fixtures: a new abbreviated lodash packument
(the application/vnd.npm.install-v1+json metadata pacquet fetches
during resolution) and the existing integrated-benchmark lockfile. The
packument fixture's base64 signature blobs are excluded from typos.

Checklist

  • Benchmark-only Rust dev tooling — no user-visible surface, so there is nothing to port to the TypeScript CLI.
  • No changeset needed: this touches only the micro-benchmark dev task (publish = false), not any published package.
  • No tests apply — the change adds benchmarks, not behavior under test.
  • No documentation changes needed.

Written by an agent (Claude Code).

Summary by CodeRabbit

  • Performance
    • Added micro-benchmarks for package metadata and lockfile parsing.
    • Expanded benchmark coverage with realistic lodash registry data and lockfile fixtures.
  • Maintenance
    • Updated tooling configuration to exclude the new fixture from typo checks.
    • Added required support for parsing package metadata and lockfiles.

Add four benches that isolate the individual CPU sinks on the
install/resolve path, so a performance change (such as an LTO or
release-profile tweak) can be attributed per sink instead of only to the
combined tarball-download bench:

- inflate/gunzip_tarball: zune-inflate, mirroring the DeflateOptions of
  pacquet_tarball::decompress_gzip.
- integrity/sha512_{compute,check}: ssri -> sha2, the whole-tarball
  integrity verify taken under the default verify-store-integrity=true.
- json/packument_parse_value: serde_json parse of a committed abbreviated
  lodash packument (the metadata format pacquet fetches during
  resolution).
- lockfile/parse_pnpm_lock: pacquet_lockfile parse of the
  integrated-benchmark's 12k-line pnpm-lock.yaml.

The JSON fixture is committed so the suite runs from a clean checkout;
its base64 signature blobs are excluded from typos.
@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ea74bc78-bfce-4a44-9690-8b8472d003ce

📥 Commits

Reviewing files that changed from the base of the PR and between 3acb421 and 7e276fe.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (4)
  • .typos.toml
  • pnpm/tasks/micro-benchmark/Cargo.toml
  • pnpm/tasks/micro-benchmark/fixtures/lodash.json
  • pnpm/tasks/micro-benchmark/src/main.rs

📝 Walkthrough

Walkthrough

Adds packument JSON and lockfile parsing benchmarks to the micro-benchmark crate, including required dependencies, fixtures, setup, and typo-check exclusions.

Changes

Micro-benchmarking

Layer / File(s) Summary
Benchmark fixtures and dependencies
.typos.toml, pnpm/tasks/micro-benchmark/Cargo.toml, pnpm/tasks/micro-benchmark/fixtures/lodash.json
Adds pacquet-lockfile and serde_json, introduces a lodash registry manifest fixture, and excludes the fixture from typo checking.
Parsing benchmark wiring
pnpm/tasks/micro-benchmark/src/main.rs
Adds packument JSON parsing and lockfile loading benchmarks, loads their fixtures, and registers both alongside the existing tarball benchmark.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • pnpm/pnpm#11635: Both changes involve micro-benchmark fixture loading and paths.
  • pnpm/pnpm#12915: The typo exclusion affects checks used by the related pre-push hook.

Suggested labels: product: pacquet

Suggested reviewers: zkochan

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/pnpm-micro-benchmarks-ndness

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock                                              1.00     24.1±0.08ms    15.5 MB/sec
packument/parse                                                       1.00     82.0±1.20µs   809.0 MB/sec
tarball/download_dependency    1.00      6.7±0.08ms   647.8 KB/sec    1.11      7.4±0.35ms   586.1 KB/sec

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.59%. Comparing base (4658133) to head (2e41146).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12950      +/-   ##
==========================================
+ Coverage   85.45%   85.59%   +0.14%     
==========================================
  Files         474      475       +1     
  Lines       74561    74829     +268     
==========================================
+ Hits        63714    64048     +334     
+ Misses      10847    10781      -66     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 7e276fec35e2

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.946 ± 0.189 3.708 4.275 1.88 ± 0.14
pacquet@main 3.830 ± 0.094 3.696 4.021 1.82 ± 0.11
pnpr@HEAD 2.101 ± 0.113 1.959 2.302 1.00
pnpr@main 2.159 ± 0.126 2.028 2.373 1.03 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.9457545879000007,
      "stddev": 0.18910601812582395,
      "median": 3.9367587043,
      "user": 3.6650652799999994,
      "system": 3.4582645199999993,
      "min": 3.7083812003000003,
      "max": 4.2754946113,
      "times": [
        4.2754946113,
        3.7550427983000003,
        3.9775244053,
        4.138540026299999,
        4.0079003672999995,
        3.7499781853000003,
        3.8403176143000004,
        3.7083812003000003,
        3.8959930033,
        4.1083736672999995
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.8297781100000003,
      "stddev": 0.09380304184772806,
      "median": 3.8025966993000004,
      "user": 3.6620402800000003,
      "system": 3.4620019199999996,
      "min": 3.6956853193000003,
      "max": 4.0207569353,
      "times": [
        3.8120020583,
        4.0207569353,
        3.9200662903000003,
        3.7724477313,
        3.7667289013,
        3.9054076083,
        3.6956853193000003,
        3.7858221983,
        3.7931913403000004,
        3.8256727173000002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.1005120477000006,
      "stddev": 0.11277081144373087,
      "median": 2.0667803593,
      "user": 2.67515338,
      "system": 3.05942412,
      "min": 1.9586665163,
      "max": 2.3016173283000003,
      "times": [
        2.0353252143000002,
        2.3016173283000003,
        2.1081819863,
        2.2873998173000003,
        2.0266069413000003,
        1.9586665163,
        2.0303980553,
        2.1233638993,
        2.0939909043,
        2.0395698143
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.1594348574,
      "stddev": 0.12631185740197345,
      "median": 2.1199436968,
      "user": 2.70004528,
      "system": 3.1063778199999996,
      "min": 2.0282824063000002,
      "max": 2.3727949843,
      "times": [
        2.1110477473,
        2.2371169603000003,
        2.0494383003000003,
        2.1288396463,
        2.0282824063000002,
        2.3727949843,
        2.1510930613,
        2.0872724213000002,
        2.0590297583,
        2.3694332883
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 663.8 ± 15.1 641.2 689.4 1.01 ± 0.03
pacquet@main 657.9 ± 9.1 646.8 674.4 1.00
pnpr@HEAD 739.5 ± 100.0 676.0 1015.6 1.12 ± 0.15
pnpr@main 743.7 ± 125.2 686.7 1096.9 1.13 ± 0.19
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6637713844,
      "stddev": 0.01505110107820184,
      "median": 0.6627911542,
      "user": 0.3830661799999999,
      "system": 1.3483070599999998,
      "min": 0.6412032572,
      "max": 0.6894276452,
      "times": [
        0.6819251622,
        0.6708942332000001,
        0.6600954512,
        0.6690784382,
        0.6622776192000001,
        0.6894276452,
        0.6412032572,
        0.6633046892000001,
        0.6445650692,
        0.6549422792
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6579316765,
      "stddev": 0.009101956447197721,
      "median": 0.6573450647000001,
      "user": 0.38925647999999996,
      "system": 1.3441478599999999,
      "min": 0.6468162672000001,
      "max": 0.6744287842000001,
      "times": [
        0.6519115332000001,
        0.6709711242,
        0.6568231312,
        0.6521035212,
        0.6601160462000001,
        0.6744287842000001,
        0.6480198802,
        0.6578669982,
        0.6602594792,
        0.6468162672000001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.7394661149000001,
      "stddev": 0.09997988309546649,
      "median": 0.7114352022000001,
      "user": 0.40075848000000003,
      "system": 1.3790562599999998,
      "min": 0.6760240822,
      "max": 1.0156358642,
      "times": [
        0.6760240822,
        0.6815178502,
        0.7414787222,
        0.7040483092,
        0.7521902362,
        0.7121624752000001,
        0.7113513032000001,
        0.6887332052,
        0.7115191012000001,
        1.0156358642
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7436727838999999,
      "stddev": 0.1252174807537916,
      "median": 0.7017878202000001,
      "user": 0.39915157999999995,
      "system": 1.3614042599999998,
      "min": 0.6867138232000001,
      "max": 1.0968613571999999,
      "times": [
        0.7432103052000001,
        0.6950588792,
        0.7027162142000001,
        0.7030979632000001,
        0.6932548932,
        0.7008594262000001,
        0.6867138232000001,
        0.6925470252,
        1.0968613571999999,
        0.7224079522
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.410 ± 0.084 4.301 4.567 1.98 ± 0.10
pacquet@main 4.316 ± 0.057 4.221 4.402 1.94 ± 0.09
pnpr@HEAD 2.229 ± 0.099 2.064 2.350 1.00
pnpr@main 2.239 ± 0.109 2.118 2.440 1.00 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.40950950284,
      "stddev": 0.08443709673383475,
      "median": 4.412330514939999,
      "user": 3.877696640000001,
      "system": 3.5325853799999996,
      "min": 4.30119054594,
      "max": 4.56685336994,
      "times": [
        4.33655038894,
        4.411510026939999,
        4.4533962549399995,
        4.56685336994,
        4.413151002939999,
        4.4778203969399994,
        4.31528832294,
        4.3510750389399995,
        4.46825967994,
        4.30119054594
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.31573698544,
      "stddev": 0.05747561426933153,
      "median": 4.31952281194,
      "user": 3.8292120400000007,
      "system": 3.4531951800000007,
      "min": 4.22126989294,
      "max": 4.40176963494,
      "times": [
        4.40176963494,
        4.359625493939999,
        4.33750328794,
        4.37847248094,
        4.34046704894,
        4.290887650939999,
        4.22126989294,
        4.30154233594,
        4.2574851449399995,
        4.2683468829399995
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.2287233524400003,
      "stddev": 0.09893138871968221,
      "median": 2.2075582319400002,
      "user": 2.54614034,
      "system": 3.02827458,
      "min": 2.06390412994,
      "max": 2.3500591979400003,
      "times": [
        2.1615065439400003,
        2.06390412994,
        2.21342690294,
        2.34203257394,
        2.3500591979400003,
        2.34312709894,
        2.29580879894,
        2.2016895609400002,
        2.1687794619400003,
        2.14689925494
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.23913206014,
      "stddev": 0.10927030703967279,
      "median": 2.23702844494,
      "user": 2.5697678400000004,
      "system": 3.0176592799999997,
      "min": 2.1179159529400002,
      "max": 2.44017863494,
      "times": [
        2.2654114019400002,
        2.16654507494,
        2.1179159529400002,
        2.44017863494,
        2.36561151194,
        2.1180522729400004,
        2.2716546649400002,
        2.13832802694,
        2.20864548794,
        2.29897757194
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.408 ± 0.018 1.382 1.435 2.06 ± 0.04
pacquet@main 1.423 ± 0.072 1.379 1.624 2.08 ± 0.11
pnpr@HEAD 0.685 ± 0.009 0.672 0.704 1.00
pnpr@main 0.701 ± 0.042 0.682 0.819 1.02 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.40837204924,
      "stddev": 0.018087064409977687,
      "median": 1.4076976077399999,
      "user": 1.3542851999999999,
      "system": 1.7433890399999996,
      "min": 1.38171303024,
      "max": 1.43455777224,
      "times": [
        1.39518627524,
        1.4049718312400001,
        1.43114629024,
        1.43455777224,
        1.40804123224,
        1.40735398324,
        1.4195288212400001,
        1.41789777324,
        1.38171303024,
        1.38332348324
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.4234458503399998,
      "stddev": 0.07241411281628546,
      "median": 1.4017514052400002,
      "user": 1.3719899999999998,
      "system": 1.7294801399999997,
      "min": 1.37897230724,
      "max": 1.62398110924,
      "times": [
        1.42889379324,
        1.40267367124,
        1.62398110924,
        1.42560224224,
        1.37923957324,
        1.39843319124,
        1.40632266424,
        1.37897230724,
        1.38951081224,
        1.40082913924
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.68469624434,
      "stddev": 0.009332617669691892,
      "median": 0.68572379074,
      "user": 0.3473575,
      "system": 1.31950274,
      "min": 0.6717216352400001,
      "max": 0.70397973524,
      "times": [
        0.67267206024,
        0.68893132924,
        0.68449380624,
        0.70397973524,
        0.68168430624,
        0.68695377524,
        0.68990243224,
        0.6717216352400001,
        0.68755560124,
        0.67906776224
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.70100685344,
      "stddev": 0.04173533386071714,
      "median": 0.6889562282400001,
      "user": 0.3477552,
      "system": 1.3205662399999998,
      "min": 0.6819399582400001,
      "max": 0.8189078792400001,
      "times": [
        0.6874412322400001,
        0.6914040302400001,
        0.6904712242400001,
        0.69801334224,
        0.68226180924,
        0.68439839224,
        0.68372558524,
        0.8189078792400001,
        0.69150508124,
        0.6819399582400001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.102 ± 0.029 3.057 3.148 4.39 ± 0.08
pacquet@main 3.077 ± 0.061 2.991 3.177 4.35 ± 0.11
pnpr@HEAD 0.707 ± 0.012 0.690 0.727 1.00
pnpr@main 0.714 ± 0.095 0.667 0.980 1.01 ± 0.14
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.1019031198400002,
      "stddev": 0.02932786166056645,
      "median": 3.1024727723399996,
      "user": 1.8224875199999997,
      "system": 2.00042718,
      "min": 3.05652340834,
      "max": 3.1477461823399997,
      "times": [
        3.1428596023399997,
        3.11789327334,
        3.10647947534,
        3.07729375634,
        3.07726204134,
        3.05652340834,
        3.0838691143399997,
        3.1477461823399997,
        3.0984660693399997,
        3.11063827534
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.07744070564,
      "stddev": 0.06129397123424937,
      "median": 3.0688856198399996,
      "user": 1.8021011200000001,
      "system": 2.00938468,
      "min": 2.9912430673399997,
      "max": 3.17675503034,
      "times": [
        3.0191889973399997,
        3.03319938234,
        2.9912430673399997,
        3.0646400943399996,
        3.03304611434,
        3.0731311453399996,
        3.1088853673399997,
        3.11601623234,
        3.17675503034,
        3.15830162534
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.70731643164,
      "stddev": 0.011898397863031073,
      "median": 0.7066965013400002,
      "user": 0.35980492,
      "system": 1.3627046799999998,
      "min": 0.68954594434,
      "max": 0.7268709713400001,
      "times": [
        0.70115425334,
        0.70983571034,
        0.7057194433400001,
        0.69180773634,
        0.70284149234,
        0.7198669363400001,
        0.7076735593400001,
        0.7178482693400001,
        0.68954594434,
        0.7268709713400001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7138268733400001,
      "stddev": 0.0948244210655676,
      "median": 0.68136120284,
      "user": 0.35735422,
      "system": 1.3189711800000001,
      "min": 0.66651581534,
      "max": 0.9797505783400001,
      "times": [
        0.6746085323400001,
        0.6852280793400001,
        0.6774943263400001,
        0.6764935283400001,
        0.6885517953400001,
        0.6711376723400001,
        0.66651581534,
        0.9797505783400001,
        0.7233559583400001,
        0.6951324473400001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 680.8 ± 19.8 654.8 724.2 6.23 ± 0.22
pacquet@main 707.3 ± 15.0 690.7 740.5 6.47 ± 0.19
pnpr@HEAD 109.5 ± 2.2 107.1 114.0 1.00 ± 0.03
pnpr@main 109.2 ± 2.3 107.1 113.4 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6807774616600001,
      "stddev": 0.01980551757234718,
      "median": 0.67621049686,
      "user": 0.6513288,
      "system": 0.14931853999999997,
      "min": 0.6547592373600001,
      "max": 0.7242178663600001,
      "times": [
        0.6745785563600001,
        0.6715205843600001,
        0.6757007903600001,
        0.65939038136,
        0.6547592373600001,
        0.68382767436,
        0.69152820636,
        0.6955311163600001,
        0.67672020336,
        0.7242178663600001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.7073018444600001,
      "stddev": 0.015049690440038418,
      "median": 0.7057447533600001,
      "user": 0.6752049,
      "system": 0.15513493999999997,
      "min": 0.69067583036,
      "max": 0.7404504873600001,
      "times": [
        0.7177363803600001,
        0.70052381236,
        0.71164381736,
        0.7404504873600001,
        0.7108975593600001,
        0.71379493636,
        0.69304342836,
        0.7005919473600001,
        0.69067583036,
        0.69366024536
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.10947657348,
      "stddev": 0.0021690299927615755,
      "median": 0.10816331236,
      "user": 0.030095119999999996,
      "system": 0.019216379999999998,
      "min": 0.10710216636,
      "max": 0.11396232836,
      "times": [
        0.11058659536000001,
        0.10785745236000001,
        0.10781359136,
        0.10776327436000001,
        0.10780967236000001,
        0.10858623136000001,
        0.10784486336,
        0.11215082036,
        0.10776029236000001,
        0.10765136936,
        0.10814879436000001,
        0.10865129036,
        0.11220520336,
        0.10778274636,
        0.11245295236000001,
        0.11276916336000001,
        0.11170494236,
        0.10739393336,
        0.10881485736,
        0.11230895836,
        0.11396232836,
        0.11151190936000001,
        0.10710216636,
        0.10816331236,
        0.10811761636
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.10924308407999998,
      "stddev": 0.0022663845849885665,
      "median": 0.10817684536000001,
      "user": 0.027921240000000003,
      "system": 0.0211123,
      "min": 0.10706715236,
      "max": 0.11339367636,
      "times": [
        0.10730088036,
        0.10815196136,
        0.10758465436,
        0.10790936236000001,
        0.10821316536,
        0.10706715236,
        0.10859068536000001,
        0.10816393036000001,
        0.10754022936,
        0.10835270736000001,
        0.10764190536,
        0.10803012736,
        0.10852423836000001,
        0.10715102936000001,
        0.10746462936000001,
        0.10841543536,
        0.10772169636000001,
        0.10817684536000001,
        0.11246584336000001,
        0.11339367636,
        0.11289713836000001,
        0.11218272536,
        0.11330599036000001,
        0.11275809636,
        0.11207299636000001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.810 ± 0.144 6.573 7.034 1.33 ± 0.04
pacquet@main 6.850 ± 0.148 6.585 7.059 1.34 ± 0.04
pnpr@HEAD 5.120 ± 0.100 4.988 5.299 1.00
pnpr@main 5.198 ± 0.136 5.031 5.504 1.02 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.809525164939998,
      "stddev": 0.14354556201625776,
      "median": 6.79258018764,
      "user": 3.975571,
      "system": 3.8102275400000005,
      "min": 6.57349906014,
      "max": 7.03405276014,
      "times": [
        6.66557745214,
        6.57349906014,
        6.73747560314,
        6.845115402139999,
        6.8841131211399995,
        7.01309809414,
        6.82280058814,
        6.7571597811399995,
        7.03405276014,
        6.762359787139999
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.84994139714,
      "stddev": 0.14784990651926264,
      "median": 6.89799917014,
      "user": 3.9670170999999996,
      "system": 3.84755944,
      "min": 6.5847536581399995,
      "max": 7.059040479139999,
      "times": [
        6.944595790139999,
        6.69939234714,
        6.70171115514,
        6.80366299314,
        6.95076438114,
        6.5847536581399995,
        6.9594948271399995,
        6.88892454614,
        7.059040479139999,
        6.90707379414
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 5.120420981139999,
      "stddev": 0.10034180644697913,
      "median": 5.11901767914,
      "user": 2.8660536999999997,
      "system": 3.3852554400000003,
      "min": 4.98840300914,
      "max": 5.2987538681399995,
      "times": [
        5.07252462414,
        5.1832398261399995,
        5.03582362414,
        5.170618022139999,
        4.98840300914,
        5.2137383351399995,
        5.16551073414,
        5.01462368914,
        5.2987538681399995,
        5.060974079139999
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 5.19783589514,
      "stddev": 0.13586655584556656,
      "median": 5.162455245139999,
      "user": 2.8694072999999998,
      "system": 3.4094584400000003,
      "min": 5.03080635214,
      "max": 5.50351052114,
      "times": [
        5.058333719139999,
        5.03080635214,
        5.1652383321399995,
        5.15081579414,
        5.30955901814,
        5.172618206139999,
        5.50351052114,
        5.154840720139999,
        5.159672158139999,
        5.27296413014
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12950
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,409.51 ms
(+2.64%)Baseline: 4,296.03 ms
5,155.23 ms
(85.53%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,101.90 ms
(+2.13%)Baseline: 3,037.33 ms
3,644.79 ms
(85.11%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,408.37 ms
(+2.78%)Baseline: 1,370.31 ms
1,644.37 ms
(85.65%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
680.78 ms
(+5.52%)Baseline: 645.18 ms
774.22 ms
(87.93%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
3,945.75 ms
(-3.40%)Baseline: 4,084.76 ms
4,901.72 ms
(80.50%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,809.53 ms
(-6.94%)Baseline: 7,317.28 ms
8,780.73 ms
(77.55%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
663.77 ms
(+1.81%)Baseline: 651.95 ms
782.34 ms
(84.84%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12950
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,228.72 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
707.32 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
684.70 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
109.48 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,100.51 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
5,120.42 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
739.47 ms
🐰 View full continuous benchmarking report in Bencher

Retarget the added benches onto code pacquet owns, so the numbers move
on pacquet changes rather than only on dependency or build-profile
changes:

- packument/parse deserializes a registry packument into
  pacquet_registry::Package and hydrates the picked version, covering
  PackageVersions' lazy fragment capture and PackageVersion hydration.
- lockfile/parse_pnpm_lock parses via pacquet_lockfile.

Drop the gzip-inflate and SHA-512 benches: they measured zune-inflate
and ssri/sha2 directly, which pacquet code cannot move, and their
real-world cost is already covered by the download_dependency pipeline
bench. Drop the now-unused zune-inflate dependency.
@KSXGitHub KSXGitHub changed the title bench(micro-benchmark): isolate per-sink install-path benches bench(micro-benchmark): isolate the packument and lockfile parse paths Jul 12, 2026
Assert the fixture parses to Some at setup, so a lockfile that loads as
None (absent, empty, or env-only main document) fails loudly instead of
letting the bench report a fast, meaningless throughput.

While here, take the throughput length from fs::metadata rather than
reading the whole file, source the filename from Lockfile::FILE_NAME,
and drop a call-site comment that repeated the callee's doc comment.
KSXGitHub

This comment was marked as resolved.

claude added 2 commits July 12, 2026 16:57
The typos-exclude reason, the packument provenance/refresh note, and the
lockfile-reuse note restate what the filenames and the bench doc
comments already convey. Remove them.
Match the crate's existing pipe-trait style for the fixture read.
pipe-trait is already a dependency.
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

What these two benches actually exercise (complexity justification)

These two benches complement the existing full-pipeline tarball/download_dependency bench by isolating the two CPU-bound parse paths that pacquet's own code owns, so a regression in resolution/lockfile parsing is attributable to a single step instead of hiding inside the combined install path.

packument/parse → pacquet-registry

serde_json::from_slice::<Package>          ← 69 KB JSON, 117 versions
├─ Package (derive Deserialize)            ← name, dist-tags, time?/modified?/etag?/homepage?
└─ PackageVersions (CUSTOM Deserialize)    ← captures 117 versions as RAW fragments, parses none
dist_tag("latest")                         ← HashMap lookup (trivial)
versions.get("latest") → hydrate()         ← parses exactly ONE version
   └─ serde_json::from_str::<PackageVersion>   ← CUSTOM: dependency-map visitor, deprecated
                                                 normalizer, `_npmUser`, `#[serde(flatten)]` catch-all

The load-bearing design point: versions are captured raw and hydrated lazily, so the envelope parse builds a map of 117 Arc<RawValue> slices and deserializes none of them —

let raw_map = HashMap::<String, Box<RawValue>>::deserialize(deserializer)?; // scan + slice only

so the bench also guards that laziness (an eager-hydration regression would parse all 117 and blow up here).

Complexity: moderate. Registry crate ≈ 1,024 LOC / 17 types / 10 custom deserialize hooks; the bench pays a full 69 KB envelope scan + 117-fragment map build + one hydration.

lockfile/parse_pnpm_lock → pacquet-lockfile

Lockfile::load_wanted_from_dir → load_from_path
├─ fs::read_to_string                         ← 392 KB, 12,065 lines (page-cache-warm)
├─ extract_main_document                      ← split on `---` (trivial)
├─ serde_saphyr::from_str::<Lockfile>         ← YAML → 52 types, 13 custom deserialize hooks
│   ├─ importers:  HashMap<String, ProjectSnapshot>
│   ├─ packages:   HashMap<PackageKey, PackageMetadata>   ← 1,355 entries
│   └─ snapshots:  HashMap<PackageKey, SnapshotEntry>     ← 1,355 entries
│        every key   → PackageKey = PkgNameVerPeer   (PARSED: name@ver(peer))
│        every value → SnapshotEntry.dependencies    → SnapshotDepRef (PARSED, 3 variants)
└─ reconstruct_missing_directory_resolutions  ← post-load fix-up pass

Unlike the packument path, nothing here is lazy: all ~2,710 map entries are fully materialized, every key is a parsed branded string (not just stored), and every dependency ref is a 3-way branded parse (bare version / npm-alias / link: path), followed by a whole-lockfile reconstruction pass.

Complexity: high. Lockfile crate ≈ 4,393 LOC across 24 modules / 52 types / 13 custom deserialize hooks; this is the bench that meaningfully stresses pacquet's parsing depth.

At a glance

packument/parse lockfile/parse_pnpm_lock
Crate pacquet-registry (~1,024 LOC, 17 types) pacquet-lockfile (~4,393 LOC, 52 types)
Fixture 69 KB JSON, 117 versions 392 KB YAML, 12,065 lines
Entries materialized 117 raw slices + 1 typed version 1,355 packages + 1,355 snapshots, all typed
Laziness yes (guards the lazy-hydration design) none (eager)
Rating moderate (partly latent) high

Candid caveat

The lockfile bench does real, deep pacquet work. The packument bench is lighter than its call graph suggests: lodash has zero runtime dependencies and only latest is hydrated, so the registry crate's heaviest custom paths (the dependency-map visitors) are underexercised — it mostly measures the 117-fragment envelope capture. If we want it to bite harder, the levers are a dependency-rich packument fixture (e.g. webpack or `@babel/core`, many versions with large dependency maps) and/or hydrating all versions instead of just latest. Happy to make that change if you'd like the packument path stressed more representatively.


Written by an agent (Claude Code).


Generated by Claude Code

@KSXGitHub
KSXGitHub marked this pull request as ready for review July 12, 2026 17:14
@KSXGitHub
KSXGitHub requested a review from zkochan as a code owner July 12, 2026 17:14
Copilot AI review requested due to automatic review settings July 12, 2026 17:14
@greptile-apps

greptile-apps Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Benchmark-only change, no user-visible surface, publish = false; safe to merge.

Both benchmark functions follow the established pattern in the file: correct black_box placement prevents dead-code elimination, throughput metrics match the actual input size, the preflight assertion in bench_lockfile catches a missing fixture before the timing loop begins, and doc comments explain the non-obvious design choices. No new user-visible behavior, no change to lockfile or store format.

No files require special attention.

Reviews (1): Last reviewed commit: "bench(micro-benchmark): read the packume..." | Re-trigger Greptile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds two new pacquet-focused micro-benchmarks to attribute CPU-bound parsing regressions to specific parse paths (packument JSON parsing/hydration and pnpm-lock.yaml parsing), complementing the existing download/tarball pipeline benchmark.

Changes:

  • Add packument/parse benchmark that deserializes a committed packument fixture into pacquet_registry::Package, then resolves + hydrates the latest version.
  • Add lockfile/parse_pnpm_lock benchmark that parses the existing integrated-benchmark pnpm-lock.yaml fixture via pacquet_lockfile::Lockfile::load_wanted_from_dir.
  • Add committed lodash packument fixture and adjust dev-tooling config/dependencies to support the new benches.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pnpm/tasks/micro-benchmark/src/main.rs Adds bench_packument and bench_lockfile, wires them into main(), and imports required crates/utilities.
pnpm/tasks/micro-benchmark/fixtures/lodash.json Adds a committed abbreviated lodash packument fixture for the packument parsing benchmark.
pnpm/tasks/micro-benchmark/Cargo.toml Adds pacquet-lockfile and serde_json workspace dependencies used by the new benchmarks.
Cargo.lock Updates the lockfile for the new micro-benchmark crate dependencies.
.typos.toml Excludes the new JSON fixture from typos to avoid base64/signature false positives.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zkochan
zkochan merged commit c6fd0b7 into main Jul 12, 2026
40 of 42 checks passed
@zkochan
zkochan deleted the claude/pnpm-micro-benchmarks-ndness branch July 12, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants