Skip to content

perf(deps-restorer): link the files of one directory from one worker - #15455

Merged
zkochan merged 6 commits into
mainfrom
fix-15439
Sep 24, 2026
Merged

zkochan merged 6 commits into
mainfrom
fix-15439

Conversation

@zkochan

@zkochan zkochan commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #15439

A warm install from the store ran one rayon task per file, so every worker in the pool linked into the same package directory at once. Creating a dirent takes the parent directory's lock on every filesystem pnpm runs on, so the workers only queued on each other while the kernel spent CPU arbitrating the queue. This PR groups a package's files by target directory and places each group from one worker, entry after entry; directories still import in parallel, so a package spread over many directories keeps its intra-package parallelism.

Measured on the issue's reproduction (995 packages, 88k files, warm store, package-import-method=hardlink, 32 CPUs, btrfs), three runs each, back to back:

binary wall user sys
pnpm 11.26.0 1.6–1.8 s 3.2 s 2.1 s
pnpm 12 before 1.2–1.4 s 0.6 s 14–16 s
pnpm 12 after 1.2–1.3 s 0.6 s 3.3 s

With the old binary, the system time tracks the rayon pool size (RAYON_NUM_THREADS=64: 10 s, 16: 2.7 s, 1: 1.3 s), which is what confirms contention rather than work. The resulting node_modules has the same file, symlink and directory counts before and after. Under strace -c, the mean linkat cost falls from 8.8 ms to 0.9 ms per call.

Linux absorbs the contention in wall time on a 32-core box, so the 5x wall-time regression from the report could not be reproduced here; it was measured on NTFS with Defender enabled, where each per-file operation is much slower and the same queue is visible in wall time. The @mui/icons-material package in the reproduction alone holds 43k of the 88k files in two directories, so on Windows it was effectively a 43k-file serial section before this change too, now with two workers instead of forty fighting over two directories. It is likely the same mechanism behind the higher system CPU reported in #14540, but that was not measured.

This is a v12-only change: pnpm v11's tryImportIndexedDir already links a package's files serially inside one worker.

A test-only probe counts the workers placing entries in each target directory. The regression test runs populate_dir over two 200-file directories and asserts neither ever had two writers at once; with the entries fanned out per file again it reports 21.

Squash Commit Body

`populate_dir` ran one rayon task per file, so a package's files were
linked into the same directory by every worker in the pool at once.
Creating a dirent takes the parent directory's lock on every filesystem
pnpm runs on, so those workers only queued on each other while the
kernel spent CPU arbitrating the queue. On a warm 995-package install
(88k files, hardlink method, 32 CPUs, btrfs) the install spent 15 s of
system time against 2 s for pnpm v11's serial per-package loop, and the
kernel time fell to 1.3 s with a single rayon thread. On NTFS the report
in pnpm/pnpm#15439 measures the same install at five times pnpm v11's
wall time with the CPU climbing the whole way, which is what that
contention looks like on a filesystem whose per-file operations are
slower.

The entries are now grouped by target directory and each group is placed
by one worker, entry after entry, while directories still import in
parallel. System time on the same install drops to 3 s with no change
in wall time on Linux, and the resulting tree is identical. Grouping by
directory rather than importing a whole package sequentially keeps
intra-package parallelism for packages spread over many directories.

Closes pnpm/pnpm#15439

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • New features are implemented only in the Rust pnpm v12 CLI. Bug fixes
    are implemented in every affected version.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Reduced CPU usage when linking packages from a warm store, addressing slower warm installs on Windows.

zkochan and others added 2 commits September 24, 2026 02:19
`populate_dir` ran one rayon task per file, so a package's files were
linked into the same directory by every worker in the pool at once.
Creating a dirent takes the parent directory's lock on every filesystem
pnpm runs on, so those workers only queued on each other while the
kernel spent CPU arbitrating the queue. On a warm 995-package install
(88k files, hardlink method, 32 CPUs, btrfs) the install spent 15 s of
system time against 2 s for pnpm v11's serial per-package loop, and the
kernel time fell to 1.3 s with a single rayon thread. On NTFS the report
in #15439 measures the same install at five times pnpm v11's
wall time with the CPU climbing the whole way, which is what that
contention looks like on a filesystem whose per-file operations are
slower.

The entries are now grouped by target directory and each group is placed
by one worker, entry after entry, while directories still import in
parallel. System time on the same install drops to 3 s with no change
in wall time on Linux, and the resulting tree is identical. Grouping by
directory rather than importing a whole package sequentially keeps
intra-package parallelism for packages spread over many directories.

Closes #15439

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 960252ad-5134-49ad-a978-ef45f98f4eb8

📥 Commits

Reviewing files that changed from the base of the PR and between 0687d41 and 05af6ac.

📒 Files selected for processing (3)
  • .changeset/link-one-writer-per-directory.md
  • pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs
  • pnpm/crates/deps-restorer/src/import_indexed_dir/placement/tests.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

