Repository navigation
Conversation
Stop retaining packument bodies in the install-scoped metadata cache (#13681). Version fragments now hydrate on demand through the loaded mirror's held-open file handle instead of anonymous buffers; warm loads parse only the header and index records, and cold fetches return the just-persisted mirror in its file-backed form so the response body drops at write time. The soft RLIMIT_NOFILE is raised once toward the hard limit to cover the held descriptors. Peak RSS on the issue's repro: 3.18 GB -> 1.31 GB (warm offline resolve), 3.33 GB -> 1.86 GB (cold online resolve); a full cold install stays under 2 GB. Wall time unchanged in a 6-run A/B. Co-Authored-By: Claude Fable 5 <[email protected]>
The rustdoc gate rejects a public item linking to the private FragmentSource enum; the inode-pinning rationale now lives on PackageVersions::from_file_spans. Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughIndexed registry mirrors now keep metadata fragments as file-backed spans. Version data loads on demand through positioned file reads. Successful mirror persistence reloads the file-backed representation, with tests covering hydration, fallback buffering, and invalid spans. ChangesFile-backed mirror metadata
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Resolver
participant load_meta
participant MirrorFile
participant PackageVersions
Resolver->>load_meta: Load indexed mirror
load_meta->>MirrorFile: Read bounded header and index records
load_meta->>PackageVersions: Create file-backed or raw-fragment spans
PackageVersions->>MirrorFile: Read requested fragment range
MirrorFile-->>PackageVersions: Return fragment JSON
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ 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 |
PR Summary by Qodoperf(resolver): lazily hydrate cached packument versions from on-disk mirrors
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (7): Last reviewed commit: "docs(registry): state one cursor contrac..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm/crates/resolving-npm-resolver/src/mirror.rs`:
- Around line 541-560: In the mirror-reading flow, obtain the file size and
return a cache miss when fragment_base exceeds it before allocating records.
Move the file.metadata check currently after deserialization ahead of the
records Vec allocation, while preserving the existing Arc-wrapping and
subsequent parsing behavior.
In `@pnpm/crates/resolving-npm-resolver/src/mirror/tests.rs`:
- Around line 152-189: The test load_meta_survives_mirror_rewrite currently
permits eager body caching, so add a test hook or fixture that makes reading
version fragments before loaded.versions.get("1.0.0") fail. Keep the real
TempDir setup, perform the mirror overwrite as before, and ensure the assertion
triggers deferred hydration only when accessing the version so the test fails
with the old from_buffer_spans behavior while still verifying rewrite safety.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3b3fe83e-645b-4e3e-9d7e-36c98b6dbff0
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (7)
.changeset/mirror-file-span-metadata.mdpnpm/crates/registry/src/package_versions.rspnpm/crates/resolving-npm-resolver/Cargo.tomlpnpm/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rspnpm/crates/resolving-npm-resolver/src/mirror.rspnpm/crates/resolving-npm-resolver/src/mirror/tests.rspnpm/crates/resolving-npm-resolver/src/pick_package.rs
Code Review by Qodo
1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13686 +/- ##
==========================================
- Coverage 88.16% 88.13% -0.03%
==========================================
Files 612 612
Lines 99579 99717 +138
==========================================
+ Hits 87791 87889 +98
- Misses 11788 11828 +40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Micro-Benchmark ResultsLinux |
…ndles Review follow-ups for the file-backed metadata cache: reject declared header/index lengths that exceed their bounds or the actual file size before allocating (a corrupted or hostile mirror could otherwise drive an arbitrarily large allocation), and count held mirror handles against a descriptor-budget cap — a load past the cap buffers its fragments and closes the file instead of letting a full cache turn File::open failures into cache misses elsewhere. Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
|
On the micro-benchmark bot's numbers: those deltas are shared-runner noise — the same run reports
which matches the end-to-end result (6-run A/B of the issue repro's warm offline resolve: ~5.2 s on both binaries). The macOS test failure is Written by an agent (Claude Code, claude-fable-5). |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pnpm/crates/registry/src/package_versions.rs (1)
107-122: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winBound each indexed fragment before allocation.
The loader validates that a span ends within
file_size, but it permits an individuallenup tou32::MAX. A corrupt sparse mirror can therefore reachFileSpan::jsonand request a multi-gigabyte allocation. This can terminate the process before the fragment read reports an error.
pnpm/crates/registry/src/package_versions.rs#L107-L122: reject spans above a defined fragment-size limit before constructingFileSpan, and use fallible allocation when reading the accepted span.pnpm/crates/resolving-npm-resolver/src/mirror/tests.rs#L199-L205: add a sparse-mirror fixture with a valid header and index but an over-limit fragment span. Assert thatload_metareturnsNonewithout hydration.As per path instructions, treat mirror spans and declared lengths as untrusted input and bound allocations.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm/crates/registry/src/package_versions.rs` around lines 107 - 122, The FragmentSource loader must bound untrusted fragment lengths before allocation. In pnpm/crates/registry/src/package_versions.rs:107-122, define and enforce a fragment-size limit before constructing FileSpan, and make FragmentSource::json use fallible allocation for accepted spans; in pnpm/crates/resolving-npm-resolver/src/mirror/tests.rs:199-205, add a sparse-mirror fixture with a valid header and index but an over-limit fragment span, asserting load_meta returns None without hydration.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@pnpm/crates/registry/src/package_versions.rs`:
- Around line 107-122: The FragmentSource loader must bound untrusted fragment
lengths before allocation. In
pnpm/crates/registry/src/package_versions.rs:107-122, define and enforce a
fragment-size limit before constructing FileSpan, and make FragmentSource::json
use fallible allocation for accepted spans; in
pnpm/crates/resolving-npm-resolver/src/mirror/tests.rs:199-205, add a
sparse-mirror fixture with a valid header and index but an over-limit fragment
span, asserting load_meta returns None without hydration.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: a74efa1b-162f-4141-8d05-2020d03158ab
📒 Files selected for processing (4)
pnpm/crates/registry/src/lib.rspnpm/crates/registry/src/package_versions.rspnpm/crates/resolving-npm-resolver/src/mirror.rspnpm/crates/resolving-npm-resolver/src/mirror/tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- pnpm/crates/resolving-npm-resolver/src/mirror.rs
|
Code review by qodo was updated up to the latest commit ff31977 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
… limit A sparse mirror makes file size untrustworthy, so each declared fragment span is bounded before FileSpan construction; and the held-handle cap no longer has a floor that could exceed a very low soft descriptor limit. Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
|
Code review by qodo was updated up to the latest commit b406eba |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
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. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time). Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.50265336084,
"stddev": 0.1618023512580806,
"median": 2.42920301944,
"user": 1.7809936,
"system": 1.3837261,
"min": 2.3717658624399998,
"max": 2.78480842344,
"times": [
2.3717658624399998,
2.38011129844,
2.78480842344,
2.40199108744,
2.4564149514399998,
2.64040091044,
2.47642553844,
2.38083326444,
2.75240952444,
2.38137274744
]
},
{
"command": "pacquet@main",
"mean": 2.41531904524,
"stddev": 0.08938400296086497,
"median": 2.35897216544,
"user": 1.6275669000000001,
"system": 1.3665771000000002,
"min": 2.33712143244,
"max": 2.55901500444,
"times": [
2.53063441344,
2.5159922244399997,
2.35220987044,
2.33712143244,
2.34112251444,
2.34773033244,
2.55901500444,
2.35890250744,
2.35904182344,
2.45142032944
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5144771084400002,
"stddev": 0.11945768913914166,
"median": 1.50966966594,
"user": 1.3261718,
"system": 1.3263124999999998,
"min": 1.36272274044,
"max": 1.74833652144,
"times": [
1.51675610844,
1.41335351644,
1.3927342514399998,
1.43415904844,
1.6138960994399998,
1.74833652144,
1.5025832234399998,
1.36272274044,
1.56329302444,
1.59693655044
]
},
{
"command": "pnpr@main",
"mean": 1.63798234524,
"stddev": 0.14233636768286967,
"median": 1.6711551734399999,
"user": 1.6859046,
"system": 1.6038641999999999,
"min": 1.43261622744,
"max": 1.8875310864400001,
"times": [
1.66576703644,
1.76945728044,
1.53645672644,
1.43261622744,
1.69614142444,
1.49609484444,
1.67654331044,
1.8875310864400001,
1.71663610644,
1.50257940944
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2937931965,
"stddev": 0.019115459507020063,
"median": 0.28700276329999996,
"user": 0.24682104,
"system": 0.56319152,
"min": 0.2736828213,
"max": 0.3273809603,
"times": [
0.3097364243,
0.3217849843,
0.2864622363,
0.2875432903,
0.2736828213,
0.2749710093,
0.2846591243,
0.2914140113,
0.3273809603,
0.2802971033
]
},
{
"command": "pacquet@main",
"mean": 0.3011691547,
"stddev": 0.015414173015229382,
"median": 0.2968080513,
"user": 0.25415254,
"system": 0.60970312,
"min": 0.2766503363,
"max": 0.3261337383,
"times": [
0.3261337383,
0.2968841313,
0.3107788513,
0.29054989529999997,
0.2967319713,
0.2869010843,
0.2953552983,
0.2766503363,
0.3168986503,
0.3148075903
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29242089160000007,
"stddev": 0.00990354508399458,
"median": 0.29186205379999997,
"user": 0.24693174,
"system": 0.5458083199999999,
"min": 0.2771826343,
"max": 0.3093446433,
"times": [
0.3031765993,
0.3093446433,
0.2855684673,
0.2829178413,
0.2998708473,
0.2771826343,
0.2867925833,
0.2893081613,
0.2956311923,
0.2944159463
]
},
{
"command": "pnpr@main",
"mean": 0.3086536949,
"stddev": 0.018074722115989168,
"median": 0.3098381658,
"user": 0.24670163999999994,
"system": 0.5831608199999999,
"min": 0.2832599783,
"max": 0.3323031863,
"times": [
0.3027745433,
0.2909817383,
0.2832599783,
0.2954204723,
0.3169017883,
0.3323031863,
0.3187743793,
0.2908812603,
0.3296686013,
0.3255710013
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.64528987786,
"stddev": 0.027173937250398624,
"median": 2.64434704476,
"user": 1.9606602199999998,
"system": 1.5462858599999998,
"min": 2.59232407526,
"max": 2.6903126052600004,
"times": [
2.64824186426,
2.6620866422600002,
2.63712929226,
2.6903126052600004,
2.6591143352600004,
2.6675930942600004,
2.63600033926,
2.6404522252600002,
2.6196443052600005,
2.59232407526
]
},
{
"command": "pacquet@main",
"mean": 2.6279651942600006,
"stddev": 0.022044600301654588,
"median": 2.6278512062600003,
"user": 1.86938382,
"system": 1.4745070599999999,
"min": 2.58966759826,
"max": 2.66975505026,
"times": [
2.60456647826,
2.58966759826,
2.63837789926,
2.6310843962600003,
2.66975505026,
2.6173187382600003,
2.6246180162600004,
2.63724399826,
2.6440643602600002,
2.62295540726
]
},
{
"command": "pnpr@HEAD",
"mean": 1.7188237959600001,
"stddev": 0.13280084023267302,
"median": 1.69169657426,
"user": 1.5839275199999998,
"system": 1.4294253600000002,
"min": 1.5666212562600002,
"max": 1.9205536712600002,
"times": [
1.63694689926,
1.5666212562600002,
1.56673740326,
1.7436023042600002,
1.9205536712600002,
1.6441777882600002,
1.73921536026,
1.62641121026,
1.83344598226,
1.91052608426
]
},
{
"command": "pnpr@main",
"mean": 1.76376656656,
"stddev": 0.13753567015351856,
"median": 1.76318290126,
"user": 1.6854185200000003,
"system": 1.6248966599999999,
"min": 1.54424147626,
"max": 1.95216222926,
"times": [
1.56243661626,
1.82515457226,
1.74112577826,
1.7779692822600002,
1.74839652026,
1.89738042026,
1.54424147626,
1.95216222926,
1.69052889826,
1.89826987226
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5534274801400001,
"stddev": 0.04654600564752713,
"median": 0.54338791574,
"user": 0.7489077799999999,
"system": 0.9159329199999998,
"min": 0.50428678174,
"max": 0.64275982974,
"times": [
0.53180264274,
0.56674253874,
0.55765673974,
0.54218241974,
0.51057532274,
0.54459341174,
0.50428678174,
0.51188108374,
0.62179403074,
0.64275982974
]
},
{
"command": "pacquet@main",
"mean": 0.55124469804,
"stddev": 0.044960967127549295,
"median": 0.54807760624,
"user": 0.7414427800000001,
"system": 0.99247412,
"min": 0.48546085274000006,
"max": 0.61828474174,
"times": [
0.54461203274,
0.53171672574,
0.49574816474000005,
0.48546085274000006,
0.55154317974,
0.59466471474,
0.60340758474,
0.61828474174,
0.56738063974,
0.51962834374
]
},
{
"command": "pnpr@HEAD",
"mean": 0.35244176864,
"stddev": 0.017656389299240738,
"median": 0.35071526774000006,
"user": 0.25997597999999994,
"system": 0.58811592,
"min": 0.32523939674,
"max": 0.38933134674000003,
"times": [
0.38933134674000003,
0.35712586674,
0.35517177774,
0.32523939674,
0.33733529474,
0.35308686374000003,
0.34258578574000004,
0.34834367174,
0.36969555574,
0.34650212674
]
},
{
"command": "pnpr@main",
"mean": 0.36853195624,
"stddev": 0.025747212977743877,
"median": 0.36138578874000005,
"user": 0.26021047999999997,
"system": 0.6553650199999999,
"min": 0.33318930674,
"max": 0.40947290774000006,
"times": [
0.37994805574,
0.36201233474000005,
0.36075924274000004,
0.35237810674000003,
0.34064693674,
0.33318930674,
0.39676255774,
0.40947290774000006,
0.39613029574,
0.35401981774
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.8780314805000002,
"stddev": 0.03146765348334777,
"median": 1.8777645315,
"user": 1.1431681799999998,
"system": 1.0649446399999998,
"min": 1.8270540205,
"max": 1.9221472495,
"times": [
1.8684893145,
1.8415951805000002,
1.8270540205,
1.8733451415000002,
1.8510866615000001,
1.9004604945,
1.9221472495,
1.9084685775,
1.9054842435000001,
1.8821839215
]
},
{
"command": "pacquet@main",
"mean": 1.8344686168,
"stddev": 0.03542887001916729,
"median": 1.8283530325,
"user": 1.00480068,
"system": 0.9789152400000001,
"min": 1.7839210655,
"max": 1.8976439495,
"times": [
1.8757849645000002,
1.8563390285,
1.8035042855,
1.8234555365,
1.8976439495,
1.8122382775,
1.8332505285,
1.7839210655,
1.8076456005,
1.8509029315
]
},
{
"command": "pnpr@HEAD",
"mean": 0.3353181491,
"stddev": 0.011717859773015628,
"median": 0.3345052725,
"user": 0.23773068,
"system": 0.55547374,
"min": 0.3158333025,
"max": 0.35712190450000003,
"times": [
0.35712190450000003,
0.3290390065,
0.3158333025,
0.33025514650000004,
0.34315541650000003,
0.33702446350000004,
0.32491788650000003,
0.3468238195,
0.3323318195,
0.3366787255
]
},
{
"command": "pnpr@main",
"mean": 0.3797710947,
"stddev": 0.01194484163774665,
"median": 0.3776242195,
"user": 0.26882868000000004,
"system": 0.6629259399999999,
"min": 0.3680662505,
"max": 0.39968212750000004,
"times": [
0.36869361650000004,
0.39968212750000004,
0.38825157450000003,
0.3693309845,
0.3755485705,
0.37969986850000004,
0.36966437750000003,
0.3809567245,
0.39781685250000004,
0.3680662505
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2643639899145455,
"stddev": 0.02179691785049322,
"median": 0.25791622646000006,
"user": 0.22325806909090906,
"system": 0.10811872545454544,
"min": 0.24271335746,
"max": 0.31182514946000006,
"times": [
0.24424530946,
0.25065298446000006,
0.26318336946000004,
0.25791622646000006,
0.26673226546000006,
0.24916667146000002,
0.24271335746,
0.25409545346000006,
0.29601299046,
0.31182514946000006,
0.27146011146000004
]
},
{
"command": "pacquet@main",
"mean": 0.22457129337666668,
"stddev": 0.014317097247888428,
"median": 0.22228134296000002,
"user": 0.1985122433333333,
"system": 0.12051451333333335,
"min": 0.20609506546,
"max": 0.26094634846000003,
"times": [
0.23225773346,
0.21980593546000002,
0.21427538746000002,
0.22386896646,
0.21903719846,
0.22127439146,
0.22328829446,
0.26094634846000003,
0.23345675046,
0.23129636746,
0.20609506546,
0.20925308146000002
]
},
{
"command": "pnpr@HEAD",
"mean": 0.09864440309333335,
"stddev": 0.005027765860519229,
"median": 0.09861263296,
"user": 0.025265860000000005,
"system": 0.015396413333333334,
"min": 0.09032231146,
"max": 0.11197869446,
"times": [
0.09288914046,
0.09729081146,
0.09803296246,
0.09126450546,
0.09617131446,
0.10006218846,
0.10462514846,
0.09961361446,
0.11197869446,
0.09979249146000001,
0.10438252246,
0.10142196146,
0.10377045846,
0.09657231446,
0.09470060346,
0.09517070146,
0.09763463346,
0.09211396646,
0.09090091846,
0.09610119046,
0.09919230346,
0.09604496846,
0.10483808646000001,
0.10243351346,
0.09421105546,
0.10534050346,
0.09987847246,
0.10046930946,
0.09032231146,
0.10211142646
]
},
{
"command": "pnpr@main",
"mean": 0.09706782352896556,
"stddev": 0.004158866188767274,
"median": 0.09665383246,
"user": 0.02271805655172414,
"system": 0.01720855931034483,
"min": 0.08997173146,
"max": 0.11225530546,
"times": [
0.09562095846,
0.10237458946,
0.08997173146,
0.09473847146,
0.09713492046,
0.09883622646,
0.09434202246,
0.11225530546,
0.09415934246,
0.09423496046,
0.09692861146,
0.09916297246,
0.10092825246,
0.09719707946,
0.09301683846,
0.09824727246,
0.09410966846,
0.09985638446,
0.09875675346,
0.09681213346,
0.09557887246,
0.09473462846,
0.09970631546,
0.09575991246,
0.09394064546,
0.09665383246,
0.09588122646,
0.10231814246,
0.09170881146
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.7679911774844443,
"stddev": 0.14001366527959289,
"median": 0.73125649504,
"user": 0.7259842644444443,
"system": 0.14066135333333332,
"min": 0.62770153304,
"max": 1.00554930304,
"times": [
0.65414229304,
0.62770153304,
1.00554930304,
0.74316120104,
0.68676728704,
0.91209831304,
0.63722522404,
0.9140189480400001,
0.73125649504
]
},
{
"command": "pacquet@main",
"mean": 1.0390951105955555,
"stddev": 0.24318289736849363,
"median": 0.95856759104,
"user": 0.983282708888889,
"system": 0.2524543533333333,
"min": 0.75463352604,
"max": 1.41285146104,
"times": [
0.76236435604,
0.75463352604,
0.84573766604,
1.1538141930399999,
0.95856759104,
0.93374497904,
1.31822208804,
1.41285146104,
1.21192013504
]
},
{
"command": "pnpm@HEAD",
"mean": 2.946768758817778,
"stddev": 0.08034852493008936,
"median": 2.90639689404,
"user": 4.232194597777776,
"system": 0.2902909088888889,
"min": 2.8701538110400002,
"max": 3.07387329304,
"times": [
3.07387329304,
2.90091841004,
2.93875406404,
2.88093149404,
2.8701538110400002,
3.02387953904,
3.04965842204,
2.8763529020400003,
2.90639689404
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.606315834839999,
"stddev": 0.1627286704157926,
"median": 4.568653358839999,
"user": 1.93220216,
"system": 1.48397992,
"min": 4.4662918413399995,
"max": 4.94501331634,
"times": [
4.609436381339999,
4.8077402953399995,
4.47873577434,
4.4662918413399995,
4.94501331634,
4.4682178623399995,
4.47062783934,
4.62765016834,
4.5278703363399995,
4.66157453334
]
},
{
"command": "pacquet@main",
"mean": 4.499331533039999,
"stddev": 0.12557691005201665,
"median": 4.455456863839999,
"user": 1.8403794599999999,
"system": 1.4144441200000002,
"min": 4.419516315339999,
"max": 4.84038019334,
"times": [
4.5511466683399995,
4.49416790834,
4.84038019334,
4.46129730934,
4.448488569339999,
4.4300091973399995,
4.453631199339999,
4.4572825283399995,
4.43739544134,
4.419516315339999
]
},
{
"command": "pnpr@HEAD",
"mean": 3.58555454444,
"stddev": 0.14562200200542222,
"median": 3.5266832798400003,
"user": 1.3592461599999999,
"system": 1.2740554200000003,
"min": 3.45765025334,
"max": 3.8591858983400003,
"times": [
3.6559159193400004,
3.46659694034,
3.4734088993400003,
3.8591858983400003,
3.79697153034,
3.55541561234,
3.47017722334,
3.62227222034,
3.49795094734,
3.45765025334
]
},
{
"command": "pnpr@main",
"mean": 3.5536798178400004,
"stddev": 0.13156015272778038,
"median": 3.48694264234,
"user": 1.3060688599999997,
"system": 1.2781719200000001,
"min": 3.45960244834,
"max": 3.85338153734,
"times": [
3.85338153734,
3.49097338334,
3.4612868213400003,
3.47579292034,
3.48291190134,
3.46411792634,
3.55073210234,
3.70964703834,
3.45960244834,
3.58835209934
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13686 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,566.62 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 315.83 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 325.24 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 90.32 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,362.72 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,457.65 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 277.18 ms |
Summary
Related to #13681 (the single-importer resolution peak; the multi-importer link-phase burst is discussed below).
Profiling the issue's
@teambit/[email protected]repro attributed the resolution-phase peak to the in-memory packument cache: every consulted packument kept its entire JSON body resident for the whole install — as raw response fragments after a network fetch, or as the whole mirror-file buffer after a warm disk load. The repro's mirror holds 1.7 GB of packument JSON (mostly a few hundred multi-megabyte bit.cloud documents), and a phase-boundary RSS probe showed ~2.4 GB live right after the importer init waves, against a 3.18 GB total peak.This change stops retaining packument bodies:
FragmentSource::FileSpan(replacingBufferSpan): a loaded mirror keeps its file handle open and reads each version fragment on demand with a positioned read. Holding the handle pins the inode — mirror rewrites go through temp-file +rename, so recorded spans can never shift under a reader. Fragment bytes now live in the (reclaimable) page cache instead of anonymous memory.load_meta) parse only the header + index records; the fragment section is never buffered.fetch_full_metadata_cached) and release-age upgrade persists (persist_upgraded_to_mirror) return/cache the just-persisted mirror in its file-backed form, so the multi-megabyte response body drops as soon as it is written instead of living in the packument cache for the rest of the install.RLIMIT_NOFILEis raised once toward the hard limit (the same startup adjustment the Go runtime performs; macOS falls back to the historic 10240 ceiling). Windows needs no adjustment.Measurements
Linux x64, 32 cores, same fixture as the issue (single importer,
@teambit/[email protected], ~3850 packages, hoisted + autoInstallPeers config), peak RSS via/usr/bin/time -v:--lockfile-onlyresolve, warm metadata mirror (offline)--lockfile-onlyresolve, cold metadata (online)The issue's expectation ("peak in the same ballpark as pnpm v10, ≤ ~2 GB for the single-importer repro"; v10's full install measures 2.13 GB there) is met. Wall time is unchanged: 6-run A/B of the warm offline resolve is ~5.2 s for both binaries.
Phase probes after the change put the packument cache at ~0.2 GB; the largest remaining block is the peer-discovery walk state (~0.65 GB at this scale), which is the follow-up lever if more is needed.
Lockfile stability
The emitted lockfile is unchanged modulo a pre-existing race: on this fixture, unmodified
mainalready produces different lockfiles across identical runs (6 runs → 4 distinct hashes;classnames: 2.2.6 ↔ 2.5.1edge flips). The race is arrival-ordered children recording for overlay-affected picks — filed separately with the mechanism and a bounded-fix sketch as #13685. This PR does not change the distribution of outcomes (verified by running both binaries 6×; the hash sets overlap), and byte-compares on race-free fixtures are unaffected — the crate and workspace test suites pass unchanged.On the multi-importer link-phase burst
The issue's second observation (a ~1300-importer workspace bursting 12 GB → 31 GB after downloads complete) could not be reproduced at that scale locally. Two data points from this investigation:
lockfile_to_hoisted_dep_graphover a 343-importer / 6349-snapshot workspace lockfile allocates ~47 MB (10.6k graph nodes).A re-test of the CI workspace against this change would tell how much of the burst remains; the
hoisted_dep_graphre-expansion path deserves its own profiling pass if it still spikes.This is Rust-only: the change is an internal memory representation of the metadata cache (the on-disk mirror format is unchanged), so there is no TypeScript-side behavior to port.
Squash Commit Body
Checklist
already linked to it solves it.
pnpm/port, or the description notes what still needs porting.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).