Repository navigation
Conversation
`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]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
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 configurationConfiguration used: Repository: pnpm/pnpm/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthrough
ChangesPackage placement
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Assessment against linked issues
Merge Risk: ⚪ Minimal · up to The placement change is ready to merge after normal checks; no actionable merge-blocking risk is identified. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Micro-Benchmark ResultsLinux |
Same-run regression checkHEAD 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.
Integrated-Benchmark Report (Linux)Commit: 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
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
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
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
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
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
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
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
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
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
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
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 storeSame 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.
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
}
]
} |
PR Summary by QodoReduce warm-install contention with per-directory file linking
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1.
|
PR Code Suggestions ✨Warning
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]>
|
|
Code review by qodo was updated up to the latest commit d7a1450 |
|
On Qodo's round for 6de1d7f:
Written by an agent (Claude Code, claude-fable-5-1). |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
@coderabbitai review |
|
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]>
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
On Qodo's round for d7a1450:
Written by an agent (Claude Code, claude-fable-5-1). |
|
Code review by qodo was updated up to the latest commit 329b2d6 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Code review by qodo was updated up to the latest commit 05af6ac |
…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
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: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 resultingnode_moduleshas the same file, symlink and directory counts before and after. Understrace -c, the meanlinkatcost 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-materialpackage 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
tryImportIndexedDiralready 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_dirover 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
Checklist
already linked to it solves it.
are implemented in every affected version.
pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-fable-5-1).
🤖 Generated with Claude Code
Summary by CodeRabbit