Repository navigation
refactor(resolving-npm-resolver): share the metadata response decode across both fetchers - #17028
Conversation
…across both fetchers The cached fetcher (FetchAttempt::run with DecodeMeta) and the plain fetcher that the release-age upgrade uses (document_from_response with decode_full_metadata) each had their own copy of the 2xx path: - the status check - the body read, with the client downscale on timeout - the permit release - the off-reactor parse - dropping incomplete publish times - abbreviated normalization - the slow-request timer and warning A fix to that path had to be made twice. #16647 was one such fix. decode_metadata_response now does it once. It takes the response with its network permit, the normalization choice from MirrorWrite, and a `finish` step that runs on the blocking pool. The plain fetcher passes `Ok`. The cached fetcher passes MirrorStore::store, which keeps DecodeMeta's filter-and-persist half. The 304 handling stays separate, because the two fetchers mean different things by it. The cached fetcher serves its mirror, and the plain fetcher returns NotModified to its caller. The plain fetcher had no test for normalization. A new test covers it, and inverting the flag in the shared function now fails tests in both fetchers. No behavior changes. Part of pnpm/tasks#146. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
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 and injected workspace scenarios compare 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.4023063281600003,
"stddev": 0.11376901443706196,
"median": 2.35283819066,
"user": 1.4068002599999998,
"system": 1.5680120800000001,
"min": 2.29963024066,
"max": 2.60877939866
},
{
"command": "pacquet@main",
"mean": 2.3976696410600002,
"stddev": 0.1311035139016915,
"median": 2.3160158921600003,
"user": 1.4383528599999997,
"system": 1.48623218,
"min": 2.29853242166,
"max": 2.64897080866
},
{
"command": "pnpr@HEAD",
"mean": 1.4580570822600003,
"stddev": 0.10666911102751798,
"median": 1.4508595691600001,
"user": 1.29062206,
"system": 1.44132678,
"min": 1.31599790366,
"max": 1.6155449726600002
},
{
"command": "pnpr@main",
"mean": 1.43021538756,
"stddev": 0.09736326384797325,
"median": 1.4023771961600002,
"user": 1.34637066,
"system": 1.4816761800000002,
"min": 1.33711426466,
"max": 1.66970990666
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.23188839205999998,
"stddev": 0.014377597233277601,
"median": 0.22460444536000002,
"user": 0.26020083999999993,
"system": 0.57250488,
"min": 0.21607011536,
"max": 0.25635163736
},
{
"command": "pacquet@main",
"mean": 0.23906015516000007,
"stddev": 0.014878064650829156,
"median": 0.23497453986,
"user": 0.27103823999999993,
"system": 0.59038338,
"min": 0.22321059836,
"max": 0.27215826436
},
{
"command": "pnpr@HEAD",
"mean": 0.32078270986000007,
"stddev": 0.08670648555859391,
"median": 0.27209045136,
"user": 0.35268833999999993,
"system": 0.7366019799999999,
"min": 0.24017619236,
"max": 0.44037343836000004
},
{
"command": "pnpr@main",
"mean": 0.25023971746,
"stddev": 0.003722908510460677,
"median": 0.24995447336,
"user": 0.27831463999999995,
"system": 0.59173728,
"min": 0.24361887436000002,
"max": 0.25576532836
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.007971194486710095,
"stddev": 0.00037377607653401327,
"median": 0.00793517706,
"user": 0.00468790918566775,
"system": 0.003931059804560259,
"min": 0.00732054006,
"max": 0.01010368606
},
{
"command": "pacquet@main",
"mean": 0.007969787161851856,
"stddev": 0.0003178232695181301,
"median": 0.00794788006,
"user": 0.005024906913580248,
"system": 0.0036127672839506185,
"min": 0.00729512206,
"max": 0.009467630060000001
},
{
"command": "pnpr@HEAD",
"mean": 0.008177290551071428,
"stddev": 0.0003514122909792563,
"median": 0.008133524060000001,
"user": 0.004770255238095238,
"system": 0.004216563333333333,
"min": 0.007343713060000001,
"max": 0.01029039806
},
{
"command": "pnpr@main",
"mean": 0.00789496616094637,
"stddev": 0.0004673098630375564,
"median": 0.00783530806,
"user": 0.004702854006309148,
"system": 0.003936276593059936,
"min": 0.006975190060000001,
"max": 0.010668519060000001
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.00871126484757202,
"stddev": 0.000851341204951639,
"median": 0.00855362772,
"user": 0.005264391028806585,
"system": 0.004230619423868312,
"min": 0.007065018720000001,
"max": 0.01071641372
},
{
"command": "pacquet@main",
"mean": 0.008297679221718209,
"stddev": 0.0008112180112143046,
"median": 0.00805322672,
"user": 0.005002397731958763,
"system": 0.0040467083161512,
"min": 0.007138095720000001,
"max": 0.01192358372
},
{
"command": "pnpr@HEAD",
"mean": 0.008089452518534797,
"stddev": 0.0007148178932174632,
"median": 0.00793302072,
"user": 0.00519504476190476,
"system": 0.003602753699633698,
"min": 0.0071265437200000005,
"max": 0.011759023720000001
},
{
"command": "pnpr@main",
"mean": 0.008487201248735633,
"stddev": 0.00064093098641839,
"median": 0.00834235972,
"user": 0.005068875632183909,
"system": 0.004225422222222223,
"min": 0.007232132720000001,
"max": 0.01030015072
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.63752252414,
"stddev": 0.12555704841152374,
"median": 2.58692065094,
"user": 2.28133024,
"system": 2.1991513400000002,
"min": 2.55766986394,
"max": 2.97314180094
},
{
"command": "pacquet@main",
"mean": 2.5797421420399997,
"stddev": 0.0396752100101316,
"median": 2.56532753894,
"user": 2.1139232400000005,
"system": 2.0346382399999996,
"min": 2.54363319894,
"max": 2.6788097579400003
},
{
"command": "pnpr@HEAD",
"mean": 1.5522216203399999,
"stddev": 0.10845457409163156,
"median": 1.52134374544,
"user": 1.34504284,
"system": 1.6674602399999998,
"min": 1.45308768994,
"max": 1.8032295279400001
},
{
"command": "pnpr@main",
"mean": 1.5214152866400001,
"stddev": 0.08623786030697336,
"median": 1.47428452694,
"user": 1.40300844,
"system": 1.66128074,
"min": 1.46128683994,
"max": 1.7168171279400002
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.7074127557400001,
"stddev": 0.1580661182157861,
"median": 0.60396552694,
"user": 1.07102674,
"system": 1.33231036,
"min": 0.56547256794,
"max": 0.9383527409400001
},
{
"command": "pacquet@main",
"mean": 0.59511308754,
"stddev": 0.020680539829271184,
"median": 0.60454397294,
"user": 0.8902738399999999,
"system": 1.11294506,
"min": 0.55885529194,
"max": 0.6162403709400001
},
{
"command": "pnpr@HEAD",
"mean": 0.36769748804,
"stddev": 0.012055751142733363,
"median": 0.36648292694000006,
"user": 0.31812574,
"system": 0.8050536599999999,
"min": 0.34819187294000004,
"max": 0.38850663394
},
{
"command": "pnpr@main",
"mean": 0.4050584621400001,
"stddev": 0.07861742808231008,
"median": 0.37216674144000006,
"user": 0.36510934,
"system": 0.8942609600000001,
"min": 0.35138874094000005,
"max": 0.55446111494
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.6518375397599996,
"stddev": 0.015494236807545882,
"median": 1.65566360176,
"user": 0.94121228,
"system": 1.0241679600000002,
"min": 1.62548361276,
"max": 1.67593242976
},
{
"command": "pacquet@main",
"mean": 1.6554751231599998,
"stddev": 0.015957977308009866,
"median": 1.65278364326,
"user": 0.9635421799999999,
"system": 1.04957956,
"min": 1.63526334776,
"max": 1.6795396787599999
},
{
"command": "pnpr@HEAD",
"mean": 0.32128612966000003,
"stddev": 0.00874370869840712,
"median": 0.32290942526,
"user": 0.27202257999999996,
"system": 0.68316766,
"min": 0.30781161076,
"max": 0.33226855376000003
},
{
"command": "pnpr@main",
"mean": 0.32279753416,
"stddev": 0.008988840278564466,
"median": 0.32424500176000004,
"user": 0.29323158000000005,
"system": 0.6753446599999999,
"min": 0.31130413476,
"max": 0.33455656576000004
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.22513347508,
"stddev": 0.011890714928503906,
"median": 0.22328896458000003,
"user": 0.19029869999999996,
"system": 0.08992676666666666,
"min": 0.20772536708,
"max": 0.24888819008000002
},
{
"command": "pacquet@main",
"mean": 0.21928158958,
"stddev": 0.013076481723621,
"median": 0.22176621808000002,
"user": 0.18612111666666667,
"system": 0.08944076666666666,
"min": 0.19854994008000001,
"max": 0.23774666508
},
{
"command": "pnpr@HEAD",
"mean": 0.09204113636125003,
"stddev": 0.003322635428927837,
"median": 0.09170142858000001,
"user": 0.03203541874999999,
"system": 0.015510503124999997,
"min": 0.08742148308,
"max": 0.09897074308
},
{
"command": "pnpr@main",
"mean": 0.0906728759832258,
"stddev": 0.002472167441961141,
"median": 0.09121160808,
"user": 0.030137329032258058,
"system": 0.015540454838709677,
"min": 0.08680385908,
"max": 0.09723658708
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2251123041155555,
"stddev": 0.01298009624478285,
"median": 0.22236640156,
"user": 0.22663328222222223,
"system": 0.052821966666666664,
"min": 0.20893957756,
"max": 0.24786457256000002
},
{
"command": "pacquet@main",
"mean": 0.21914323833777777,
"stddev": 0.010765731585060972,
"median": 0.21577094756,
"user": 0.22474239333333332,
"system": 0.04698596666666667,
"min": 0.20821820156,
"max": 0.24137670256000002
},
{
"command": "pnpm@HEAD",
"mean": 3.428703626004445,
"stddev": 0.061081036664432105,
"median": 3.41508534356,
"user": 5.222742948888889,
"system": 0.3697951888888888,
"min": 3.3170693465600003,
"max": 3.51837211556
}
]
}Scenario: Isolated linker: linked-workspace resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.21632776571333334,
"stddev": 0.02322938778951441,
"median": 0.20797319158,
"user": 0.1725859,
"system": 0.07979355333333332,
"min": 0.18927515358,
"max": 0.25066533858
},
{
"command": "pacquet@main",
"mean": 0.24203229212545455,
"stddev": 0.01393668233322171,
"median": 0.24207954158,
"user": 0.19521422727272728,
"system": 0.08779596545454546,
"min": 0.22172706658,
"max": 0.25983366258
}
]
}Scenario: Isolated linker: injected workspace repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.08390036640631579,
"stddev": 0.016133405424546148,
"median": 0.07810940288000001,
"user": 0.032494293684210536,
"system": 0.058578850526315784,
"min": 0.07111393388000001,
"max": 0.14177593088
},
{
"command": "pacquet@main",
"mean": 0.1196523182713043,
"stddev": 0.014063896328203231,
"median": 0.11405625188,
"user": 0.04833097217391304,
"system": 0.08217279217391303,
"min": 0.09880780788,
"max": 0.14381773188000002
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.403309173619999,
"stddev": 0.09530293811696845,
"median": 4.37487094882,
"user": 1.38588502,
"system": 1.4366561199999999,
"min": 4.31954476682,
"max": 4.62495238382
},
{
"command": "pacquet@main",
"mean": 4.44610246142,
"stddev": 0.14468690310610924,
"median": 4.37412607882,
"user": 1.45500992,
"system": 1.4014490199999998,
"min": 4.31549969882,
"max": 4.7857939408200005
},
{
"command": "pnpr@HEAD",
"mean": 3.4550617731199997,
"stddev": 0.0704900943475606,
"median": 3.4233276648200004,
"user": 1.33236822,
"system": 1.36333972,
"min": 3.3933219238200003,
"max": 3.58472945482
},
{
"command": "pnpr@main",
"mean": 3.53566188012,
"stddev": 0.12718902865697687,
"median": 3.47504203732,
"user": 1.3925789199999998,
"system": 1.3286928199999999,
"min": 3.4101815328200002,
"max": 3.76318899982
}
]
}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.19588421849,
"stddev": 0.011694307939869216,
"median": 0.19705244574000003,
"user": 0.22744587333333333,
"system": 0.19677719000000002,
"min": 0.16397437424000003,
"max": 0.20929086624
},
{
"command": "pacquet@main",
"mean": 0.2091994274542857,
"stddev": 0.023595469960076644,
"median": 0.21059745574000002,
"user": 0.23705825428571425,
"system": 0.19859343999999998,
"min": 0.17275915424000002,
"max": 0.24324214824000004
},
{
"command": "pnpr@HEAD",
"mean": 0.15633617866857144,
"stddev": 0.04122566485885682,
"median": 0.13483412324000002,
"user": 0.17268589714285718,
"system": 0.14508465428571427,
"min": 0.12338607924,
"max": 0.25777509924
},
{
"command": "pnpr@main",
"mean": 0.13220592681142856,
"stddev": 0.005976328286074361,
"median": 0.13232708224000003,
"user": 0.15058746857142852,
"system": 0.13258713047619047,
"min": 0.11864745324,
"max": 0.14307143324000002
}
]
}Scenario: Store only: unlocked direct deps, cold cache + hot storeStore-only install (
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.1164842776600001,
"stddev": 0.015368765780836369,
"median": 1.1122286369599999,
"user": 0.50275572,
"system": 0.19202711999999994,
"min": 1.09466596396,
"max": 1.14173539796
},
{
"command": "pacquet@main",
"mean": 1.13642892386,
"stddev": 0.06601166603034532,
"median": 1.11514661996,
"user": 0.5362646200000001,
"system": 0.20513711999999998,
"min": 1.0666075959599999,
"max": 1.3057284549600001
}
]
} |
Micro-Benchmark ResultsLinux |
|
The Code Coverage failure on this head is That test fails whenever its lockfile mtime lands on an exact second, about once in a thousand runs. I reproduced it locally by forcing that case, and the fix is in #17031. I've re-run the failed job here. Written by an agent (Claude Code, claude-opus-5-5). |
|
@coderabbitai review |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17028 +/- ##
==========================================
- Coverage 92.54% 92.54% -0.01%
==========================================
Files 1776 1776
Lines 228560 228496 -64
==========================================
- Hits 211519 211455 -64
Misses 17041 17041 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
PR Summary by QodoShare metadata response decoding between cached and plain fetchers
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can see how risky a PR is at a glance with blast radius labels |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
…second mtimes (#17031) Two tests date the lockfile MTIME_STEP_MS past the recorded timestamp, the time setup wrote the files. About once in a thousand runs that mtime lands on an exact second. The freshness check reads it as whole-second precision, so the first check cannot record a timestamp past it, and the second check compares the poisoned lockfile and reports it outdated. date_lockfile_after moves an exact-second mtime one millisecond earlier. Seen in Code Coverage on #17028.
Summary
Second step of pnpm/tasks#146 (Related to pnpm/tasks#146), following #17024. It addresses the task's "v12 has two request pipelines" item. There is no behavior change.
v12 has two metadata fetchers: the cached one (
FetchAttempt) and the plain one (fetch_full_metadata), which theminimumReleaseAgeupgrade uses. Each had its own copy of the 2xx path:spawn_blockingparsedrop_incomplete_publish_times#16647 had to fix that path in both places.
Now
decode_metadata_responsedoes it once, and each fetcher supplies only what differs:finishstep on the blocking poolOkMirrorStore::store(filter + persist, the rest of the oldDecodeMeta)The 304 handling stays per fetcher. The cached fetcher serves its mirror, and the plain fetcher returns
NotModifiedto its caller.Tests. The plain fetcher had no normalization test, so I added one. Inverting the normalization flag in the shared function now fails tests in both fetchers. Before, only the cached fetcher's tests caught it. All 614 tests of
pnpm-resolving-npm-resolverpass.Still open on the task. These are left for later PRs:
decide()over the pick layers.No changeset, since nothing changes for users.
Squash Commit Body
Checklist
already linked to it solves it.
are implemented in every affected version.
Written by an agent (Claude Code, claude-opus-5-5).
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit