Skip to content

test(micro-benchmark): gate multi-importer workspace resolution in CI - #13581

Merged
zkochan merged 1 commit into
mainfrom
gate-hoist-resolution-benchmark
Aug 2, 2026
Merged

zkochan merged 1 commit into
mainfrom
gate-hoist-resolution-benchmark

Conversation

@zkochan

@zkochan zkochan commented Aug 2, 2026 •

Copy link
Copy Markdown
Member

Summary

No CI benchmark measures the peer-hoist loop, so a change to its cost —
in either direction — passes unnoticed. This puts the fixture that does
measure it in front of the harness that already compares both sides of a
pull request.

The gap, measured rather than assumed:

  • The hoist-heavy resolution fixture is the only benchmark that runs
    the loop. It lived as a harness-free bench in the resolver crate that
    nothing in CI invoked.
  • The integrated benchmark's scenarios all converge in one hoist
    round, so none of them moves when the loop's cost changes. I also
    prototyped a 40-importer hoist-heavy scenario for it, and A/B'd it
    across perf(resolving-deps-resolver): amortize the per-importer workspace scans in the hoist loop #13579, which makes the loop 4.4x faster: 820.6 ms vs
    819.0 ms
    (1.00 ± 0.29). At that scale the per-importer work is ~16k
    map entries a round and is buried in an 820 ms end-to-end install that
    is mostly linking. I am not proposing that scenario.
  • The micro-benchmark job already builds main and the PR head, runs
    both under criterion, and posts their comparison. It is deterministic,
    in-process, and needs no registry — the right instrument for a
    resolver-internal cost.

The change

Move the fixture into the micro-benchmark task and give it two sizes.

Size::Ci — 120 importers over 1,200 packages — runs under criterion
on every PR at ~0.2s a resolve. Both factors of the per-importer work
shrink together, so the shape of what it measures is unchanged.

Size::Full — the 331-importer, 5,000-package workspace the original
regression came from — keeps its single timed run, now behind
--full-workspace-resolution. A regressed run at that size can take
minutes and several GiB, which has no business in a statistical harness;
that is why the bench had no harness to begin with.

Only the hoist-heavy shape is benched. The plain and peer-heavy shapes
re-measure the tree walk other scenarios already cover, and with every
peer provided up front their hoist loop converges in one round.

Moving rather than copying keeps one home for the fixture: the bench
could not import from a task crate, and duplicating ~300 lines of
fixture across the two would leave them free to drift.

That it discriminates

Across #13579, on the CI size:

workspace_resolution/hoist_heavy
                        time:   [216.20 ms 219.12 ms 222.34 ms]
                        change: [−62.563% −62.051% −61.468%] (p = 0.00 < 0.05)
                        Performance has improved.

577 ms → 219 ms. A future change that reintroduces either quadratic
shows up as a ~2.6x regression in the table on its own PR.

The group costs ~9s of the job (3s warmup, 10 samples).

Squash Commit Body

The hoist-heavy resolution fixture is the only benchmark that measures
the peer-hoist loop — the importer barrier, the per-round context syncs,
and the per-importer work that scales with the workspace. Nothing ran it
in CI: it lived as a harness-free bench in the resolver crate, and the
scenarios the integrated benchmark does run converge in one hoist round,
so none of them moves when that loop's cost changes. An A/B of a
40-importer integrated-benchmark fixture measures 820.6ms against
819.0ms across a change that makes the loop 4.4x faster.

Move the fixture into the micro-benchmark task, which already builds
both sides of a pull request and posts their comparison, and give it two
sizes. The CI size — 120 importers over 1,200 packages — runs under
criterion on every PR at ~0.2s a resolve; the full size, which models the
331-importer workspace the original regression came from, keeps its
single timed run behind `--full-workspace-resolution`, since a regressed
run there can take minutes and several GiB and has no business in a
statistical harness.

Only the hoist-heavy shape is benched. The plain and peer-heavy shapes
re-measure the tree walk that other scenarios already cover, and with
every peer provided up front their hoist loop converges in one round.

The CI size keeps the signal: across the same change, the group moves
577ms -> 219ms (-62%, p = 0.00).

