Repository navigation
perf(resolver): reuse cached metadata when the lockfile decides a range - #16460
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Repository: pnpm/pnpm/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
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)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe resolver evaluates multiple lockfile selectors when identifying stable cached range picks. It also checks package-specific release-age policy when deciding whether a cached packument can provide a stable pick or requires a registry request. ChangesCached metadata reuse
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant PackagePicker
participant PackagePickPolicy
participant Mirror
participant Registry
PackagePicker->>PackagePickPolicy: Check release-age applicability for package
PackagePicker->>Mirror: Read cached packument
alt Policy does not apply
Mirror-->>PackagePicker: Return cached packument for selection
else Policy applies
PackagePicker->>Registry: Request packument
Registry-->>PackagePicker: Return packument response
end
Possibly related PRs
Suggested labels: Merge Risk: ⚪ Minimal · up to Cached metadata reuse preserves release-age checks for nonexempt packages while allowing package-wide exemptions. No actionable merge-blocking risk remains, subject to normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Version-selection and release-age safeguards remain in place. However, additional private-registry resolutions can now succeed from previously cached metadata without detecting revoked access. The exposure is limited to an existing cache namespace; whether this behavior is permitted needs clarification. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
✨ Finishing Touches🧪 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 |
PR Summary by QodoReuse cached registry metadata for lockfile-decided ranges
AI Description
Diagram
High-Level Assessment
Files changed (14)
|
Code Review by Qodo
1.
|
|
Code review by qodo was updated up to the latest commit 02fc715 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16460 +/- ##
=======================================
Coverage 92.17% 92.17%
=======================================
Files 1519 1520 +1
Lines 204884 204843 -41
=======================================
- Hits 188856 188821 -35
+ Misses 16028 16022 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.4167960289,
"stddev": 0.12395775915897268,
"median": 2.4011063198,
"user": 1.3372650400000001,
"system": 1.4245713000000002,
"min": 2.2791030828000003,
"max": 2.6847047398
},
{
"command": "pacquet@main",
"mean": 2.3305670285,
"stddev": 0.09723981369859927,
"median": 2.2976182568,
"user": 1.3476891400000004,
"system": 1.3026820999999997,
"min": 2.2544438408,
"max": 2.5880230898
},
{
"command": "pnpr@HEAD",
"mean": 1.3663563887000003,
"stddev": 0.07390854484507375,
"median": 1.3244309178,
"user": 1.15231494,
"system": 1.2322098999999997,
"min": 1.2985640398,
"max": 1.5007318078000003
},
{
"command": "pnpr@main",
"mean": 1.4631281899000002,
"stddev": 0.1307650375669981,
"median": 1.4346495883000001,
"user": 1.37342214,
"system": 1.4102655,
"min": 1.3293130488,
"max": 1.7114791898000001
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.3317425153800001,
"stddev": 0.05709928122213641,
"median": 0.36022251538000005,
"user": 0.38359108,
"system": 0.7761435799999999,
"min": 0.24698151138000002,
"max": 0.3847371733800001
},
{
"command": "pacquet@main",
"mean": 0.26783901928000003,
"stddev": 0.011107324187312232,
"median": 0.26688887188,
"user": 0.31040448,
"system": 0.6373967799999999,
"min": 0.24559235838000001,
"max": 0.28797066438
},
{
"command": "pnpr@HEAD",
"mean": 0.28586053698,
"stddev": 0.012231780980653514,
"median": 0.28759459338000004,
"user": 0.30845488000000004,
"system": 0.6253026799999999,
"min": 0.26730825938,
"max": 0.30819113138000004
},
{
"command": "pnpr@main",
"mean": 0.2639655523800001,
"stddev": 0.024407246217806516,
"median": 0.25860859788,
"user": 0.28821477999999995,
"system": 0.5854430799999999,
"min": 0.23751426738,
"max": 0.32857517738
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.009507567986482213,
"stddev": 0.0012803971960509257,
"median": 0.00939593386,
"user": 0.005757831146245058,
"system": 0.004599486956521738,
"min": 0.0074004058600000006,
"max": 0.01572514086
},
{
"command": "pacquet@main",
"mean": 0.008885784781348325,
"stddev": 0.0009827945503263261,
"median": 0.008883961860000001,
"user": 0.005675703670411981,
"system": 0.0040304636704119835,
"min": 0.00715173886,
"max": 0.01452464686
},
{
"command": "pnpr@HEAD",
"mean": 0.00881970454421052,
"stddev": 0.0010159099908367414,
"median": 0.008614785860000002,
"user": 0.005073203467492263,
"system": 0.004535253869969038,
"min": 0.0073075818600000005,
"max": 0.01447444286
},
{
"command": "pnpr@main",
"mean": 0.00995765056847458,
"stddev": 0.0010750661869742934,
"median": 0.00983669986,
"user": 0.0060104942372881396,
"system": 0.004840302372881355,
"min": 0.007823038860000001,
"max": 0.013471424860000001
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.010450700404977375,
"stddev": 0.003218378883946697,
"median": 0.0093464555,
"user": 0.0063844407239818995,
"system": 0.004892440180995476,
"min": 0.0079407765,
"max": 0.024123206500000004
},
{
"command": "pacquet@main",
"mean": 0.00957418522932331,
"stddev": 0.0009609982947814107,
"median": 0.009453405,
"user": 0.005755354586466167,
"system": 0.004724993233082708,
"min": 0.007834516500000001,
"max": 0.0139251045
},
{
"command": "pnpr@HEAD",
"mean": 0.008588208603053437,
"stddev": 0.0016526132479288242,
"median": 0.0080034335,
"user": 0.004986237557251913,
"system": 0.0043480786259542,
"min": 0.0066233035,
"max": 0.0155781765
},
{
"command": "pnpr@main",
"mean": 0.009401128698347106,
"stddev": 0.0009403562524922738,
"median": 0.009336761,
"user": 0.005349387768595042,
"system": 0.004886093719008264,
"min": 0.0073342775,
"max": 0.0129411795
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.77366157166,
"stddev": 0.16743317358895046,
"median": 2.73019391496,
"user": 2.55698124,
"system": 2.02206332,
"min": 2.58744939596,
"max": 3.16196290296
},
{
"command": "pacquet@main",
"mean": 2.63632292366,
"stddev": 0.024010111885453274,
"median": 2.63253376496,
"user": 2.28078194,
"system": 1.71941312,
"min": 2.60683281896,
"max": 2.67208158596
},
{
"command": "pnpr@HEAD",
"mean": 1.5690823660600002,
"stddev": 0.10956864209170869,
"median": 1.5416897249600001,
"user": 1.4161890400000001,
"system": 1.4494264200000002,
"min": 1.4479411219600002,
"max": 1.8003625239600003
},
{
"command": "pnpr@main",
"mean": 1.6931805477600002,
"stddev": 0.11733709842091351,
"median": 1.70464384896,
"user": 1.4707457400000001,
"system": 1.5073406199999997,
"min": 1.49528480796,
"max": 1.8255525139600002
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5519079572800001,
"stddev": 0.06731311514417895,
"median": 0.55495304948,
"user": 0.7600780800000001,
"system": 0.8843019,
"min": 0.42834080298000005,
"max": 0.62718742998
},
{
"command": "pacquet@main",
"mean": 0.48051521178000006,
"stddev": 0.039504757065099295,
"median": 0.48781917998,
"user": 0.6632730800000001,
"system": 0.7586331000000002,
"min": 0.41495203698000005,
"max": 0.52292008698
},
{
"command": "pnpr@HEAD",
"mean": 0.31393092478000006,
"stddev": 0.004803366389929634,
"median": 0.31340295898000003,
"user": 0.27085877999999997,
"system": 0.6231688,
"min": 0.30709027098,
"max": 0.32104116698
},
{
"command": "pnpr@main",
"mean": 0.30997316598,
"stddev": 0.007860140314873294,
"median": 0.30795101198,
"user": 0.28935138,
"system": 0.57561,
"min": 0.30012191498,
"max": 0.32351414098000003
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.62792002112,
"stddev": 0.024092426498537326,
"median": 1.62630172262,
"user": 0.8552652399999999,
"system": 0.8689605799999999,
"min": 1.58626266762,
"max": 1.68008976062
},
{
"command": "pacquet@main",
"mean": 1.6617487203199999,
"stddev": 0.08088449364231604,
"median": 1.63555835412,
"user": 0.9173769399999999,
"system": 0.9620497799999999,
"min": 1.58657764662,
"max": 1.8154711316199998
},
{
"command": "pnpr@HEAD",
"mean": 0.28980507722000004,
"stddev": 0.004054550373770692,
"median": 0.29042195262000003,
"user": 0.25432654,
"system": 0.5796459799999999,
"min": 0.28193569362,
"max": 0.29743657662
},
{
"command": "pnpr@main",
"mean": 0.28721963521999994,
"stddev": 0.010163365481983133,
"median": 0.28948268662,
"user": 0.24173163999999997,
"system": 0.5720314799999999,
"min": 0.26667137162,
"max": 0.30167514162000003
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.23772051452666662,
"stddev": 0.033063149750770016,
"median": 0.22542881526000003,
"user": 0.20603729333333337,
"system": 0.08702947333333334,
"min": 0.18699768926000002,
"max": 0.33238360526000005
},
{
"command": "pacquet@main",
"mean": 0.21846041011714287,
"stddev": 0.017231616498329046,
"median": 0.21771205176000002,
"user": 0.19760384571428566,
"system": 0.08892926857142859,
"min": 0.19835752826,
"max": 0.25937673326
},
{
"command": "pnpr@HEAD",
"mean": 0.09153351329225806,
"stddev": 0.0021781231295633172,
"median": 0.09219486326000001,
"user": 0.03169623741935484,
"system": 0.01382314645161291,
"min": 0.08712830326000001,
"max": 0.09601402626000001
},
{
"command": "pnpr@main",
"mean": 0.09195973426000002,
"stddev": 0.003673257531907867,
"median": 0.09175032626,
"user": 0.032921140645161294,
"system": 0.013289296774193552,
"min": 0.08733774626,
"max": 0.10210909826
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.22085617929333334,
"stddev": 0.01129216653032598,
"median": 0.21687323796000002,
"user": 0.22603715777777778,
"system": 0.05574241333333333,
"min": 0.20878301896,
"max": 0.24608394096000002
},
{
"command": "pacquet@main",
"mean": 0.22356953107111113,
"stddev": 0.008484613773835147,
"median": 0.22226021196,
"user": 0.23171782444444444,
"system": 0.046689302222222215,
"min": 0.21255437896,
"max": 0.24179995796
},
{
"command": "pnpm@HEAD",
"mean": 3.56303025696,
"stddev": 0.08790822714685348,
"median": 3.53610401696,
"user": 5.527619157777776,
"system": 0.3554101911111111,
"min": 3.4535078159599997,
"max": 3.6893342529599997
}
]
}Scenario: Isolated linker: linked-workspace resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25916363510000007,
"stddev": 0.042164744335098585,
"median": 0.2662613211,
"user": 0.1886975285714286,
"system": 0.11110470285714287,
"min": 0.19732735310000002,
"max": 0.31960180410000005
},
{
"command": "pacquet@main",
"mean": 0.2529790487,
"stddev": 0.042767317895974495,
"median": 0.26893323560000004,
"user": 0.2007174,
"system": 0.10029256,
"min": 0.1958511081,
"max": 0.31429024510000003
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.62172947434,
"stddev": 0.051648835087203186,
"median": 4.60023288294,
"user": 2.3361955599999997,
"system": 2.1607587800000005,
"min": 4.56758856044,
"max": 4.71236513844
},
{
"command": "pacquet@main",
"mean": 4.67928145484,
"stddev": 0.20516600144660893,
"median": 4.60289489044,
"user": 2.1815581599999994,
"system": 2.0288361800000003,
"min": 4.47090567244,
"max": 5.01863462544
},
{
"command": "pnpr@HEAD",
"mean": 3.62019176704,
"stddev": 0.06795321269889053,
"median": 3.6075088599400003,
"user": 2.02417946,
"system": 1.8187206799999998,
"min": 3.54709371644,
"max": 3.75339205044
},
{
"command": "pnpr@main",
"mean": 3.65245138614,
"stddev": 0.0661982845994286,
"median": 3.67449657594,
"user": 2.00674126,
"system": 1.83976168,
"min": 3.5273865084400002,
"max": 3.75389418644
}
]
}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.1413594129355556,
"stddev": 0.004532886836427837,
"median": 0.14023775388,
"user": 0.17665051333333334,
"system": 0.14742406,
"min": 0.13571843788000001,
"max": 0.15145800988000002
},
{
"command": "pacquet@main",
"mean": 0.1423386549355556,
"stddev": 0.0057307922511884305,
"median": 0.14171687588,
"user": 0.16998712444444444,
"system": 0.15302772666666664,
"min": 0.13566122188000002,
"max": 0.15402050088000002
},
{
"command": "pnpr@HEAD",
"mean": 0.15080019821333338,
"stddev": 0.011601154384760951,
"median": 0.15306576888,
"user": 0.1790250466666667,
"system": 0.15286572666666667,
"min": 0.13073265688000002,
"max": 0.16915521688000001
},
{
"command": "pnpr@main",
"mean": 0.16840967052705885,
"stddev": 0.0347071491790992,
"median": 0.14863455888000002,
"user": 0.1998615917647059,
"system": 0.16175047176470586,
"min": 0.13315330188000002,
"max": 0.23609872488000003
}
]
} |
02fc715 to
f50dacd
Compare
|
Code review by qodo was updated up to the latest commit f50dacd |
1 similar comment
|
Code review by qodo was updated up to the latest commit f50dacd |
f50dacd to
2086f8e
Compare
|
Re the Qodo review, as of 2086f8e:
|
|
Code review by qodo was updated up to the latest commit 2086f8e |
1 similar comment
|
Code review by qodo was updated up to the latest commit 2086f8e |
The stable cached-range proof from pnpm#13980 lets a range pick skip registry revalidation when the preferred versions prove that no version missing from the cached packument can win. It only fired for exactly one exact selector at the lockfile weight, and not at all under minimumReleaseAge. autoDedupe reopens every package with several locked versions, and a workspace that sets minimumReleaseAge usually excludes its own scopes, so most of its re-picks paid a conditional request. Prove the pick from every exact selector the range admits, at any positive weight. The winner is the one with the highest guaranteed weight, its own selector plus every range it satisfies. That weight must exceed what range and tag selectors could give any other version, and every other exact selector must stay below it with every tag's weight added, so a tie never qualifies. A version published after the packument was cached can then not change the winner. With a single exact selector at the lockfile weight this is the previous proof; the winner may now also outrank other locked versions. The proof also covers the lone plain selector of a direct dependency kept at its locked version (pnpm#16424). Treat a package that minimumReleaseAgeExclude lists without versions as unrestricted by the cutoff, since the picker ignores the cutoff for it. One helper now answers this for the stable-range proof, the unverified in-memory cache guard, the fresh ETag-less mirror shortcut, the publishedBy mtime shortcut and the release-age metadata upgrade. An exclusion that names versions still revalidates. An add test counted the install's refetch of such a package's packument; the young mirror its selectors wrote now answers the install, so the test expects one fetch. As in pnpm#13980, the proof covers versions published after the packument was cached, so only an unpublish can change the answer later. The TypeScript resolver has the same single-version and minimumReleaseAge limits in its stable cached-range proof. They are not changed here. Related to pnpm#16458
2086f8e to
1e37e14
Compare
|
Code review by qodo was updated up to the latest commit 1e37e14 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
release_age_applies_to now runs on several cache fast paths per pick. PackageVersionPolicy::matches merges and clones the exact versions of every matching rule, which this check never reads. Add covers_every_version, which stops at the first bare-name or wildcard rule that matches and allocates nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Code review by qodo was updated up to the latest commit e096eb0 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Review status as of e096eb0 (rebased onto current Qodo findings:
No work remains within the scope of this PR. Written by an agent (Claude Code, claude-opus-5-5). |
Brings main up to 17e8a01 (#16460). None of the merged commits touch the resolver crate; the merge is conflict-free. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYTBQo8HY7xD2iz6hjo1CW
Summary
Related to #16458. This PR fixes the registry revalidation part. #16461 fixes the no-op re-resolution.
A range pick can skip registry revalidation when the lockfile preferences prove that the cached packument already gives the answer: the stable cached-range proof from #13980. That proof missed three common cases. As a result,
autoDedupere-picks, and installs in workspaces that setminimumReleaseAge, revalidated packuments for picks the lockfile already decided:minimumReleaseAgeis set. The proof was off even for names thatminimumReleaseAgeExcludelists without a version, which the picker already treats as having no cutoff.Changes:
The proof.
dominant_lockfile_versionnow builds the proof in one pass from every exact selector the range admits, at any positive weight.Release-age exemption.
PackagePickPolicy::release_age_applies_totreats a name thatminimumReleaseAgeExcludelists without versions as unrestricted. Five checks now use it:An exclusion that names versions still revalidates.
One updated test.
add_reuses_shared_packument_state_for_every_selector_pathnow expects one fetch. The package is exempt fromminimumReleaseAge, so the install reuses the young mirror its selectors wrote.The resolved output does not change. Only the number of requests does.
Benchmarks
Measured on
mainatbb11485b0, on a Mac M4, online with a warm metadata cache. Lockfiles were byte-identical across builds.Reproduction repository: 20 alternating runs, median.
--auto-dedupe--auto-dedupeOur private monorepo: 3 runs, median.
--auto-dedupe--auto-dedupeTrade-off
As in #13980, the proof covers versions published after the packument was cached, so only an unpublish can change the answer later.
pnpm v11
This is a v12 performance change, not a shared bug fix: the resolved output is identical, and only the number of conditional metadata requests drops. The TypeScript resolver keeps the single-version and
minimumReleaseAgelimits incanReuseStableCachedRange(pnpm11/resolving/npm-resolver/src/pickPackage.ts) andgetDominantLockfileVersion(pnpm11/resolving/npm-resolver/src/dominantLockfileVersion.ts). Most of the gain depends on v12-only behavior:autoDedupe, and the locked direct-dependency selector from #16424.Squash Commit Body
Checklist
already linked to it solves it.
are implemented in every affected version. (A v12 performance change; see "pnpm v11" above.)
pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Summary by CodeRabbit
pnpm installnow reuses cached registry metadata more often when the lockfile determines which version satisfies a range, reducing unnecessary registry requests.