populate_dir now groups non-marker entries by target directory. Rayon workers place each directory’s entries sequentially, then place the marker. Tests verify directory grouping and single-writer behavior.

Changes

Package placement

Layer / File(s) Summary
Group and place entries by directory
pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs, pnpm/crates/deps-restorer/src/import_indexed_dir/placement/tests.rs, .changeset/link-one-writer-per-directory.md
populate_dir processes entries grouped by target directory and places each group sequentially. Tests verify grouping, file creation, and a maximum of one concurrent writer per directory. The changeset declares a patch release and describes lower CPU use and faster warm installs on Windows.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Assessment against linked issues

Objective Addressed Explanation
Restore warm-store install performance on Windows to about the pnpm 11 level or faster [#15439] ❓ The code changes placement concurrency and tests single-writer behavior, but the provided changes do not include a performance benchmark confirming the expected install time.

Merge Risk: ⚪ Minimal · up to 05af6

The placement change is ready to merge after normal checks; no actionable merge-blocking risk is identified.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@codecov-commenter

codecov-commenter commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.82%. Comparing base (ed4cb35) to head (05af6ac).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15455   +/-   ##
=======================================
  Coverage   91.82%   91.82%           
=======================================
  Files        1413     1413           
  Lines      190671   190746   +75     
=======================================
+ Hits       175088   175158   +70     
- Misses      15583    15588    +5     

☔ 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 Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     14.4±0.78ms    25.9 MB/sec    1.01     14.6±0.42ms    25.7 MB/sec
packument/parse                                  1.08     48.3±1.32µs  1373.9 MB/sec    1.00     44.6±0.31µs  1485.9 MB/sec
tarball/download_dependency                      1.00      4.5±0.28ms   962.8 KB/sec    1.03      4.6±0.28ms   938.4 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.02   230.4±27.90ms 69.4 KElem/sec    1.00    226.2±5.27ms 70.7 KElem/sec
workspace_resolution/hoist_heavy                 1.00    305.7±3.21ms        ? ?/sec    1.03    314.9±4.91ms        ? ?/sec
workspace_sort/chained_projects                  1.01     15.2±1.10ms        ? ?/sec    1.00     15.1±1.14ms        ? ?/sec

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Same-run regression check

HEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval.

Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-cold-cache-cold-store pacquet 2488.30 ms 2609.05 ms 4.9% 124.42 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1459.14 ms 1502.80 ms 3.0% 72.96 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 223.92 ms 225.56 ms 0.7% 11.20 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 237.60 ms 239.77 ms 0.9% 11.88 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 7.43 ms 8.09 ms 8.9% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 7.17 ms 8.58 ms 19.7% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 7.16 ms 6.83 ms -4.6% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 6.75 ms 6.71 ms -0.5% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2466.80 ms 2503.81 ms 1.5% 123.34 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1402.17 ms 1477.56 ms 5.4% 70.11 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pacquet 427.30 ms 447.09 ms 4.6% 21.36 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 258.72 ms 275.78 ms 6.6% 12.94 ms Inconclusive (overlapping samples)
isolated-fresh-install-cold-cache-hot-store pacquet 1613.04 ms 1608.97 ms -0.3% 80.65 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 279.65 ms 286.19 ms 2.3% 13.98 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 224.53 ms 248.03 ms 10.5% 11.23 ms Inconclusive (overlapping samples)
isolated-fresh-resolve-hot-cache-offline pnpr 92.57 ms 91.96 ms -0.7% 4.63 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 723.08 ms 709.10 ms -1.9% 36.15 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 176.23 ms 188.51 ms 7.0% 8.81 ms Inconclusive (overlapping samples)
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4532.06 ms 4540.75 ms 0.2% 226.60 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3484.75 ms 3457.67 ms -0.8% 174.24 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 127.01 ms 112.58 ms -11.4% 6.35 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 134.80 ms 139.28 ms 3.3% 6.74 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 05af6ac0ebfe

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked-workspace scenario compares current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs.

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.637 ± 0.111 2.531 2.833 1.78 ± 0.18
pacquet@main 2.511 ± 0.083 2.396 2.655 1.69 ± 0.16
pnpr@HEAD 1.517 ± 0.148 1.311 1.731 1.02 ± 0.14
pnpr@main 1.482 ± 0.134 1.316 1.709 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.63737223936,
      "stddev": 0.1111403656655364,
      "median": 2.60904728696,
      "user": 1.9688217,
      "system": 1.6506312400000003,
      "min": 2.53110297946,
      "max": 2.83310808546
    },
    {
      "command": "pacquet@main",
      "mean": 2.5114119730600004,
      "stddev": 0.08349808663368646,
      "median": 2.48830239596,
      "user": 1.7387275999999996,
      "system": 1.55038734,
      "min": 2.39570210046,
      "max": 2.65491584946
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5171690790599999,
      "stddev": 0.14793262291442913,
      "median": 1.50279935646,
      "user": 1.4345674,
      "system": 1.4323726399999999,
      "min": 1.31054638946,
      "max": 1.73056024446
    },
    {
      "command": "pnpr@main",
      "mean": 1.48170776576,
      "stddev": 0.1343244792668415,
      "median": 1.4591447929599999,
      "user": 1.5253614999999998,
      "system": 1.5937649399999998,
      "min": 1.31628744046,
      "max": 1.70851368946
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 260.9 ± 61.4 209.3 388.0 1.15 ± 0.28
pacquet@main 227.0 ± 16.6 208.5 260.9 1.00
pnpr@HEAD 240.8 ± 9.4 229.7 263.2 1.06 ± 0.09
pnpr@main 240.5 ± 11.1 224.5 261.0 1.06 ± 0.09
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.26089976408000004,
      "stddev": 0.06140388482647703,
      "median": 0.22555504498,
      "user": 0.29418250000000007,
      "system": 0.60739378,
      "min": 0.20931395698000002,
      "max": 0.38799546498000004
    },
    {
      "command": "pacquet@main",
      "mean": 0.22700906968,
      "stddev": 0.01659708552403334,
      "median": 0.22391602248000003,
      "user": 0.25003220000000004,
      "system": 0.5464679799999999,
      "min": 0.20852545698000002,
      "max": 0.26091487798
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.24081103818,
      "stddev": 0.009412794993590393,
      "median": 0.23977246348000003,
      "user": 0.2391997,
      "system": 0.5484189799999999,
      "min": 0.22972586998000002,
      "max": 0.26316451198
    },
    {
      "command": "pnpr@main",
      "mean": 0.24050972748000002,
      "stddev": 0.011114771136583422,
      "median": 0.23759584698000003,
      "user": 0.2449102,
      "system": 0.54104708,
      "min": 0.22446757798000003,
      "max": 0.26100859498
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 8.9 ± 2.0 6.3 15.4 1.21 ± 0.30
pacquet@main 7.5 ± 0.6 6.1 9.7 1.02 ± 0.13
pnpr@HEAD 8.8 ± 1.1 6.5 13.2 1.19 ± 0.19
pnpr@main 7.3 ± 0.7 6.2 10.3 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.008901568191343285,
      "stddev": 0.0019800327061696384,
      "median": 0.00809099446,
      "user": 0.0049519959203980085,
      "system": 0.004460708855721391,
      "min": 0.00632229046,
      "max": 0.015355329460000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.007494643499393938,
      "stddev": 0.0005967895171455175,
      "median": 0.00742664946,
      "user": 0.004556995151515155,
      "system": 0.0034319415757575757,
      "min": 0.00607846346,
      "max": 0.009651297460000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.008769365193532932,
      "stddev": 0.0011151034129760734,
      "median": 0.008578549960000001,
      "user": 0.005172266826347303,
      "system": 0.0041059886227544935,
      "min": 0.00652493446,
      "max": 0.01322397546
    },
    {
      "command": "pnpr@main",
      "mean": 0.00734253157400652,
      "stddev": 0.0007409786654149023,
      "median": 0.00716615646,
      "user": 0.004539590423452767,
      "system": 0.0032095665146579812,
      "min": 0.00617889546,
      "max": 0.010263675460000002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 6.9 ± 0.7 5.9 9.3 1.03 ± 0.12
pacquet@main 7.6 ± 1.1 6.0 12.0 1.12 ± 0.18
pnpr@HEAD 6.8 ± 0.4 6.0 8.4 1.00
pnpr@main 6.8 ± 0.3 5.8 8.7 1.00 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.006931447996271192,
      "stddev": 0.0006570527194026141,
      "median": 0.0068321430200000005,
      "user": 0.004145458983050847,
      "system": 0.0031962077288135585,
      "min": 0.0058603280200000005,
      "max": 0.00925800002
    },
    {
      "command": "pacquet@main",
      "mean": 0.007575765341875003,
      "stddev": 0.0011346125979066713,
      "median": 0.007162884020000001,
      "user": 0.00479165125,
      "system": 0.003216163000000001,
      "min": 0.006024627020000001,
      "max": 0.011950697020000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.006761751840754715,
      "stddev": 0.0004060201039200776,
      "median": 0.0067094730200000004,
      "user": 0.004117765911949683,
      "system": 0.0030451588050314457,
      "min": 0.006030697020000001,
      "max": 0.00839493902
    },
    {
      "command": "pnpr@main",
      "mean": 0.006766066453846158,
      "stddev": 0.0003361178511301157,
      "median": 0.006746252020000001,
      "user": 0.004480436923076924,
      "system": 0.0027275126153846157,
      "min": 0.005788723020000001,
      "max": 0.008713126020000002
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.554 ± 0.104 2.476 2.771 1.75 ± 0.16
pacquet@main 2.473 ± 0.041 2.430 2.576 1.69 ± 0.14
pnpr@HEAD 1.529 ± 0.128 1.395 1.744 1.05 ± 0.12
pnpr@main 1.462 ± 0.117 1.384 1.727 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.55444515602,
      "stddev": 0.10394378000119095,
      "median": 2.5038069926200004,
      "user": 2.17398356,
      "system": 1.7717648599999998,
      "min": 2.47604477912,
      "max": 2.7713950581200004
    },
    {
      "command": "pacquet@main",
      "mean": 2.4731827493200003,
      "stddev": 0.041266990691665825,
      "median": 2.46679785112,
      "user": 1.9819339599999999,
      "system": 1.6355517599999998,
      "min": 2.43041552812,
      "max": 2.57591739312
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5289255471200003,
      "stddev": 0.1282193195319141,
      "median": 1.47755871062,
      "user": 1.29680926,
      "system": 1.2425531599999997,
      "min": 1.39532077012,
      "max": 1.7443396801200002
    },
    {
      "command": "pnpr@main",
      "mean": 1.46249907652,
      "stddev": 0.116895513830437,
      "median": 1.4021744586200002,
      "user": 1.2360031599999999,
      "system": 1.21684466,
      "min": 1.3836073101200002,
      "max": 1.72669213412
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 479.9 ± 91.6 407.4 663.2 1.84 ± 0.36
pacquet@main 422.6 ± 23.6 385.0 453.1 1.62 ± 0.12
pnpr@HEAD 277.3 ± 10.9 260.1 293.3 1.06 ± 0.06
pnpr@main 260.6 ± 12.1 250.1 291.5 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.47986140957999995,
      "stddev": 0.09164778849313841,
      "median": 0.44708525308,
      "user": 0.6822931000000001,
      "system": 0.74072368,
      "min": 0.40738299758,
      "max": 0.66315272958
    },
    {
      "command": "pacquet@main",
      "mean": 0.42256217468,
      "stddev": 0.02356728115045963,
      "median": 0.42729526758,
      "user": 0.5931127,
      "system": 0.77872888,
      "min": 0.38501612758000003,
      "max": 0.45305078958
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.27729190708000007,
      "stddev": 0.010880792760077355,
      "median": 0.27578490408,
      "user": 0.23013720000000001,
      "system": 0.48800638,
      "min": 0.26011854858,
      "max": 0.29327323158
    },
    {
      "command": "pnpr@main",
      "mean": 0.26059409128000005,
      "stddev": 0.012144124523277088,
      "median": 0.25871899408,
      "user": 0.2123698,
      "system": 0.45226028000000007,
      "min": 0.25009236658,
      "max": 0.29148544258000003
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.665 ± 0.117 1.588 1.920 6.03 ± 0.57
pacquet@main 1.625 ± 0.031 1.585 1.681 5.89 ± 0.38
pnpr@HEAD 0.326 ± 0.060 0.272 0.408 1.18 ± 0.23
pnpr@main 0.276 ± 0.017 0.255 0.309 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.66547261616,
      "stddev": 0.11658581108646925,
      "median": 1.60897317826,
      "user": 0.9446018,
      "system": 0.8349086800000001,
      "min": 1.5882879497600002,
      "max": 1.91999486776
    },
    {
      "command": "pacquet@main",
      "mean": 1.6252429860600004,
      "stddev": 0.0312778421552058,
      "median": 1.61303629376,
      "user": 0.8522473999999999,
      "system": 0.9006954799999999,
      "min": 1.5848952657600002,
      "max": 1.6811163047600002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.32600817156,
      "stddev": 0.06003676911103771,
      "median": 0.28619032576000003,
      "user": 0.2726730999999999,
      "system": 0.60051578,
      "min": 0.27200667876,
      "max": 0.40784711076
    },
    {
      "command": "pnpr@main",
      "mean": 0.27608982726000003,
      "stddev": 0.017211854402240892,
      "median": 0.27965326276,
      "user": 0.2282456,
      "system": 0.50990108,
      "min": 0.25487195476,
      "max": 0.30894539676
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 244.5 ± 20.8 213.7 288.5 2.66 ± 0.24
pacquet@main 224.9 ± 9.4 210.2 245.0 2.44 ± 0.13
pnpr@HEAD 92.1 ± 3.2 86.3 97.7 1.00
pnpr@main 93.4 ± 4.5 87.5 108.0 1.01 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24450572924,
      "stddev": 0.020765466993962752,
      "median": 0.24802918004000002,
      "user": 0.25638219999999995,
      "system": 0.08551548,
      "min": 0.21369231854,
      "max": 0.28846606354000004
    },
    {
      "command": "pacquet@main",
      "mean": 0.22493133146307692,
      "stddev": 0.009408187892029027,
      "median": 0.22452807354,
      "user": 0.24221573846153846,
      "system": 0.07563929538461538,
      "min": 0.21022726854,
      "max": 0.24497581154
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09206790931419356,
      "stddev": 0.0032022497614035018,
      "median": 0.09195531554,
      "user": 0.030623812903225807,
      "system": 0.017552486451612906,
      "min": 0.08632056654,
      "max": 0.09766122354000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.09340458820666667,
      "stddev": 0.0044501635411614,
      "median": 0.09256945404,
      "user": 0.033873299999999995,
      "system": 0.014231779999999998,
      "min": 0.08750543154,
      "max": 0.10799118354000001
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 681.4 ± 89.5 470.3 759.6 1.00
pacquet@main 719.0 ± 42.0 652.8 769.4 1.06 ± 0.15
pnpm@HEAD 3176.3 ± 412.9 2877.4 4178.3 4.66 ± 0.86
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6813705232733333,
      "stddev": 0.08946396449886188,
      "median": 0.70910450294,
      "user": 0.7035591400000001,
      "system": 0.1579128022222222,
      "min": 0.47030031594000005,
      "max": 0.75959147394
    },
    {
      "command": "pacquet@main",
      "mean": 0.7189796392733334,
      "stddev": 0.0419748255497753,
      "median": 0.7230822719400001,
      "user": 0.7375909177777777,
      "system": 0.17033546888888884,
      "min": 0.65284909294,
      "max": 0.7693937149400001
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.1763088602733327,
      "stddev": 0.41293872314567237,
      "median": 2.99583572994,
      "user": 4.9078921399999995,
      "system": 0.23657824666666669,
      "min": 2.87740858394,
      "max": 4.17827297094
    }
  ]
}

Scenario: Isolated linker: linked-workspace resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 188.5 ± 8.7 171.0 202.3 1.06 ± 0.06
pacquet@main 177.4 ± 6.2 167.4 190.9 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.18854964885333333,
      "stddev": 0.008704462745207217,
      "median": 0.18850863752000002,
      "user": 0.13847706666666668,
      "system": 0.09457458666666667,
      "min": 0.17095773152000002,
      "max": 0.20230124652
    },
    {
      "command": "pacquet@main",
      "mean": 0.17744582814500007,
      "stddev": 0.0061993152123210726,
      "median": 0.17622862252000002,
      "user": 0.12629986249999997,
      "system": 0.09308398249999998,
      "min": 0.16739842652,
      "max": 0.19085219352000002
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.576 ± 0.114 4.454 4.763 1.31 ± 0.04
pacquet@main 4.566 ± 0.105 4.447 4.729 1.31 ± 0.04
pnpr@HEAD 3.501 ± 0.123 3.386 3.758 1.00 ± 0.04
pnpr@main 3.489 ± 0.077 3.376 3.640 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.575854595820001,
      "stddev": 0.11364173942851014,
      "median": 4.54074785962,
      "user": 2.0873728199999997,
      "system": 1.68231434,
      "min": 4.4540881291200005,
      "max": 4.76264070612
    },
    {
      "command": "pacquet@main",
      "mean": 4.5659068962200005,
      "stddev": 0.10467642758178787,
      "median": 4.532060334620001,
      "user": 2.11641282,
      "system": 1.9350232400000003,
      "min": 4.44714854412,
      "max": 4.729330662120001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.50057740922,
      "stddev": 0.12252780643726296,
      "median": 3.4576742971199996,
      "user": 1.47738082,
      "system": 1.4350959399999998,
      "min": 3.38589319612,
      "max": 3.75834007512
    },
    {
      "command": "pnpr@main",
      "mean": 3.4889570241200003,
      "stddev": 0.07667004608131203,
      "median": 3.48475472262,
      "user": 1.41885782,
      "system": 1.5453815399999997,
      "min": 3.3761924251199997,
      "max": 3.64016625512
    }
  ]
}

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

Same install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 113.5 ± 4.7 107.2 127.2 1.00
pacquet@main 126.3 ± 6.3 115.5 139.0 1.11 ± 0.07
pnpr@HEAD 138.5 ± 8.9 126.2 155.0 1.22 ± 0.09
pnpr@main 139.9 ± 16.1 122.5 190.6 1.23 ± 0.15
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.11352317815454548,
      "stddev": 0.004653534144421772,
      "median": 0.11258192220000002,
      "user": 0.13791008545454544,
      "system": 0.12789974545454544,
      "min": 0.10724948020000001,
      "max": 0.1272094242
    },
    {
      "command": "pacquet@main",
      "mean": 0.12631185335,
      "stddev": 0.0062766236144309335,
      "median": 0.1270112677,
      "user": 0.14475049,
      "system": 0.16227819999999998,
      "min": 0.11546841320000001,
      "max": 0.13897016920000002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.13846235325555556,
      "stddev": 0.008901639284329277,
      "median": 0.13927862470000002,
      "user": 0.16462109555555549,
      "system": 0.15562814444444445,
      "min": 0.1261998632,
      "max": 0.15496044120000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.13985517483157897,
      "stddev": 0.016057658153073175,
      "median": 0.13479734820000003,
      "user": 0.16071051368421052,
      "system": 0.15447527894736843,
      "min": 0.12245461120000001,
      "max": 0.1905749552
    }
  ]
}

@zkochan
zkochan marked this pull request as ready for review September 24, 2026 00:48
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Reduce warm-install contention with per-directory file linking

🐞 Bug fix ✨ Enhancement 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Groups package entries by target directory to eliminate competing writers and filesystem lock
 contention.
• Preserves parallel imports across directories while serializing file placement within each
 directory.
• Adds grouping coverage and documents reduced CPU usage during warm installs.
Diagram

graph TD
    A["CAS path map"] --> B["Create directories"] --> C["Group target dirs"] --> D["Rayon workers"] --> E["Sequential entries"] --> F["Completion marker"]
Loading
High-Level Assessment

The per-directory grouping is the best balance: per-file tasks cause directory-lock contention, while serializing an entire package would discard useful parallelism across independent directories. Preserving marker-last placement also retains interrupted-import detection without introducing new synchronization.

Files changed (3) +91 / -19

Bug fix (1) +49 / -17
placement.rsSchedule package placement by target directory +49/-17

Schedule package placement by target directory

• Groups indexed entries by destination parent directory before Rayon dispatch. Each directory group is placed sequentially by one worker, reducing filesystem lock contention while retaining cross-directory parallelism and marker-last semantics.

pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs

Tests (1) +37 / -2
tests.rsVerify target-directory grouping and marker exclusion +37/-2

Verify target-directory grouping and marker exclusion

• Adds a unit test confirming entries sharing a destination directory are grouped together, nested directories remain separate, store paths are preserved, and the completion marker is excluded.

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/tests.rs

Documentation (1) +5 / -0
link-one-writer-per-directory.mdDocument lower CPU usage for warm-store package linking +5/-0

Document lower CPU usage for warm-store package linking

• Adds a patch changeset for 'pacquet' explaining that files within one directory are now linked sequentially by one worker while separate directories remain parallel. It documents the warm-install regression addressed by issue #15439.

.changeset/link-one-writer-per-directory.md

@qodo-code-review

qodo-code-review Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Windows link regressions go undetected ✓ Resolved 📜 Skill insight ▣ Testability
Description
entries_are_grouped_by_the_directory_they_land_in supplies only forward-slash paths such as
lib/index.js and has no Windows-specific execution case. The changed grouping relies on
Path::parent to define hardlink work units, so separator-dependent behavior on the platform
highlighted by the bug is not covered.
Code

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/tests.rs[R14-16]

+    let cas_paths: HashMap<String, PathBuf> =
+        ["package.json", "README.md", "lib/index.js", "lib/util.js", "lib/esm/index.js"]
+            .into_iter()
Relevance

●●● Strong

Recent linker precedents accept platform-specific regression coverage for Windows and filesystem
aliasing risks.

PR-#14289
PR-#13306

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 3365308 requires Windows separators or an explicit Windows-specific case for path and hardlink
changes. The sole new fixture uses forward slashes even though the PR specifically changes hardlink
scheduling and identifies Windows as the affected platform.

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/tests.rs[12-41]
Skill: review-code

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 hardlink scheduling change derives target directories through platform path semantics, but its regression test covers only forward-slash input and no explicit Windows case.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement/tests.rs[12-41]

## Recommended Fix
Add a Windows-specific test that exercises representative nested package paths and verifies that entries sharing a Windows parent directory are assigned to the same group. Run it under `cfg(windows)` if native `Path` behavior is required.

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


2. Release notes expose worker internals ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The changeset follows its user-visible CPU statement with details about assigning directories to
workers, serial entry processing, and kernel lock arbitration. Those sentences describe the internal
scheduling mechanism rather than an observable command, setting, output, or API change.
Code

.changeset/link-one-writer-per-directory.md[5]