Related to https://github.com/pnpm/pnpm/issues/13505.

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package.
  • Added or updated tests.

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


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Chores
    • Expanded workspace-resolution benchmarking with separate CI-sized and full-workspace scenarios.
    • Added a dedicated command-line option for running full workspace-resolution benchmarks and reporting timings.
    • Updated benchmark coverage to include plain, peer-provided, and peer-hoisted dependency resolution scenarios.
    • Improved benchmark fixtures and configuration for more representative workspace measurements.
    • Removed an obsolete benchmark target and refreshed supporting benchmark configuration.

Copilot AI review requested due to automatic review settings August 2, 2026 11:00

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 2, 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: 50eca330-66d8-4839-981f-d36204af3b18

📥 Commits

Reviewing files that changed from the base of the PR and between 5a4ca10 and 6b7a291.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (4)
  • pnpm/crates/resolving-deps-resolver/Cargo.toml
  • pnpm/tasks/micro-benchmark/Cargo.toml
  • pnpm/tasks/micro-benchmark/src/main.rs
  • pnpm/tasks/micro-benchmark/src/workspace_resolution.rs
💤 Files with no reviewable changes (1)
  • pnpm/crates/resolving-deps-resolver/Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (3)
  • pnpm/tasks/micro-benchmark/Cargo.toml
  • pnpm/tasks/micro-benchmark/src/workspace_resolution.rs
  • pnpm/tasks/micro-benchmark/src/main.rs

📝 Walkthrough

Walkthrough

The PR moves the full workspace-resolution benchmark to the micro-benchmark crate. It adds size-aware fixtures, CI Criterion execution, and a one-shot full-workspace CLI mode. The resolver crate benchmark declaration is removed.

Changes

Workspace resolution benchmark

Layer / File(s) Summary
Size-aware workspace fixtures
pnpm/tasks/micro-benchmark/src/workspace_resolution.rs
Workspace dimensions and generated dependency graphs now use Size. A reusable Workspace performs one resolution and returns the graph-node count.
Benchmark execution modes
pnpm/tasks/micro-benchmark/Cargo.toml, pnpm/tasks/micro-benchmark/src/main.rs, pnpm/tasks/micro-benchmark/src/workspace_resolution.rs, pnpm/crates/resolving-deps-resolver/Cargo.toml
The standard suite runs the CI-sized peer-hoisted scenario. The --full-workspace-resolution flag runs plain, peer-provided, and peer-hoisted full-size scenarios once and prints timings. The previous resolver benchmark target is removed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Workspace
  participant GraphResolver
  CLI->>Workspace: construct selected workspace shape
  Workspace->>GraphResolver: resolve workspace graph
  GraphResolver-->>Workspace: return graph-node count
  Workspace-->>CLI: report timing and workspace counts
Loading

Possibly related issues

Possibly related PRs

  • pnpm/pnpm#13381: Adds and restructures benchmarks that exercise workspace dependency resolution.
  • pnpm/pnpm#13491: Replaces the resolver crate benchmark with a micro-benchmark implementation for full-workspace resolution.
  • pnpm/pnpm#13571: Modifies workspace-resolution benchmark scenarios, including plain, peer-provided, and peer-hoisted cases.

Suggested labels: product: pacquet

Suggested reviewers: copilot

✨ 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 gate-hoist-resolution-benchmark

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.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Gate hoist-heavy workspace resolution micro-benchmark in CI

🧪 Tests ✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Move the hoist-heavy multi-importer workspace resolution fixture into the CI micro-benchmark
 harness.
• Add a CI-sized criterion benchmark plus a full-size one-shot mode behind a CLI flag.
• Remove the unused harness-free resolver bench registration and wire required deps.
Diagram

