Repository navigation
perf(lockfile): stream the env document out of the lockfile - #13820
Conversation
`EnvLockfile::read` loaded the whole `pnpm-lock.yaml` into a `String` and sliced the leading env document out of it. Since the switch to the project's package-manager version, that read happens on every command in a project that pins pnpm through `devEngines.packageManager` or a v12+ `packageManager` field — most projects — to consume a document that is a fraction of a percent of the file. Read the file in 64 KB chunks instead, stopping at the separator that closes the env document, and rejecting a lockfile that does not begin with `---\n` as soon as those 4 bytes are in. The cost is now flat in the size of the lockfile: on an 8 MB lockfile, reading the env document takes ~15µs instead of ~390µs. The BOM and CRLF normalization that `normalize_lockfile_content` did over the whole file happens per chunk, withholding a carriage return that ends a chunk until the next one says whether an LF follows it. This mirrors `streamReadFirstYamlDocument` in `pnpm11/lockfile/fs/src/yamlDocuments.ts`, which the TypeScript CLI already uses. Behavior, output, and file format are unchanged in both stacks, so there is nothing to port back. Closes #13819
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe lockfile crate now reads only the leading YAML document in bounded chunks. It handles BOM, CRLF, chunk boundaries, missing documents, interrupted reads, and invalid UTF-8. ChangesEnvironment lockfile streaming
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant EnvLockfile
participant read_env_document
participant read_first_yaml_document
participant LockfileReader
EnvLockfile->>read_env_document: open lockfile with symlink following
read_env_document->>read_first_yaml_document: read first YAML document
read_first_yaml_document->>LockfileReader: read bounded chunks
LockfileReader-->>read_first_yaml_document: return chunked bytes
read_first_yaml_document-->>read_env_document: return document or I/O error
read_env_document-->>EnvLockfile: return environment document or None
Assessment against linked issues
Possibly related PRs
Suggested labels: ✨ 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: stream env YAML document from pnpm-lock.yaml
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
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 @.changeset/stream-env-lockfile-document.md:
- Line 5: Update the bounded-read description to state that the reader consumes
only the initial chunks needed to locate the leading environment document or
determine that it is absent, rather than claiming it reads only the first chunk.
Preserve the performance comparison and user-visible behavior description.
In `@pnpm/crates/lockfile/src/yaml_documents.rs`:
- Around line 86-100: The read_first_yaml_document_in_chunks function must probe
only the minimum bytes needed to validate the YAML document marker, including
BOM and CRLF disambiguation, before switching to READ_BUFFER_SIZE streaming
reads; reject marker-less input after the initial four-byte boundary. Update
pnpm/crates/lockfile/src/yaml_documents.rs lines 86-100 accordingly, and change
pnpm/crates/lockfile/src/yaml_documents/tests.rs lines 132-139 to assert the
bounded initial read limit rather than READ_BUFFER_SIZE.
🪄 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: 2ee25e68-aab7-48c1-94c7-46b0a2f16806
📒 Files selected for processing (5)
.changeset/stream-env-lockfile-document.mdpnpm/crates/cli/src/cli_args/pre_command.rspnpm/crates/lockfile/src/env_lockfile.rspnpm/crates/lockfile/src/yaml_documents.rspnpm/crates/lockfile/src/yaml_documents/tests.rs
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported interrupted-read path now retries while preserving reader and parser state, with regression coverage. Reviews (4): Last reviewed commit: "test(lockfile): log the streamed documen..." | Re-trigger Greptile |
`read_to_string`, which the streaming env-document read replaced, retries a read interrupted by a signal. The chunked loop propagated `EINTR` instead, so a signal arriving mid-read would fail the command. Also state in the changeset that reading stops at the end of the env document, rather than after the first chunk — an env document larger than 64 KB takes more than one.
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pnpm/crates/lockfile/src/yaml_documents.rs (1)
102-104: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRewrite the retry comment to describe current behavior.
The comment refers to the implementation that this code replaced. It also repeats
Read::read_to_stringbehavior. Keep only the reason for the local retry.Proposed comment
- // `Read::read_to_string`, which this replaces on the lockfile - // read path, retries a signal-interrupted read rather than - // failing the command. + // Retry `io::ErrorKind::Interrupted` so a transient signal does + // not abort lockfile loading.As per path instructions, comments must document contracts, non-obvious invariants, workarounds, deliberate exceptions, or unavoidable technical constraints, and must describe current behavior rather than historical implementation details.
🤖 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/lockfile/src/yaml_documents.rs` around lines 102 - 104, Update the retry comment in the lockfile read path to remove the historical `Read::read_to_string` reference and avoid restating its behavior. Keep only the current reason for the local retry, documenting the relevant non-obvious contract or technical constraint.Source: Path instructions
pnpm/crates/lockfile/src/yaml_documents/tests.rs (1)
46-60: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueLog YAML values before assertions
assert_streamscompares multiline and large YAML documents without diagnostic logging. Log the actual and expected values before the relevantassert_eq!calls.🤖 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/lockfile/src/yaml_documents/tests.rs` around lines 46 - 60, Update the test helper assert_streams to log the actual and expected YAML values immediately before each relevant assert_eq! call, including both chunked and non-chunked reads, so multiline or large-document mismatches are diagnosable.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.
Nitpick comments:
In `@pnpm/crates/lockfile/src/yaml_documents.rs`:
- Around line 102-104: Update the retry comment in the lockfile read path to
remove the historical `Read::read_to_string` reference and avoid restating its
behavior. Keep only the current reason for the local retry, documenting the
relevant non-obvious contract or technical constraint.
In `@pnpm/crates/lockfile/src/yaml_documents/tests.rs`:
- Around line 46-60: Update the test helper assert_streams to log the actual and
expected YAML values immediately before each relevant assert_eq! call, including
both chunked and non-chunked reads, so multiline or large-document mismatches
are diagnosable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 29ddcce7-9e4e-4411-8632-37933b6cb5ac
📒 Files selected for processing (3)
.changeset/stream-env-lockfile-document.mdpnpm/crates/lockfile/src/yaml_documents.rspnpm/crates/lockfile/src/yaml_documents/tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- .changeset/stream-env-lockfile-document.md
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13820 +/- ##
========================================
Coverage 88.26% 88.27%
========================================
Files 624 624
Lines 101978 102132 +154
========================================
+ Hits 90014 90156 +142
- Misses 11964 11976 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Micro-Benchmark ResultsLinux |
The retry comment described the read this code replaced instead of the reason for the retry. The streaming test helper compares multiline documents, which the style guide asks to log with `eprintln!` before the assertion so a failure is readable.
Code Review by Qodo
1. Changeset missing pnpm entry
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
Qodo findings from the latest run — neither is being changed: 1. "Changeset missing 2. "Invalid UTF-8 ignored" — the observation is accurate but the outcome is right. The env-document read now validates UTF-8 only for the bytes it returns; a file with no closing Written by an agent (Claude Code, claude-opus-5). |
Understood. Based on the repository guidance and the implementation context:
No code changes are needed for either finding. |
|
Code review by qodo was updated up to the latest commit 174f88f |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Logging every comparison dumped the 150 KB fixture once per chunk size on a passing run, which buries the one comparison a reader needs when it fails. Log both documents from the failing comparison instead.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
On the latest Qodo run: findings 1 and 2 are the same two settled above — the changeset is Rust-only by design, and the UTF-8 behavior is intentional. Finding 3 ("verbose test logging") is fixed in 25bf6ec. The unconditional logging came from a CodeRabbit nitpick asking for the style guide's Written by an agent (Claude Code, claude-opus-5). |
|
Code review by qodo was updated up to the latest commit 25bf6ec |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
On the micro-benchmark numbers:
Happy to re-run the benchmark job if a maintainer wants a second sample. Written by an agent (Claude Code, claude-opus-5). |
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.98676857014,
"stddev": 0.20062437409103143,
"median": 2.9840695244399997,
"user": 3.1786229199999996,
"system": 2.4089758799999994,
"min": 2.67254880044,
"max": 3.31840489944,
"times": [
3.31840489944,
3.16000284644,
2.95665873844,
3.00554209044,
3.04114254044,
2.96259695844,
2.67254880044,
2.72112233144,
3.16744616244,
2.86222033344
]
},
{
"command": "pacquet@main",
"mean": 2.6057062228400003,
"stddev": 0.17274701573391962,
"median": 2.56939587094,
"user": 2.05351962,
"system": 1.5220825799999997,
"min": 2.38608628144,
"max": 2.86711077844,
"times": [
2.84638729144,
2.55208070644,
2.58671103544,
2.45318722444,
2.4630607214399998,
2.46394888844,
2.38608628144,
2.74529995544,
2.69318934544,
2.86711077844
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5928890232400001,
"stddev": 0.16333094111308916,
"median": 1.5699131454400002,
"user": 1.1891808199999998,
"system": 1.25777908,
"min": 1.37767891744,
"max": 1.8207382164400001,
"times": [
1.44804471544,
1.77491459144,
1.8207382164400001,
1.58453841344,
1.6800465684399999,
1.44229657544,
1.45802563744,
1.55528787744,
1.37767891744,
1.78731871944
]
},
{
"command": "pnpr@main",
"mean": 1.5631573690400002,
"stddev": 0.1454758566400991,
"median": 1.53131773794,
"user": 1.2178540199999999,
"system": 1.21238758,
"min": 1.3873060984399999,
"max": 1.8154292334400002,
"times": [
1.8154292334400002,
1.69658705244,
1.7161943984399999,
1.3873060984399999,
1.44407549744,
1.49902223344,
1.6195794344399999,
1.56361324244,
1.49599806444,
1.39376843544
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2792104924,
"stddev": 0.038401094008801435,
"median": 0.26972685040000005,
"user": 0.23035690000000003,
"system": 0.55960246,
"min": 0.2397435384,
"max": 0.35127905940000004,
"times": [
0.26652258940000007,
0.2590177584,
0.27293111140000004,
0.2466993594,
0.24018973640000002,
0.2397435384,
0.28214310840000006,
0.33259416740000003,
0.35127905940000004,
0.30098449540000005
]
},
{
"command": "pacquet@main",
"mean": 0.2878035236,
"stddev": 0.015029595217456608,
"median": 0.29018921090000005,
"user": 0.2493768,
"system": 0.55594376,
"min": 0.2589575344,
"max": 0.3137873144000001,
"times": [
0.29712779440000003,
0.3137873144000001,
0.2898778114,
0.29678666440000007,
0.29190688040000007,
0.27218780540000004,
0.28834857040000006,
0.27855425040000004,
0.2905006104,
0.2589575344
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30986929420000003,
"stddev": 0.011134005166199076,
"median": 0.3119235709,
"user": 0.2624307,
"system": 0.5832982600000001,
"min": 0.29054647640000003,
"max": 0.32903248840000004,
"times": [
0.31057425240000003,
0.30432174240000004,
0.30951345040000006,
0.29054647640000003,
0.2947824304000001,
0.31736573440000004,
0.31327288940000003,
0.31346925740000003,
0.31581422040000007,
0.32903248840000004
]
},
{
"command": "pnpr@main",
"mean": 0.3927285408000001,
"stddev": 0.025683025950549176,
"median": 0.3964017839,
"user": 0.3624123,
"system": 0.73389546,
"min": 0.34883441940000004,
"max": 0.42401548240000003,
"times": [
0.34883441940000004,
0.4016577424000001,
0.3521640214,
0.38904015140000003,
0.40327692340000004,
0.4238907874000001,
0.39114582540000004,
0.42401548240000003,
0.4060341894000001,
0.38722586540000004
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.74717683806,
"stddev": 0.07763094774616573,
"median": 2.70861746196,
"user": 1.9851908199999997,
"system": 1.6549877999999996,
"min": 2.68149446696,
"max": 2.9018510149599996,
"times": [
2.68245822996,
2.70945670296,
2.70180063496,
2.77422933696,
2.70777822096,
2.9018510149599996,
2.76267060496,
2.85944345696,
2.6905857109599998,
2.68149446696
]
},
{
"command": "pacquet@main",
"mean": 2.70149392316,
"stddev": 0.06130370966509728,
"median": 2.67630175446,
"user": 1.9546095199999995,
"system": 1.5736736,
"min": 2.6459806479599997,
"max": 2.84479172796,
"times": [
2.65940183396,
2.66214791196,
2.6459806479599997,
2.6824186229599998,
2.67018488596,
2.6648170949599996,
2.69768086696,
2.7262772539599998,
2.84479172796,
2.76123838496
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6785069486600002,
"stddev": 0.17402828692267122,
"median": 1.7530483969600001,
"user": 1.18331162,
"system": 1.2880468999999999,
"min": 1.4576986279600002,
"max": 1.8853987319600003,
"times": [
1.5046329559600002,
1.49572136796,
1.8753337739600002,
1.7366009769600002,
1.7694958169600001,
1.79786263796,
1.4576986279600002,
1.7864778509600001,
1.47584674596,
1.8853987319600003
]
},
{
"command": "pnpr@main",
"mean": 1.59501384586,
"stddev": 0.12645648936868825,
"median": 1.5326346069600003,
"user": 1.25863762,
"system": 1.3920952,
"min": 1.4738831649600002,
"max": 1.82042698496,
"times": [
1.4738831649600002,
1.4961237549600002,
1.5422502739600001,
1.69813125396,
1.49675208496,
1.6775995379600002,
1.5230189399600003,
1.82042698496,
1.7395693719600003,
1.4823830909600002
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.43802837732000005,
"stddev": 0.017535130266074127,
"median": 0.43030658872000005,
"user": 0.56886332,
"system": 0.7454495,
"min": 0.41875999872,
"max": 0.46319446072000003,
"times": [
0.41878037572000004,
0.41875999872,
0.43347809072000004,
0.45215551872000004,
0.46319446072000003,
0.46287564172,
0.45098996972000005,
0.42713508672000006,
0.42670832672000003,
0.42620630372
]
},
{
"command": "pacquet@main",
"mean": 0.4404896159200001,
"stddev": 0.020618793794719117,
"median": 0.43565630772,
"user": 0.58454462,
"system": 0.7400635999999999,
"min": 0.41492430472,
"max": 0.47344379072000004,
"times": [
0.47344379072000004,
0.41629852472,
0.41492430472,
0.44906546472000003,
0.42504791872000003,
0.45615852772000004,
0.46857275272000004,
0.43553664172,
0.43577597372000004,
0.43007225972
]
},
{
"command": "pnpr@HEAD",
"mean": 0.33470932272000004,
"stddev": 0.01493196632996838,
"median": 0.33203194872,
"user": 0.24773041999999995,
"system": 0.5506024,
"min": 0.31925804972000005,
"max": 0.36996547572000005,
"times": [
0.31977779872,
0.31925804972000005,
0.32927118272,
0.32993111572,
0.32366246672000004,
0.34490858172000005,
0.33413278172000005,
0.33847501172000005,
0.33771076272,
0.36996547572000005
]
},
{
"command": "pnpr@main",
"mean": 0.33512574612,
"stddev": 0.009198203204498613,
"median": 0.33604139772,
"user": 0.24295231999999997,
"system": 0.5637769999999999,
"min": 0.32343491772000005,
"max": 0.35067357272000005,
"times": [
0.34254824572000003,
0.32343491772000005,
0.34028644472,
0.34155521472,
0.35067357272000005,
0.32752861972,
0.34054425872000005,
0.32408772772,
0.33179635072,
0.32880210872000004
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.8089458829199998,
"stddev": 0.03536153997733935,
"median": 1.78979671552,
"user": 0.9341970399999999,
"system": 0.9352794999999998,
"min": 1.77553357602,
"max": 1.8620057330200002,
"times": [
1.77553357602,
1.7873044240200002,
1.7769808550200001,
1.7781525950200001,
1.7922890070200002,
1.8548470470200003,
1.78513799602,
1.8479179430200001,
1.8620057330200002,
1.82928965302
]
},
{
"command": "pacquet@main",
"mean": 1.79627182732,
"stddev": 0.025647256815049604,
"median": 1.7883329245200001,
"user": 0.9378249399999999,
"system": 0.8679767999999999,
"min": 1.7747640660200001,
"max": 1.85934041702,
"times": [
1.80028683902,
1.78818940702,
1.8182724810200002,
1.85934041702,
1.78573713102,
1.77824794502,
1.79336174102,
1.7884764420200001,
1.7760418040200001,
1.7747640660200001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.33691408072,
"stddev": 0.011684533058300625,
"median": 0.34010140252000004,
"user": 0.24499304,
"system": 0.5707513000000001,
"min": 0.31313337402,
"max": 0.35282017202000004,
"times": [
0.34444117802,
0.34273619402000005,
0.35282017202000004,
0.32968735802000004,
0.32986772802000003,
0.31313337402,
0.32828399202,
0.34073878902000004,
0.33946401602000004,
0.34796800602000005
]
},
{
"command": "pnpr@main",
"mean": 0.35339914802000005,
"stddev": 0.018940356682277462,
"median": 0.35195861902000003,
"user": 0.26027524,
"system": 0.5870008999999999,
"min": 0.32815323602,
"max": 0.38155152002000003,
"times": [
0.32815323602,
0.34777013302000004,
0.33165926302000004,
0.36108249902,
0.33563982302,
0.38155152002000003,
0.35614710502,
0.38082970402000005,
0.36425362802000005,
0.34690456902000005
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2740026633,
"stddev": 0.018836609820814698,
"median": 0.27713426560000004,
"user": 0.24947934,
"system": 0.07590316,
"min": 0.2419875601,
"max": 0.30669990410000003,
"times": [
0.30669990410000003,
0.28810518510000005,
0.28283649410000006,
0.2419875601,
0.2609050861,
0.27837722610000004,
0.28512758010000006,
0.26762757810000004,
0.27589130510000004,
0.25246871410000005
]
},
{
"command": "pacquet@main",
"mean": 0.24649836128181815,
"stddev": 0.020440251877844852,
"median": 0.2416080571,
"user": 0.22065668545454545,
"system": 0.08418226909090909,
"min": 0.2195911681,
"max": 0.28350111310000004,
"times": [
0.25878497110000004,
0.28350111310000004,
0.2384286431,
0.2371522951,
0.2195911681,
0.2416080571,
0.2249975771,
0.2559840191,
0.2311289561,
0.24288792210000001,
0.2774172521
]
},
{
"command": "pnpr@HEAD",
"mean": 0.09854811009999999,
"stddev": 0.004837720515582572,
"median": 0.09664490410000001,
"user": 0.027812243448275854,
"system": 0.011850222068965518,
"min": 0.09163683310000001,
"max": 0.1106275371,
"times": [
0.0957740371,
0.10600779610000001,
0.1028125431,
0.09655953310000001,
0.0999804521,
0.10160631510000001,
0.09765488110000001,
0.09440694810000001,
0.10615642510000001,
0.09761899410000001,
0.09643010010000001,
0.09408307010000001,
0.0968712481,
0.09664490410000001,
0.0958536271,
0.0955189981,
0.0994835981,
0.10232538710000001,
0.1106275371,
0.1103119441,
0.10019822110000001,
0.0950120651,
0.0964510291,
0.0926183971,
0.0957482691,
0.09163683310000001,
0.0992018491,
0.0958812691,
0.09441892110000001
]
},
{
"command": "pnpr@main",
"mean": 0.09357883089310344,
"stddev": 0.002300534742639964,
"median": 0.0928388021,
"user": 0.02472127793103448,
"system": 0.01126832551724138,
"min": 0.0904337731,
"max": 0.0984749221,
"times": [
0.0965729681,
0.0938423381,
0.0915648891,
0.09154286710000001,
0.09309271910000001,
0.0928388021,
0.09623479310000001,
0.09683112410000001,
0.0946524301,
0.09271869610000001,
0.09118686810000001,
0.0917904821,
0.09179460010000001,
0.0959033501,
0.09253561210000001,
0.0914025331,
0.09103355010000001,
0.09130457010000001,
0.0904337731,
0.09086505310000001,
0.09404465810000001,
0.09493580210000001,
0.09577013910000001,
0.09807522210000001,
0.0984749221,
0.09530670910000001,
0.0921840921,
0.0923351961,
0.0945173361
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.2843089573533335,
"stddev": 0.3604455549931562,
"median": 1.2768491990200002,
"user": 1.2916758644444446,
"system": 0.18727625999999997,
"min": 0.7901901570200001,
"max": 2.11074932802,
"times": [
1.33835227702,
1.2389852810200002,
1.15456070002,
0.7901901570200001,
0.9953656550200001,
2.11074932802,
1.2768491990200002,
1.3670861340200002,
1.28664188502
]
},
{
"command": "pacquet@main",
"mean": 1.2681776815755557,
"stddev": 0.27796327155696904,
"median": 1.2048073220200002,
"user": 1.292848308888889,
"system": 0.17409114888888888,
"min": 0.87266319002,
"max": 1.76239428702,
"times": [
1.76239428702,
1.1017381590200002,
1.2048073220200002,
0.87266319002,
1.32853812102,
1.6349365740200001,
1.27869294402,
1.1301388090200002,
1.0996897280200002
]
},
{
"command": "pnpm@HEAD",
"mean": 3.4380317512422223,
"stddev": 0.20178354586003697,
"median": 3.54574312702,
"user": 5.348600531111111,
"system": 0.30117603777777774,
"min": 3.13993136102,
"max": 3.71639357302,
"times": [
3.71639357302,
3.54574312702,
3.21867455302,
3.13993136102,
3.33527974902,
3.2604304910199997,
3.60169458902,
3.56006110502,
3.56407721302
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.5249879019399994,
"stddev": 0.10371141465888725,
"median": 4.47670132804,
"user": 1.9953441199999997,
"system": 1.5516316399999999,
"min": 4.44620023104,
"max": 4.7227054630400005,
"times": [
4.51530541404,
4.50574107004,
4.7227054630400005,
4.71299289004,
4.47303933104,
4.44620023104,
4.46317545404,
4.46133951504,
4.48036332504,
4.46901632604
]
},
{
"command": "pacquet@main",
"mean": 4.6447610919399995,
"stddev": 0.20680890084696732,
"median": 4.580176310040001,
"user": 2.23679142,
"system": 1.6313243399999997,
"min": 4.4371145080400005,
"max": 5.13307320804,
"times": [
4.73527756104,
4.49605244204,
4.57370529804,
4.4371145080400005,
4.51477841404,
4.78000782004,
4.58664732204,
4.48460595604,
4.7063483900400005,
5.13307320804
]
},
{
"command": "pnpr@HEAD",
"mean": 3.6342397909399997,
"stddev": 0.11798892900790195,
"median": 3.61826190304,
"user": 1.5984800200000002,
"system": 1.60422734,
"min": 3.50094515304,
"max": 3.91428609804,
"times": [
3.50094515304,
3.59334658304,
3.91428609804,
3.65211245204,
3.53299704804,
3.53437661004,
3.63143228504,
3.6050915210400003,
3.68387685604,
3.69393330304
]
},
{
"command": "pnpr@main",
"mean": 3.84582459824,
"stddev": 0.09153055844996541,
"median": 3.8354416985400004,
"user": 2.17699402,
"system": 2.15536674,
"min": 3.72881788704,
"max": 4.03481091704,
"times": [
3.81938431904,
3.7572994410400002,
3.72881788704,
3.8514990780400002,
3.81832335704,
3.7645545680400003,
3.93887827604,
3.8724806050400002,
3.87219753404,
4.03481091704
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13820 |
| 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,457.70 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 313.13 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 319.26 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 91.64 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,377.68 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,500.95 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 290.55 ms |
|
Same for the integrated report ( Mechanically it cannot be this change. That scenario is a full cold install; Written by an agent (Claude Code, claude-opus-5). |
Summary
EnvLockfile::readloaded the wholepnpm-lock.yamlinto aStringand sliced the leading env document out of it. Since the switch to the project's package-manager version, that read happens on every command in a project that pins pnpm (devEngines.packageManager, or apackageManagerfield with a v12+ major) — most projects — to consume a document that is a fraction of a percent of the file. In this repository the env document is 2,915 bytes of an 821,592-byte lockfile.This ports
streamReadFirstYamlDocumentfrompnpm11/lockfile/fs/src/yamlDocuments.ts, which the TypeScript CLI already uses: read in 64 KB chunks, reject a file that does not begin with---\nas soon as those 4 bytes are in, and return as soon as the\n---\nthat closes the env document is found. The cost is now flat in the size of the lockfile — reading the env document out of an 8 MB lockfile takes ~15µs instead of ~390µs, and the whole-file UTF-8 validation and the second full copy thatnormalize_lockfile_contentallocated on a CRLF checkout are both gone.BOM stripping and CRLF normalization happen per chunk instead of over the whole file, withholding a carriage return that ends a chunk until the next chunk says whether an LF follows it.
The other
EnvLockfile::readcallers —self_update,with,audit, and the env-installer — get the win for free.This is a pure perf gap in the Rust stack. Behavior, output, and file format are identical in both stacks, so there is nothing to mirror on the TypeScript side.
Closes #13819
Squash Commit Body
Checklist
already linked to it solves it.
pnpm/port, or the description notes what still needs porting. (TheTypeScript CLI already streams the env document; this brings the Rust port
in line. Nothing to port back.)
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-opus-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Performance
Reliability