+`pnpm install` uses less CPU when it links packages from a warm store. pnpm now links the files of one directory from one worker, one after another, and links different directories in parallel. Before, every worker linked into the same directory at once and the workers queued on the directory lock, which on Windows made a warm install several times slower than on pnpm 11 [#15439](https://github.com/pnpm/pnpm/issues/15439).
Relevance

●●● Strong

Recent changeset precedents consistently require removing internal implementation rationale from
user-facing release notes.

PR-#13658
PR-#15190
PR-#14157

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 3058322 limits changeset entries to observable behavior changes. The entry names the internal
worker allocation, serial processing strategy, and directory-lock contention mechanism in its
release-note prose.

Rule 3058322: Changeset entries must describe observable behavior changes only
.changeset/link-one-writer-per-directory.md[5-5]

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 changeset includes internal worker scheduling and filesystem-lock implementation details after its observable CPU improvement statement. Changeset prose should contain only concrete behavior users can observe.

## Fix Focus Areas
- .changeset/link-one-writer-per-directory.md[5-5]

## Recommended Fix
Rewrite the entry around the measured warm-install CPU improvement and affected `pnpm install` scenario. Move the worker grouping, directory-lock explanation, and implementation comparisons to the commit body or PR description.

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


3. New helper documents old scheduling 📘 Rule violation ⚙ Maintainability
Description
The Rustdoc for entries_by_target_dir records measurements for the replaced one-task-per-file
implementation and compares its former behavior with pnpm v11. Readers changing the current grouping
algorithm must sift through historical benchmark narrative instead of receiving only its present
locking constraint and concurrency guarantee.
Code

pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[R68-71]

+/// the 88k files of a 995-package warm install with one rayon task per
+/// file cost 15 s of system time on Linux against 3 s with one task per
+/// directory (pnpm v11's per-package loop: 2 s), and pnpm/pnpm#15439
+/// reports the per-file fan-out taking five times pnpm v11's wall time
Relevance

●● Moderate

Historical implementation prose is sometimes accepted when rationale matters, despite precedents
also requesting timeless current-behavior comments.

PR-#14012
PR-#14568
PR-#14861

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 772199 prohibits source comments from describing replaced algorithms or historical
implementations. The added Rustdoc explicitly discusses the former one-task-per-file fan-out and its
historical benchmark results.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[61-73]

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 new helper documentation embeds benchmark history and describes the scheduling implementation that this PR removes. Source comments should explain the current invariant rather than preserve historical implementation details.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[61-73]

## Recommended Fix
Replace the historical measurements and comparisons with a concise present-tense explanation that serial placement within each parent avoids directory-lock contention while independent directories can still run in parallel.

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


View medium (1)
4. Copy installs lose file parallelism 🐞 Bug ➹ Performance
Description
populate_dir uses a sequential inner iterator for every operation in a target directory, including
the full file copy performed by copy_file. When Copy is configured—or Auto, Hardlink, or
CloneOrCopy falls back to copying—packages with many files in one directory perform all byte
transfers on one worker, turning directory size into a serial critical path.
Code

pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[R36-39]

+        .try_for_each(|entries| {
+            entries
+                .iter()
+                .try_for_each(|(cleaned_entry, store_path)| {
Relevance

●● Moderate

Performance concerns in deps-restorer are often accepted, but this copy-path consequence lacks a
closely matching precedent.

PR-#14788
PR-#14248

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed outer par_iter schedules only directories, while the inner iter processes every
entry in each directory sequentially. import_into_fresh_target dispatches to the configured import
method, and the copy tier opens and copies the complete source contents before returning; hardlink,
automatic, and clone-or-copy paths can also select that copy implementation. Repair placement
reaches the same import routine through atomic staging, so both fresh and repair paths inherit the
serialization.

pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[34-48]
pnpm/crates/deps-restorer/src/link_file.rs[209-224]
pnpm/crates/deps-restorer/src/link_file.rs[328-346]
pnpm/crates/deps-restorer/src/link_file.rs[374-419]
pnpm/crates/deps-restorer/src/import_indexed_dir/staging.rs[28-50]

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 directory grouping serializes expensive file copies together with cheap directory-entry operations. Copy-based imports therefore lose per-file parallelism whenever many package files share a directory.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[34-48]
- pnpm/crates/deps-restorer/src/link_file.rs[209-224]
- pnpm/crates/deps-restorer/src/link_file.rs[407-419]

## Recommended Fix
Select scheduling based on the effective import tier: retain one-worker-per-directory sequencing for cheap hardlink or clone operations, but preserve bounded per-file parallelism for `Copy` and any method that has fallen back to copying. Add a same-directory, multi-file benchmark covering explicit copy and fallback-to-copy paths to verify that the hardlink improvement does not regress those supported modes.

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



Informational

5. Scheduling regressions can escape tests ✓ Resolved 📜 Skill insight ▣ Testability
Description
entries_are_grouped_by_the_directory_they_land_in only converts entries_by_target_dir output
into sets, without exercising populate_dir, concurrent placement, or filesystem writes. Restoring
per-entry iteration at the production call site would preserve every assertion, while same-directory
worker contention and an invalid final package tree would remain untested.
Code

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/tests.rs[R20-21]

+    let groups: BTreeSet<BTreeSet<&str>> = entries_by_target_dir(&cas_paths, Some("package.json"))
+        .iter()
Relevance

● Weak

Recent repository precedents reject generic requests for additional branch, concurrency, or Codecov
coverage without demonstrated missing behavior.

PR-#15174
PR-#15160
PR-#14256

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rules 3365251 and 3365318 require the regression test to fail when the production fix is removed
and, for changed locking behavior, to exercise competing writes or simulate concurrency while
asserting a valid final state. The test calls the extracted grouping helper directly, but the fix
separately depends on populate_dir consuming those groups as parallel work units around
parent-directory locks; because it performs no placement, synchronization, or final filesystem
validation, it cannot detect restoration of the defective scheduling behavior.

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/tests.rs[12-41]
pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[34-48]
Skill: review-code

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 production change modifies concurrent filesystem placement so `populate_dir` schedules work by target directory and prevents workers from contending within one directory, but the added test only validates grouping data in isolation. Reverting the production call site to per-entry parallelism would leave the test passing, and the test does not verify the resulting package tree.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement/tests.rs[12-41]
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[34-48]

## Recommended Fix
Add a regression test around the production placement path using controlled instrumentation or a test placement implementation. Record or synchronize active placements to prove that entries sharing a parent directory are processed serially, confirm that entries targeting different directories remain eligible for parallel processing, and verify that all expected files are present in the final package tree.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 64 rules
✅ Skills: review-code
Review mode: ⏭️ Skipped: The push only updates comments in a test file and has no behavioral or semantic effect.

Grey Divider

Tip of the day
💡 Did you know, you can choose which labels appear on a finding, and whether they show icons or text

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

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.

The changeset now states only what the user sees: less CPU, and the
old Windows behavior in its own past-tense sentence. The helper's doc
comment keeps the measured comparison that justifies one task per
directory and drops the narrative about the report.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness or repository-rule violations.

Reviews (4) · Last reviewed commit: "test(deps-restorer): keep the writer pro..."

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit d7a1450

@zkochan

zkochan commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

On Qodo's round for 6de1d7f:

  • Release note exposes internals and new helper documents old scheduling: fixed in d7a1450. The changeset now states only what the user sees, and the doc comment keeps just the measured comparison that justifies one task per directory.
  • Windows link regressions go undetected: not acting. The grouping keys are the store index's relative entries, which are always forward-slash paths on every platform, and Path::parent treats / as a separator on Windows too, exactly as the neighbouring create_indexed_dirs already relies on. A backslash fixture would test a form the keys never take. The new test runs in the Windows CI job, which passed on this head.
  • Copy installs lose file parallelism: not acting. Creating the target file takes the same directory lock as linking it, so parallel copies into one directory contend the same way; only the byte transfer would overlap, and the copy tier is the cross-device fallback. Directories still copy in parallel, and pnpm 11 copies a package serially inside one worker as well.

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

@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[bot]
greptile-apps Bot previously approved these changes Sep 24, 2026
@zkochan

zkochan commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

A test-only probe counts the workers placing entries in each target
directory around every placement. The regression test runs
`populate_dir` over two 200-file directories and asserts neither ever
had two writers at once; with the entries of a group fanned out per
file again it reports 21.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@greptile-apps
greptile-apps Bot dismissed their stale review September 24, 2026 01:10

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@zkochan

zkochan commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

On Qodo's round for d7a1450:

  • Scheduling regressions can escape tests: fixed in 329b2d6. A test-only probe now counts the workers placing entries in each target directory around every placement, and the new test runs populate_dir over two 200-file directories and asserts neither ever had two writers at once. With the group's entries fanned out per file again it reports 21 writers in one directory.
  • New helper documents old scheduling: keeping the doc comment as trimmed in d7a1450. It states the invariant and the measurement that justifies it, in the same shape as the numbers on next_auto_tier and place_entry; the narrative about the report is gone.

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 329b2d6

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 05af6ac

@zkochan
zkochan merged commit 0be6224 into main Sep 24, 2026
57 checks passed
@zkochan
zkochan deleted the fix-15439 branch September 24, 2026 05:20
u9g pushed a commit to u9g/pnpm that referenced this pull request Sep 25, 2026
…npm#15455)

`populate_dir` ran one rayon task per file, so a package's files were
linked into the same directory by every worker in the pool at once.
Creating a dirent takes the parent directory's lock on every filesystem
pnpm runs on, so those workers only queued on each other while the
kernel spent CPU arbitrating the queue. On a warm 995-package install
(88k files, hardlink method, 32 CPUs, btrfs) the install spent 15 s of
system time against 2 s for pnpm v11's serial per-package loop, and the
kernel time fell to 1.3 s with a single rayon thread. On NTFS the report
in pnpm#15439 measures the same install at five times pnpm v11's
wall time with the CPU climbing the whole way, which is what that
contention looks like on a filesystem whose per-file operations are
slower.

The entries are now grouped by target directory and each group is placed
by one worker, entry after entry, while directories still import in
parallel. System time on the same install drops to 3 s with no change
in wall time on Linux, and the resulting tree is identical. Grouping by
directory rather than importing a whole package sequentially keeps
intra-package parallelism for packages spread over many directories.

Closes pnpm#15439
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.

pnpm 12 installs ~5x slower than pnpm 11 on Windows (NTFS) when linking a single project from a warm store

2 participants