graph TD
  CI["CI micro-benchmark job"] --> MB["micro-benchmark (bin)"] --> Main["main.rs"] --> WS["workspace_resolution.rs"] --> R["pacquet-resolving-deps-resolver"] --> RB["pacquet-resolving-resolver-base"]
  Main --> Crit["criterion"]
  WS --> Tokio["tokio runtime"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep as resolver crate bench and invoke via CI
  • ➕ Keeps benchmark closest to resolver implementation
  • ➕ Avoids adding resolver-specific deps to the task crate
  • ➖ Harder to compare base vs head in the existing micro-benchmark reporting pipeline
  • ➖ Still needs custom CI wiring (and likely special-casing for full-size runs)
2. Add a hoist-heavy scenario to the integrated benchmark
  • ➕ Measures end-to-end behavior closer to real installs
  • ➖ Signal gets drowned out by linking/IO; small resolver loop changes may not move totals
  • ➖ Requires larger fixture or heavier setup to discriminate, increasing CI cost
3. Use a custom non-criterion timing harness in CI
  • ➕ Can cap memory/time and run exactly once for a representative size
  • ➖ Less statistically robust and harder to compare across machines/variance than criterion in-process benchmarks
  • ➖ Duplicates benchmarking/reporting logic that the micro-benchmark job already provides

Recommendation: The chosen approach—moving the fixture into the existing micro-benchmark job and benchmarking only the hoist-heavy shape at a CI-sized dataset—best matches the goal: reliably detecting peer-hoist loop regressions with a strong base-vs-head comparison signal while keeping CI runtime bounded. Keeping a full-size one-shot behind a flag preserves the original regression reproducer without forcing it into criterion’s statistical harness.

Files changed (5) +158 / -71

Other (5) +158 / -71
Cargo.lockAdd new workspace-resolution deps to the lockfile +4/-0

Add new workspace-resolution deps to the lockfile

• Updates the lockfile to include additional pacquet workspace crates now depended on by the micro-benchmark task (catalog types, package manifest, and resolver crates).

Cargo.lock

Cargo.tomlRemove harness-free workspace resolution bench registration +0/-4

Remove harness-free workspace resolution bench registration

• Deletes the [[bench]] entry for the old non-criterion full-resolution benchmark so it is no longer registered or expected to run from this crate.

pnpm/crates/resolving-deps-resolver/Cargo.toml

Cargo.tomlWire resolver/manifest dependencies into micro-benchmark task +10/-6

Wire resolver/manifest dependencies into micro-benchmark task

• Adds the resolver base and deps-resolver crates (plus supporting manifest/catalog crates) as dependencies so the task can host and run the workspace-resolution fixture under criterion.

pnpm/tasks/micro-benchmark/Cargo.toml

main.rsAdd CLI gate for full-size resolution and register new benchmark group +15/-1

Add CLI gate for full-size resolution and register new benchmark group

• Introduces a --full-workspace-resolution flag that runs the full-size one-shot timings and exits. Always registers the CI-sized workspace_resolution criterion benchmark group in the standard suite.

pnpm/tasks/micro-benchmark/src/main.rs

workspace_resolution.rsImplement CI-sized criterion benchmark plus full-size one-shot runner +129/-60

Implement CI-sized criterion benchmark plus full-size one-shot runner

• Refactors the multi-importer fixture into reusable constructors (Workspace, Size) and extracts a resolve_once timed region. Adds a criterion benchmark for the hoist-heavy shape at CI size and a separate full-size path that runs each shape once and prints timings.

pnpm/tasks/micro-benchmark/src/workspace_resolution.rs

@qodo-code-review

qodo-code-review Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. Historical note in module docs ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The module-level doc comment references an "original regression" and the specific workspace that
exposed it, which is historical phrasing rather than describing current behavior/rationale. This can
become stale and violates the rule to keep comments focused on the current code contract.
Code

pnpm/tasks/micro-benchmark/src/workspace_resolution.rs[R12-15]

+//! - [`Size::Full`] models the Bit workspace that exposed the original
+//!   regression (331 importers over 5,000 packages). It is too slow and
+//!   too memory-hungry for a statistical harness — a regressed run can
+//!   take minutes and several GiB — so `--full-workspace-resolution` runs
Relevance

●●● Strong

Repo has accepted rewriting comments to focus on rationale/constraints rather than stale historical
framing.

PR-#12950

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 forbids comments with historical framing (e.g., "original", "previously",
"used to"). The module docs at the cited lines explicitly reference an "original regression" and the
specific workspace that exposed it, which is historical rather than describing the current
behavior/constraints of Size::Full.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/tasks/micro-benchmark/src/workspace_resolution.rs[12-16]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The module doc comment uses historical phrasing (e.g., "original regression" and referencing the specific workspace that exposed it). Comments should describe current behavior and rationale without embedding historical implementation/migration context.

## Issue Context
This is a benchmark fixture; keeping docs non-historical helps prevent stale comments and keeps the documentation focused on what the code does today.

## Fix Focus Areas
- pnpm/tasks/micro-benchmark/src/workspace_resolution.rs[12-16]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@greptile-apps

greptile-apps Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (2): Last reviewed commit: "test(micro-benchmark): gate multi-import..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/tasks/micro-benchmark/src/main.rs`:
- Around line 225-228: Update main() around the CliArgs destructuring and
full_workspace_resolution branch to reject combinations where save_baseline and
full_workspace_resolution are both enabled. Return an appropriate error before
calling workspace_resolution::run_full_workspace_resolution(), while preserving
the existing standalone behavior of each flag.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 952524d2-b182-4792-96cf-a67438120d95

📥 Commits

Reviewing files that changed from the base of the PR and between 5644b55 and 5a4ca10.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (4)
  • pnpm/crates/resolving-deps-resolver/Cargo.toml
  • pnpm/tasks/micro-benchmark/Cargo.toml
  • pnpm/tasks/micro-benchmark/src/main.rs
  • pnpm/tasks/micro-benchmark/src/workspace_resolution.rs
💤 Files with no reviewable changes (1)
  • pnpm/crates/resolving-deps-resolver/Cargo.toml

Comment thread pnpm/tasks/micro-benchmark/src/main.rs Resolved
The hoist-heavy resolution fixture is the only benchmark that measures
the peer-hoist loop — the importer barrier, the per-round context syncs,
and the per-importer work that scales with the workspace. Nothing ran it
in CI: it lived as a harness-free bench in the resolver crate, and the
scenarios the integrated benchmark does run converge in one hoist round,
so none of them moves when that loop's cost changes. An A/B of the
40-importer integrated-benchmark fixture measures 820.6ms against
819.0ms across a change that makes the loop 4.4x faster.

Move the fixture into the micro-benchmark task, which already builds
both sides of a pull request and posts their comparison, and give it two
sizes. The CI size — 120 importers over 1,200 packages — runs under
criterion on every PR at ~0.2s a resolve; the full size, which models the
331-importer workspace the original regression came from, keeps its
single timed run behind `--full-workspace-resolution`, since a regressed
run there can take minutes and several GiB and has no business in a
statistical harness.

Only the hoist-heavy shape is benched. The plain and peer-heavy shapes
re-measure the tree walk that other scenarios already cover, and with
every peer provided up front their hoist loop converges in one round.

The CI size keeps the signal: across the same change, the group moves
577ms -> 219ms (-62%, p = 0.00).

Related to https://github.com/pnpm/pnpm/issues/13505.
Copilot AI review requested due to automatic review settings August 2, 2026 11:05
@zkochan
zkochan force-pushed the gate-hoist-resolution-benchmark branch from 5a4ca10 to 6b7a291 Compare August 2, 2026 11:05

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan

zkochan commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

Both findings were right and are fixed in 6b7a291:

  • --save-baseline silently ignored (CodeRabbit) — the two flags now conflicts_with each other, so the combination is rejected rather than dropped:
    error: the argument '--save-baseline <SAVE_BASELINE>' cannot be used with '--full-workspace-resolution'
    
  • Historical framing in the module docs (Qodo) — "the Bit workspace that exposed the original regression" is exactly what the comment conventions forbid; the size is now described as what it is ("a large real workspace's scale: 331 importers over 5,000 packages") rather than by what it once caught.

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

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 2, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 6b7a291

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     11.4±0.02ms    32.8 MB/sec    1.00     11.4±0.06ms    32.7 MB/sec
packument/parse                                  1.00     37.9±0.10µs  1751.8 MB/sec    1.01     38.2±0.10µs  1736.1 MB/sec
tarball/download_dependency                      1.00      2.2±0.08ms  1961.8 KB/sec    1.00      2.2±0.07ms  1959.7 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00    173.1±1.07ms 92.5 KElem/sec    1.01    174.3±1.38ms 91.8 KElem/sec
workspace_resolution/hoist_heavy                                                        1.00    677.3±2.56ms        ? ?/sec

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.98%. Comparing base (5644b55) to head (6b7a291).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   pnpm/pnpm#13581      +/-   ##
==========================================
- Coverage   87.99%   87.98%   -0.02%     
==========================================
  Files         563      563              
  Lines       97561    97561              
==========================================
- Hits        85850    85840      -10     
- Misses      11711    11721      +10     

☔ 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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants