Skip to content

perf(resolver): share package ids across the occurrences that name them - #13855

Merged
zkochan merged 4 commits into
mainfrom
fix-13681-cycle-cache
Aug 12, 2026
Merged

zkochan merged 4 commits into
mainfrom
fix-13681-cycle-cache

Conversation

@zkochan

@zkochan zkochan commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #13844 on the same workload from #13681.

A workspace has a few thousand distinct pkgIdWithPatchHash values, but the peer walk realizes one occurrence node per distinct root-to-package path — 2,007,292 of them for a 6,133-node graph. Every one of those nodes owned a fresh String copy of its package id, and every parent-context snapshot copied it again.

Changes

  • DependenciesTreeNode::resolved_package_id and ChildEdge::pkg_id become Arc<str>. realize_children now hands over a refcount instead of allocating, and the node shrinks from 56 to 48 bytes. The maps keyed by package id move to Arc<str> keys with it — Arc<str>: Borrow<str> keeps &str lookups working, and Arc<str> hashes as its str, so iteration order is unchanged.
  • ParentPkgInfo::pkg_id follows. Those snapshots held 1,327,035 entries across the walk, each with its own copy of an id that already existed on the tree node it was read from.
  • DepPath gains From<Arc<str>>. It already wraps an Arc<str>, so these conversions stop round-tripping through String and reallocating.

Result

peak RSS
main 3306 / 3236 / 3250 MB
this branch 3008 / 3086 / 3044 MB

3264 → 3046 MB, −6.7%, alternating A/B to control for drift, non-overlapping, 3 of 3.

Cumulative with #13844 the same install has gone 3670 → 3046 MB (−17%).

(The first version of this PR measured −5%. Review caught that the conversion had left Arc::from calls on paths that previously did no allocation at all — comparisons in the cache-matching loop, a double allocation in packages.insert, a &str → String → Arc<str> round-trip. Removing them is what took it to −6.7%.)

Correctness

The lockfile is byte-identical — main twice and this branch once all produced the same file, and the package sets match exactly. (Worth noting given #13846: on this run the engine happened to be deterministic, so the control was clean; that is not always true.)

326 tests pass, plus cargo clippy --all-targets, cargo fmt and cargo dylint clean across the workspace.

Two tests cover the change: the existing footprint assertion drops from 56 to 48 bytes, and realizing_children_shares_the_edge_package_id asserts pointer equality through realize_children_with — the path that creates the two million occurrences — so a future copy fails rather than silently costing memory. I verified it fails when that path is made to copy; the first version of it did not, because it only checked that the constructor kept its argument.

What this still does not fix

The occurrence count itself, which is the remaining ~85%. As measured in #13681, 91% of full walks end in a cycle and cycle-resolved walks are never cached (#5108), so find_hit succeeds 155 times in 188,862 lookups and nearly every occurrence re-walks its subtree. Everything sized by that 2M count — the tree, node_dep_paths, visited_this_call, the three per-node peer maps — stays proportional to it.

Fixing that means caching cycle-resolved verdicts under a key that captures which ancestor repetition truncated the subtree. I have not attempted it because getting the invariant wrong produces wrong lockfiles rather than merely slow ones, and #5108 suggests it is subtle. Still happy to take it on with a steer on the intended rule.

Refs #13681


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Performance Improvements

    • Reduced peak memory usage during dependency resolution by sharing package identifiers across dependency-tree entries.
    • Reduced unnecessary string copying during peer-dependency and workspace resolution.
  • Bug Fixes

    • Maintained existing dependency and peer-resolution behavior while improving identifier handling.
  • Tests

    • Added coverage for shared identifier storage and memory usage.
    • Confirmed dependency graph and lockfile results remain unchanged.

A workspace has a few thousand distinct `pkgIdWithPatchHash` values, but
the peer walk realizes one occurrence node per distinct root-to-package
path — 2,007,292 of them for a 6,133-node graph on the workload in
#13681. Every one of those nodes owned a fresh `String` copy of its
package id, and every parent-context snapshot copied it again.

Holding the id as `Arc<str>` instead makes `realize_children` hand over
a refcount rather than allocate, and shrinks the node from 56 to 48
bytes. The maps keyed by package id move to `Arc<str>` keys with it;
`Arc<str>: Borrow<str>` keeps `&str` lookups working, and `Arc<str>`
hashes as its `str`, so iteration order is unchanged.

`ParentPkgInfo::pkg_id` follows for the same reason: those snapshots
held 1,327,035 entries across the walk, each with its own copy of an id
that already existed on the tree node it was read from.

`DepPath` gains `From<Arc<str>>`. It already wraps an `Arc<str>`, so the
conversions on this path stop round-tripping through `String` and
reallocating.

Peak RSS 3231 -> 3068 MB (-5%, n=3 each, alternating A/B, non-overlapping)
on the same replayed install, with a byte-identical lockfile.

Refs #13681
Copilot AI lite review requested due to automatic review settings August 12, 2026 08:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

perf(resolver): share package ids across peer-walk occurrences

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Share pkgIdWithPatchHash strings across dependency-tree occurrences using Arc.
• Convert package-id keyed maps to Arc while preserving &str lookup behavior.
• Add tests guarding per-node size and pointer-sharing to prevent regressions.
Diagram

graph TD
  A["Peer resolver walk"] --> B["ResolvedTree"] --> C["DependenciesTreeNode"] --> D["ChildEdge"]
  B --> E["WorkspaceTreeCtx"]
  A --> F["DepPath"]
  E --> G[("pkg-id keyed maps")]
  C --> G
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Global string interner for package IDs
  • ➕ Can deduplicate IDs beyond the current walk/snapshots without per-use Arc cloning
  • ➕ Potentially reduces refcount churn if IDs are frequently passed around
  • ➖ Adds a new global/long-lived allocation strategy that must be carefully scoped to avoid leaks
  • ➖ More complex to thread through APIs; harder to reason about lifetimes than Arc
2. Convert remaining peer-walker caches to `Arc` keys
  • ➕ Eliminates remaining to_string() conversions on hot paths (e.g., caches currently keyed by String)
  • ➕ Makes package-id handling uniform across resolver components
  • ➖ Broader API churn and more refactoring risk in cache code
  • ➖ May not materially improve RSS if those maps are small compared to occurrence nodes/snapshots

Recommendation: The Arc approach is a good fit here: it preserves existing hashing/ordering semantics (hashes as str), keeps &amp;str lookups via Borrow, and directly targets the dominant memory waste (millions of duplicated IDs). Consider the additional cache-key conversions only if profiling shows to_string() hot spots remain after this win.

Files changed (20) +344 / -272

Enhancement (10) +151 / -106
dep_path.rsAdd 'From<Arc<str>>' conversion for 'DepPath' +8/-0

Add 'From<Arc<str>>' conversion for 'DepPath'

• Implements 'From<Arc<str>> for DepPath' so callers can transfer an existing shared string without reallocating. This avoids round-tripping through 'String' in hot paths.

pnpm/crates/deps-path/src/dep_path.rs

reuse.rsStore package IDs and child edges as 'Arc<str>' in reuse path +4/-4

Store package IDs and child edges as 'Arc<str>' in reuse path

• Updates package map lookups/inserts to use 'Arc<str>' keys and values, keeping '&str' lookups via 'as_str()'. Converts recorded 'ChildEdge.pkg_id' to shared 'Arc<str>'.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs

walk.rsUse 'Arc<str>' package IDs throughout dependency-tree walk caching +10/-9

Use 'Arc<str>' package IDs throughout dependency-tree walk caching

• Adjusts package/children caches to be keyed by 'Arc<str>' while maintaining string-slice lookup patterns. Ensures created 'ChildEdge' entries and cache entries share IDs instead of allocating new strings.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs

workspace_ctx.rsMigrate workspace caches keyed by pkgId to 'Arc<str>' +45/-31

Migrate workspace caches keyed by pkgId to 'Arc<str>'

• Changes 'WorkspaceTreeCtx' maps/sets keyed by package id ('packages', 'children_specs_by_id', 'children_by_id', 'nodes_by_pkg_id', etc.) to use 'Arc<str>'. Updates snapshotting and incremental sync code paths to clone arcs and keep '&str'-based access working.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs

resolve_importer.rsAdjust snapshot package lookup to accept '&str' against 'Arc<str>' keys +1/-1

Adjust snapshot package lookup to accept '&str' against 'Arc<str>' keys

• Updates importer snapshot lookups to use 'dep.id.as_str()' when indexing 'packages' now keyed by 'Arc<str>'. Behavior is unchanged; only lookup type is updated.

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs

cache.rsAdapt peer cache matching to 'Arc<str>' node/edge IDs +25/-19

Adapt peer cache matching to 'Arc<str>' node/edge IDs

• Updates fast-cache comparisons and lookups to compare 'Arc<str>'-backed IDs correctly without allocating. Ensures missing-peer reporting and chain tracking still operate while minimizing string copies.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs

context.rsShare parent-context package IDs and avoid allocations on membership checks +13/-7

Share parent-context package IDs and avoid allocations on membership checks

• Changes 'ParentPkgInfo.pkg_id' to 'Option<Arc<str>>' so snapshots can reuse existing shared IDs. Adds 'SharedChain::contains_str' to let callers test membership using '&str' without allocating a temporary 'String'.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/context.rs

finalize.rsFinalize peer graph using 'Arc<str>' IDs without extra copies +6/-4

Finalize peer graph using 'Arc<str>' IDs without extra copies

• Adjusts graph node construction to clone shared IDs and convert to 'String' only where the final graph type requires it. Updates edge indexing to use '&str' derived from 'Arc<str>' fields.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rs

walker.rsRealize occurrence nodes by cloning 'Arc<str>' IDs from edges +28/-23

Realize occurrence nodes by cloning 'Arc<str>' IDs from edges

• Updates walker logic to use shared 'Arc<str>' IDs for occurrence nodes and to avoid temporary 'String' allocations where possible. Switches cycle detection/membership checks to the new 'contains_str' helper to prevent incidental allocations.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs

resolved_tree.rsMake package IDs shared ('Arc<str>') across tree, packages, and edges +11/-8

Make package IDs shared ('Arc<str>') across tree, packages, and edges

• Migrates 'ResolvedTree.packages', 'ResolvedTree.children_by_id', 'ResolvedPackage.id', 'ChildEdge.pkg_id', and 'DependenciesTreeNode.resolved_package_id' to 'Arc<str>'. Adds documentation explaining why sharing is critical due to millions of occurrence nodes.

pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs

Tests (9) +188 / -166
tests.rsUpdate workspace ctx tests for 'Arc<str>' IDs +31/-23

Update workspace ctx tests for 'Arc<str>' IDs

• Refactors test fixtures and assertions to construct and compare 'Arc<str>' package IDs. Ensures behavior remains unchanged with the new key/value types.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs

tests.rsUpdate peer cache tests for 'Arc<str>' package map keys +2/-5

Update peer cache tests for 'Arc<str>' package map keys

• Refactors test trees/packages initialization to use 'Arc<str>' keys and idiomatic 'into()' conversions. Keeps assertions equivalent while matching new types.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache/tests.rs

tests.rsUpdate discovery tests to build trees with 'Arc<str>' IDs +5/-4

Update discovery tests to build trees with 'Arc<str>' IDs

• Adds required 'Arc' imports and switches package-id keys to 'Arc<str>'-compatible 'into()'/'Arc::from' constructions. Keeps peer discovery behavior tests intact.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery/tests.rs

tests.rsUpdate finalization tests for 'Arc<str>' package keys/values +22/-22

Update finalization tests for 'Arc<str>' package keys/values

• Converts test data initializers to use 'Arc<str>' keys ('into()') across multiple cases. Keeps semantic coverage while matching the updated 'ResolvedTree' representation.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/tests.rs

test_support.rsSwitch peer test helpers to construct 'Arc<str>' IDs +3/-3

Switch peer test helpers to construct 'Arc<str>' IDs

• Updates helper builders for 'DependenciesTreeNode' and 'ResolvedPackage' to produce 'Arc<str>' IDs. Reduces duplication in tests and aligns fixtures with production types.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/test_support.rs

tests.rsRefactor peer resolver tests for 'Arc<str>' IDs +87/-94

Refactor peer resolver tests for 'Arc<str>' IDs

• Updates many test fixtures to build 'ResolvedTree.packages' with 'Arc<str>' keys and to import 'Arc' where needed. Assertions are adapted to deref 'Arc<str>' fields when comparing to literals.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs

tests.rsUpdate workspace integration tests for 'Arc<str>' child edge IDs +3/-3

Update workspace integration tests for 'Arc<str>' child edge IDs

• Adjusts assertions and iterators to compare 'ChildEdge.pkg_id' by dereferencing 'Arc<str>'. Keeps integration-level behavior expectations unchanged.

pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs

tests.rsTighten node-size budget and assert pointer-sharing of package IDs +23/-3

Tighten node-size budget and assert pointer-sharing of package IDs

• Updates the per-occurrence node footprint assertion from 56 to 48 bytes. Adds a new test that checks 'Arc::ptr_eq' between an edge ID and the realized node’s 'resolved_package_id' to prevent future accidental copying.

pnpm/crates/resolving-deps-resolver/src/resolved_tree/tests.rs

tests.rsUpdate resolver integration tests for shared 'Arc<str>' IDs +12/-9

Update resolver integration tests for shared 'Arc<str>' IDs

• Adjusts multiple tests to compare 'ChildEdge.pkg_id'/'DependenciesTreeNode.resolved_package_id' by dereferencing 'Arc<str>' and to construct expected values with 'into()'. Keeps end-to-end resolver expectations stable while matching new representations.

pnpm/crates/resolving-deps-resolver/src/tests.rs

Documentation (1) +5 / -0
shared-package-ids.mdAdd release note for reduced peer-walk memory usage +5/-0

Add release note for reduced peer-walk memory usage

• Introduces a changeset documenting reduced peak memory during peer dependency resolution by sharing package IDs between edges and realized occurrences.

.changeset/shared-package-ids.md

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ccb5237f-3ce1-4d58-9575-6e74f43307a4

📥 Commits

Reviewing files that changed from the base of the PR and between 0517cb7 and 4caa998.

📒 Files selected for processing (2)
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolved_tree/tests.rs
💤 Files with no reviewable changes (1)
  • pnpm/crates/resolving-deps-resolver/src/resolved_tree/tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs

📝 Walkthrough

Walkthrough

The resolver now stores package identifiers in shared Arc<str> values across resolved trees, workspace indexes, and peer-resolution paths. Tests validate reduced node size and shared allocation reuse. A patch changeset documents the update.

Changes

Shared package identifier storage

Layer / File(s) Summary
Identifier contracts
pnpm/crates/deps-path/src/dep_path.rs, pnpm/crates/deps-path/Cargo.toml, pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs
Public resolver structures and DepPath now support shared Arc<str> package identifiers.
Dependency-tree and workspace integration
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/*, pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs
Dependency-tree traversal, reuse, workspace indexes, synchronization, and importer lookups use shared package-ID keys.
Peer-resolution integration
pnpm/crates/resolving-deps-resolver/src/resolve_peers/{cache,context,finalize,walker}.rs
Peer caches, context, graph finalization, and walking preserve shared identifiers and convert to String at required boundaries.
Validation and release metadata
pnpm/crates/resolving-deps-resolver/**/tests.rs, pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs, .changeset/shared-package-ids.md
Fixtures and assertions use shared identifiers. Tests check node size and pointer reuse. A patch changeset records the update.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • pnpm/pnpm#11915: Both PRs modify dependency-tree representation and package-ID sharing.
  • pnpm/pnpm#13575: Both PRs modify dependency-tree reuse and recorded-child handling.
  • pnpm/pnpm#13835: Both PRs modify dependency-tree resolver paths.

Suggested labels: product: pacquet

Suggested reviewers: greptile-apps

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-13681-cycle-cache

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (4): Last reviewed commit: "test(resolver): assert id sharing throug..." | Re-trigger Greptile

Comment thread pnpm/crates/deps-path/src/dep_path.rs Resolved
@qodo-code-review

qodo-code-review Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (1) 📜 Skill insights (0)

Grey Divider


Action required

1. Allocating Arc in comparisons ✓ Resolved 🐞 Bug ➹ Performance
Description
resolve_peers/cache.rs now builds a fresh Arc<str> from &str in tight loops (cache matching and
parent scans), causing repeated heap allocations/copies on the peer-resolution hot path. This adds
significant allocator/CPU overhead on large graphs and partially defeats the PR’s goal of reducing
per-occurrence work.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[R295-296]

+                    if cached_tree_node.resolved_package_id != Arc::from(child_pkg_id) {
                        return FastCacheMatch::NoMatch;
Relevance

●●● Strong

Perf PRs here routinely accept avoiding extra allocations/probes in tight resolver loops.

PR-#13589

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new code allocates temporary Arc<str> values inside inner loops (peer provider matching and
parent-node scanning). This conflicts with the module’s documented intent to share package ids via
Arc<str> across millions of occurrences and avoid per-occurrence allocations.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[274-307]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[493-510]
pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs[48-58]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`resolve_peers/cache.rs` constructs temporary `Arc<str>` values from `&str` during equality checks, e.g. `Arc::from(child_pkg_id)` and `Arc::from(current_pkg_id)`. Converting `&str -> Arc<str>` allocates and copies, and doing it in the per-peer / per-parent loops introduces avoidable hot-path heap churn.

### Issue Context
These comparisons are against `DependenciesTreeNode.resolved_package_id: Arc<str>`. Equality and hashing already operate on the underlying `str`, so comparisons can be done by borrowing the `Arc<str>` (`as_ref()` / `&*arc`) instead of allocating a new `Arc`.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[290-306]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[503-510]

### Suggested change
- Replace `cached_tree_node.resolved_package_id != Arc::from(child_pkg_id)` with a borrowed comparison like `cached_tree_node.resolved_package_id.as_ref() != child_pkg_id`.
- Replace `node.resolved_package_id == Arc::from(current_pkg_id)` with `node.resolved_package_id.as_ref() == current_pkg_id`.
- Ensure no other `Arc::from(&str)` conversions exist in the peer-walk hot path for package-id comparisons.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset file only declares a version bump for pacquet and omits the required pnpm
package entry, which can lead to an incorrect or missing pnpm release bump for this change.
Code

.changeset/shared-package-ids.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

●●● Strong

Recent reviews accepted adding required pnpm entry alongside pacquet in changeset front-matter.

PR-#13748
PR-#13403

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires changeset front-matter to contain an entry for the pnpm package
with a valid bump type. The added changeset file declares only "pacquet": patch and has no pnpm
entry.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/shared-package-ids.md[1-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new changeset omits a required `pnpm` entry in its front-matter.

## Issue Context
Compliance requires changesets to explicitly include a `pnpm` bump type (`patch`/`minor`/`major`). This PR adds `.changeset/shared-package-ids.md` but only lists `pacquet`.

## Fix Focus Areas
- .changeset/shared-package-ids.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Duplicate package-id Arcs ✓ Resolved 🐞 Bug ➹ Performance
Description
When inserting new packages into WorkspaceTreeCtx::packages, the code allocates two separate
Arc<str> instances from the same id String (one for the HashMap key and one for ResolvedPackage.id).
This keeps an avoidable second allocation per distinct package and reduces the memory/CPU savings
this PR is targeting.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs[R457-461]

        packages.insert(
-            id.clone(),
+            Arc::from(id.clone()),
            ResolvedPackage {
-                id: id.clone(),
+                id: Arc::from(id.clone()),
                result: Arc::clone(&result),
Relevance

●●● Strong

Matches repo pattern of accepting small perf/memory wins in resolver hot paths.

PR-#13431

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Both the tree-walk and reuse paths insert using two independent Arc::from(id.clone()) conversions.
Since ResolvedPackage.id is itself Arc<str>, it can share the same Arc allocation as the map key
via Arc::clone instead of allocating twice.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs[445-466]
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs[565-589]
pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs[148-156]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
On package insertion, the code converts the same `id: String` into `Arc<str>` twice:
- once for the `HashMap<Arc<str>, ResolvedPackage>` key
- once for `ResolvedPackage { id: Arc<str>, ... }`

Each `Arc::from(id.clone())` implies a distinct allocation/copy. This defeats sharing between the key and value for the same package id.

### Issue Context
`ResolvedPackage.id` is already an `Arc<str>`, so it can and should share the same allocation as the map key by using `Arc::clone`.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs[445-466]
- pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs[565-589]

### Suggested change
- Create one `Arc<str>` once, then clone it:
 - `let id_arc: Arc<str> = Arc::from(id.clone());`
 - `packages.insert(Arc::clone(&id_arc), ResolvedPackage { id: id_arc, ... })`
- Apply the same pattern in both `walk.rs` and `reuse.rs`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Manual From<Arc<str>> for DepPath ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
A purely mechanical From<Arc<str>> implementation for the DepPath newtype was added instead of
using derive_more::From, which increases boilerplate and maintenance burden.
Code

pnpm/crates/deps-path/src/dep_path.rs[R41-44]

+    fn from(value: Arc<str>) -> Self {
+        DepPath(value)
+    }
+}
Relevance

●● Moderate

Style/compliance preference, but no clear repo precedent on derive_more::From vs manual impl for
this crate.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2254616 requires mechanical newtype conversions to use derive_more::From/Into
instead of hand-written impls. The added impl From<Arc<str>> for DepPath is a direct wrapper and
qualifies as purely mechanical.

Rule 2254616: Prefer derive_more::From/Into for mechanical newtype conversions
pnpm/crates/deps-path/src/dep_path.rs[38-44]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A mechanical newtype conversion (`From<Arc<str>>`) is implemented manually.

## Issue Context
`DepPath` is a tuple newtype (`pub struct DepPath(Arc<str>);`) and the added conversion body is a direct wrap (`DepPath(value)`). Per compliance, mechanical newtype conversions should use `derive_more::From`/`Into` instead of handwritten impls.

## Fix Focus Areas
- pnpm/crates/deps-path/src/dep_path.rs[15-17]
- pnpm/crates/deps-path/src/dep_path.rs[38-44]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context
✅ Compliance rules (platform): 26 rules

Grey Divider

Tip of the day
💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@github-actions

github-actions Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     12.4±0.29ms    30.3 MB/sec    1.02     12.7±0.90ms    29.6 MB/sec
packument/parse                                  1.03     40.5±0.98µs  1639.0 MB/sec    1.00     39.2±0.46µs  1690.6 MB/sec
tarball/download_dependency                      1.02      2.5±0.15ms  1715.0 KB/sec    1.00      2.5±0.09ms  1746.8 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00    184.3±6.17ms 86.8 KElem/sec    1.07   197.8±23.34ms 80.9 KElem/sec
workspace_resolution/hoist_heavy                 1.00   280.8±13.73ms        ? ?/sec    1.14   320.3±19.17ms        ? ?/sec

@qodo-code-review

qodo-code-review Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Avoid double-allocation by using Arc::from directly on &str

Replace Arc::from(pkg_id.to_string()) with Arc::from(pkg_id) to avoid a
redundant string allocation.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/test_support.rs [20-21]

 pub(super) fn tree_node(
     pkg_id: &str,
     children: Vec<DependenciesTreeNode>,
     depth: i32,
 ) -> DependenciesTreeNode {
     DependenciesTreeNode::new(
-        Arc::from(pkg_id.to_string()),
+        Arc::from(pkg_id),

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 6

__

Why: Using Arc::from directly on a string slice avoids an unnecessary intermediate string allocation, though the impact is minor in test code.

Low
Avoid unnecessary Arc clone before to_string

Call .to_string() directly on the pkg_id reference instead of cloning the Arc
first.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs [682-695]

 let recorded_by_current_owner = record
     .map()
     .get(&**pkg_id)
     .is_some_and(|entry| entry.recorded_by.as_ref() == Some(owner));
 if !recorded_by_current_owner {
     let names = missing_by_pkg
         .get(&**pkg_id)
         .map(|names| names.iter().map(str::to_owned).collect())
         .unwrap_or_default();
     record.map_mut().insert(
-        std::sync::Arc::<str>::clone(pkg_id).to_string(),
+        pkg_id.to_string(),
         OwnerMissingRecord { recorded_by: Some(owner.clone()), names },
     );
 }

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 5

__

Why: Removing the unnecessary Arc::clone before .to_string() slightly improves performance and simplifies the code.

Low
Remove redundant Arc clones before formatting

Remove the redundant Arc::clone and call .to_string() directly on pkg.id.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs [837-850]

 let resolved_through_cycle = parent_pkg_ids_chain.contains_str(&pkg.id);
 if resolved_through_cycle {
     // Leave both caches untouched so later occurrences re-resolve (or
     // hit the authoritative entry of the same package) instead of
     // reusing this partial one.
 } else if is_pure {
     self.pure_pkgs
-        .insert(std::sync::Arc::<str>::clone(&pkg.id).to_string(), dep_path.clone());
+        .insert(pkg.id.to_string(), dep_path.clone());
 } else {
     self.retained_peer_node_ids.extend(all_resolved_peers.values().cloned());
     self.peers_cache
-        .entry(std::sync::Arc::<str>::clone(&pkg.id).to_string())
+        .entry(pkg.id.to_string())
         .or_default()
         .push(PeersCacheItem {

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 5

__

Why: Removing the unnecessary Arc::clone before .to_string() avoids atomic reference counting overhead and cleans up the code.

Low
  • Update

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (2)
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs (1)

295-296: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Compare package IDs as borrowed strings.

Use resolved_package_id.as_ref() at both cache-comparison sites to avoid allocating temporary Arc<str> values.

🤖 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/resolving-deps-resolver/src/resolve_peers/cache.rs` around lines
295 - 296, Update both cache-comparison sites in the peer resolution logic to
compare package IDs as borrowed strings using resolved_package_id.as_ref()
against child_pkg_id. Remove the temporary Arc<str> conversions while preserving
the existing FastCacheMatch::NoMatch behavior.

Sources: Coding guidelines, Path instructions

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs (1)

457-461: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Reuse one package-ID Arc for the map key and package record.

Both insertion paths allocate independent Arc-backed storage for the same package ID.

  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs#L457-L461: create one Arc<str> from id.as_str() and use Arc::clone for the map key and ResolvedPackage.id.
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs#L580-L584: apply the same shared-Arc construction to reused packages.

As per path instructions, pacquet Rust code must preserve ownership while sharing identifiers and use explicit Arc::clone operations.

🤖 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/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs`
around lines 457 - 461, In walk.rs lines 457-461, create one Arc<str> from
id.as_str() and use explicit Arc::clone operations for both the packages map key
and ResolvedPackage.id; apply the same shared-Arc construction in reuse.rs lines
580-584 for reused packages, preserving ownership without independently
allocating the package ID.

Source: Path instructions

🔇 Additional comments (20)
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs (1)

212-212: LGTM!

Also applies to: 243-243, 350-350, 377-380, 556-568, 583-583, 632-636, 648-648, 677-677

pnpm/crates/resolving-deps-resolver/src/resolve_peers/context.rs (1)

57-57: LGTM!

Also applies to: 89-96, 208-208, 294-302, 330-330

pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rs (1)

199-199: LGTM!

Also applies to: 399-399, 631-633, 647-647

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs (1)

161-186: LGTM!

Also applies to: 455-455, 540-543, 582-582, 617-617, 682-683, 698-701, 804-804, 837-856, 1031-1031, 1327-1327

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs (1)

27-27: LGTM!

Also applies to: 37-47, 78-97, 170-170, 198-199, 224-224, 270-270, 314-315, 328-328, 349-349, 370-384, 469-469, 493-493, 647-647, 691-691

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache/tests.rs (1)

24-24: LGTM!

Also applies to: 55-55

pnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery/tests.rs (1)

16-16: LGTM!

Also applies to: 44-50

pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/tests.rs (1)

29-31: LGTM!

Also applies to: 101-101, 174-174, 187-187, 203-206, 315-315, 324-324, 343-349, 365-367

pnpm/crates/resolving-deps-resolver/src/resolve_peers/test_support.rs (1)

21-21: LGTM!

Also applies to: 63-63, 73-73

pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs (1)

17-301: LGTM!

Also applies to: 358-677, 727-1035, 1126-1357, 1415-1664, 1831-1911

pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs (1)

462-462: LGTM!

Also applies to: 638-638, 3099-3099

pnpm/crates/resolving-deps-resolver/src/tests.rs (1)

248-248: LGTM!

Also applies to: 320-320, 421-421, 566-566, 637-641, 2290-2290, 2386-2386, 2407-2407

.changeset/shared-package-ids.md (1)

1-5: LGTM!

pnpm/crates/deps-path/src/dep_path.rs (1)

38-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

⚠️ Unverified finding
Sandbox verification was unavailable.

Use the standard derived conversion for From<Arc<str>>.

This implementation only forwards the wrapped value. Use derive_more::From for the mechanical conversion. Keep manual implementations for validation or normalization logic.

As per coding guidelines, use derive_more::From and derive_more::Into for mechanical branded-string conversions.

pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs (2)

29-29: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

⚠️ Unverified finding
Sandbox verification was unavailable.

Update remaining String construction sites for the new Arc<str> contract.

The supplied pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs:1238-1327 fixture still passes String values to ResolvedTree.packages, ResolvedTree.children_by_id, ResolvedPackage.id, ChildEdge.pkg_id, and DependenciesTreeNode::new. Rust does not perform these conversions implicitly. Those callers will fail to compile until they construct Arc<str> values.

The supplied downstream snippet shows the un-migrated constructors.

Also applies to: 45-45, 149-149, 263-263


29-29: LGTM!

Also applies to: 45-45, 149-149, 239-241

pnpm/crates/resolving-deps-resolver/src/resolved_tree/tests.rs (1)

30-38: LGTM!

Also applies to: 42-65

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs (1)

446-446: LGTM!

Also applies to: 642-642, 759-759, 838-845, 1287-1287, 1313-1313

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs (1)

234-234: LGTM!

Also applies to: 256-271, 539-541, 573-573, 592-601, 684-692, 791-794, 804-804, 929-934, 954-955, 1016-1022, 1061-1061, 1286-1286, 1313-1313, 1417-1420

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs (1)

1229-1229: LGTM!

🤖 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-deps-resolver/src/resolve_dependency_tree/reuse.rs`:
- Line 645: Update the initializer assigning pkg_id in the dependency-tree reuse
loop to pass dep.id directly to Arc::from instead of cloning it. Preserve the
existing ownership flow, matching the consuming pattern used by walk.rs.

In
`@pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs`:
- Around line 1479-1484: Make occurrence IDs reuse the child-edge Arc allocation
throughout the production and realization paths: in workspace_ctx.rs lines
1479-1484, pass the owned Arc<str> into insert_tree_node and clone it for both
the DependenciesTreeNode and reverse index; in resolved_tree.rs lines 55-58,
preserve the sharing contract only after this existing Arc is reused; in
resolved_tree/tests.rs lines 67-85, exercise the production insertion path and
assert pointer equality between the child edge and occurrence node, including
package-ID sharing across occurrences.

In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs`:
- Line 463: Update DeferredChildResolution::Materialize to store Arc<str>; when
creating the deferred resolution, clone edge.pkg_id and pass that Arc directly
to DependenciesTreeNode::new instead of converting through String. Add a
regression test that verifies the child edge and materialized occurrence share
the allocation using Arc::ptr_eq.

In `@pnpm/crates/resolving-deps-resolver/src/resolved_tree/tests.rs`:
- Around line 67-85: Replace the constructor-only test in
realizing_an_occurrence_shares_the_package_id with a fixture that records a
child edge and inserts the occurrence through
WorkspaceTreeCtx::insert_tree_node. Retrieve the resulting node and compare its
package ID Arc with the recorded edge ID using Arc::ptr_eq, preserving the
assertion that the production insertion path shares storage.

---

Nitpick comments:
In `@pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs`:
- Around line 457-461: In walk.rs lines 457-461, create one Arc<str> from
id.as_str() and use explicit Arc::clone operations for both the packages map key
and ResolvedPackage.id; apply the same shared-Arc construction in reuse.rs lines
580-584 for reused packages, preserving ownership without independently
allocating the package ID.

In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs`:
- Around line 295-296: Update both cache-comparison sites in the peer resolution
logic to compare package IDs as borrowed strings using
resolved_package_id.as_ref() against child_pkg_id. Remove the temporary Arc<str>
conversions while preserving the existing FastCacheMatch::NoMatch behavior.
🪄 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: 448f2e7f-dfb3-4fbe-bdda-577dc7007919

📥 Commits

Reviewing files that changed from the base of the PR and between 9d42ccc and 79f4050.

📒 Files selected for processing (20)
  • .changeset/shared-package-ids.md
  • pnpm/crates/deps-path/src/dep_path.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/reuse.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/walk.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/workspace_ctx/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/context.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/finalize/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/test_support.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs
  • pnpm/crates/resolving-deps-resolver/src/resolved_tree/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/tests.rs

@github-actions

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 79f4050ac594

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.582 ± 0.191 2.395 2.865 1.67 ± 0.24
pacquet@main 2.661 ± 0.177 2.430 2.935 1.72 ± 0.24
pnpr@HEAD 1.595 ± 0.174 1.396 1.829 1.03 ± 0.17
pnpr@main 1.546 ± 0.186 1.377 1.834 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5824254279599996,
      "stddev": 0.19129961750943308,
      "median": 2.48341527326,
      "user": 2.1958743000000003,
      "system": 1.6626986000000001,
      "min": 2.39513209376,
      "max": 2.86486152176,
      "times": [
        2.86486152176,
        2.45136730676,
        2.83642284676,
        2.43609280876,
        2.66970780176,
        2.4240809027599997,
        2.39513209376,
        2.80534628176,
        2.51546323976,
        2.4257794757599997
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.6608980320599995,
      "stddev": 0.17664491126907292,
      "median": 2.67985899876,
      "user": 2.3591946,
      "system": 1.7146127999999998,
      "min": 2.4295236177599997,
      "max": 2.9347039367599996,
      "times": [
        2.8130234487599997,
        2.47319354976,
        2.7998135977599996,
        2.4295236177599997,
        2.60028359876,
        2.60564360776,
        2.43862510576,
        2.9347039367599996,
        2.76009546776,
        2.75407438976
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5948613108600003,
      "stddev": 0.17436878490698582,
      "median": 1.59962727526,
      "user": 1.6191290999999999,
      "system": 1.4661944,
      "min": 1.39642978776,
      "max": 1.8292723157600002,
      "times": [
        1.7050226747600001,
        1.7809797517600001,
        1.4531496837600002,
        1.4109989737600002,
        1.4942318757600002,
        1.7452943247600001,
        1.71544839676,
        1.39642978776,
        1.8292723157600002,
        1.4177853237600002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.54589014326,
      "stddev": 0.18616723856874257,
      "median": 1.4394451377600002,
      "user": 1.5050656999999998,
      "system": 1.3707460999999996,
      "min": 1.3771295467600002,
      "max": 1.8335910287600001,
      "times": [
        1.4003740077600002,
        1.4002451577600001,
        1.8037637997600002,
        1.4785162677600001,
        1.3771295467600002,
        1.39756837176,
        1.8335910287600001,
        1.3915582637600001,
        1.71037767576,
        1.6657773127600002
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 265.2 ± 9.0 250.4 285.7 1.00 ± 0.05
pacquet@main 264.4 ± 10.8 251.2 280.0 1.00
pnpr@HEAD 288.7 ± 12.1 274.9 312.8 1.09 ± 0.06
pnpr@main 330.9 ± 54.2 278.5 442.6 1.25 ± 0.21
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.26517939606,
      "stddev": 0.008965886945696411,
      "median": 0.26522222356,
      "user": 0.23749225999999996,
      "system": 0.53550238,
      "min": 0.25044997256,
      "max": 0.28571929856000006,
      "times": [
        0.26703159356,
        0.26356157056,
        0.25902068856000005,
        0.25044997256,
        0.26629919956000003,
        0.28571929856000006,
        0.26812348856,
        0.26015629556000003,
        0.26728660556,
        0.26414524756
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.26437865286,
      "stddev": 0.010845953684513611,
      "median": 0.26407568006000004,
      "user": 0.23065296000000002,
      "system": 0.5382645800000001,
      "min": 0.25119361956,
      "max": 0.27999872156000005,
      "times": [
        0.25119361956,
        0.27551196556,
        0.25868867256000005,
        0.25128161156,
        0.27999872156000005,
        0.27280590356,
        0.25482948156,
        0.25712722356,
        0.27288664156000003,
        0.26946268756
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.28872838966000003,
      "stddev": 0.012074868013815103,
      "median": 0.28495116556,
      "user": 0.23821486000000003,
      "system": 0.5538143800000002,
      "min": 0.27489456656000005,
      "max": 0.31275317856,
      "times": [
        0.30308971656000006,
        0.29050465756000005,
        0.28201730056,
        0.27850899756,
        0.28683029156,
        0.28307203956000004,
        0.31275317856,
        0.29639385256,
        0.27921929556,
        0.27489456656000005
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.33091331796000006,
      "stddev": 0.054231353886346666,
      "median": 0.31263285656000006,
      "user": 0.29951676000000005,
      "system": 0.6417544800000001,
      "min": 0.27851354056000005,
      "max": 0.44255741356000006,
      "times": [
        0.33310443156,
        0.44255741356000006,
        0.34973785456000006,
        0.30808845556000003,
        0.40522095756000004,
        0.29367444256,
        0.31717725756000004,
        0.27851354056000005,
        0.29371691956,
        0.28734190656
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.957 ± 0.066 2.815 3.039 1.77 ± 0.22
pacquet@main 2.892 ± 0.092 2.733 3.045 1.73 ± 0.22
pnpr@HEAD 1.737 ± 0.165 1.496 1.929 1.04 ± 0.16
pnpr@main 1.669 ± 0.200 1.470 1.991 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.9568738887999997,
      "stddev": 0.06644344041993927,
      "median": 2.9635562136999996,
      "user": 2.57480164,
      "system": 2.0255803599999997,
      "min": 2.8145939997,
      "max": 3.0388403437,
      "times": [
        2.8145939997,
        2.9538012596999996,
        2.9733111677,
        3.0277336886999997,
        2.9915432426999997,
        2.9294636857,
        2.9238669237,
        2.9107532407,
        3.0388403437,
        3.0048313356999996
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.8918528041,
      "stddev": 0.0920677236643219,
      "median": 2.8920658847,
      "user": 2.40625324,
      "system": 1.87055446,
      "min": 2.7328466937,
      "max": 3.0446020007,
      "times": [
        2.9830864307,
        3.0446020007,
        2.9462834197,
        2.8070194517,
        2.8217019487,
        2.8559985467,
        2.8782510627,
        2.9428577796999997,
        2.9058807066999996,
        2.7328466937
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.7372788020999999,
      "stddev": 0.16544161511256683,
      "median": 1.7520310102,
      "user": 1.6285056400000002,
      "system": 1.5475408599999998,
      "min": 1.4962221917,
      "max": 1.9285075127000002,
      "times": [
        1.8204378077,
        1.5721192537000002,
        1.9285075127000002,
        1.4962221917,
        1.7201101257,
        1.5097256647000001,
        1.7136274147000001,
        1.9049775237000002,
        1.9231086317000001,
        1.7839518947000002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.6686939846000002,
      "stddev": 0.20040937294896055,
      "median": 1.6254303602000002,
      "user": 1.61998614,
      "system": 1.50374886,
      "min": 1.4702308707,
      "max": 1.9907846057,
      "times": [
        1.7876182687,
        1.9583375727,
        1.9907846057,
        1.7215267527000002,
        1.4702308707,
        1.5202630747,
        1.7454647147,
        1.4709682487,
        1.4924117697000001,
        1.5293339677000002
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 513.1 ± 36.3 459.5 572.5 1.72 ± 0.14
pacquet@main 457.5 ± 43.4 406.0 531.2 1.53 ± 0.16
pnpr@HEAD 298.7 ± 13.4 287.1 329.6 1.00
pnpr@main 303.8 ± 18.1 289.6 336.8 1.02 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.51314622278,
      "stddev": 0.036290355391139846,
      "median": 0.51382658858,
      "user": 0.679053,
      "system": 0.8313810799999999,
      "min": 0.45954400358,
      "max": 0.57251115358,
      "times": [
        0.52503278458,
        0.51242553558,
        0.48833282758,
        0.55503356958,
        0.53766642858,
        0.51522764158,
        0.49867839158000005,
        0.57251115358,
        0.45954400358,
        0.46700989158
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.45754960588000004,
      "stddev": 0.043399552826835434,
      "median": 0.45553696408,
      "user": 0.5822697,
      "system": 0.7325527799999999,
      "min": 0.40601303158,
      "max": 0.53117599458,
      "times": [
        0.50254881158,
        0.46159661458,
        0.53117599458,
        0.49906327258,
        0.47013933858,
        0.44947731358000004,
        0.41511703558,
        0.40601303158,
        0.40807195958000003,
        0.43229268658000003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29872216358000003,
      "stddev": 0.013390248844475474,
      "median": 0.29361124808,
      "user": 0.2056899,
      "system": 0.50902308,
      "min": 0.28713570858,
      "max": 0.32961661758,
      "times": [
        0.32961661758,
        0.30367076858000003,
        0.28977868458,
        0.28740541458,
        0.29526784058,
        0.28870257258,
        0.29195465558,
        0.30575890158,
        0.30793047158000003,
        0.28713570858
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30382648878,
      "stddev": 0.018145368552529646,
      "median": 0.29539725958,
      "user": 0.21828849999999997,
      "system": 0.50338248,
      "min": 0.28955183958,
      "max": 0.33681318158,
      "times": [
        0.29164046858000003,
        0.28970536358,
        0.29548937458,
        0.28955183958,
        0.33681318158,
        0.33156046858,
        0.29991277658,
        0.29005972758,
        0.29530514458,
        0.31822654258
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.127 ± 0.226 1.867 2.637 6.99 ± 0.79
pacquet@main 2.002 ± 0.040 1.950 2.079 6.59 ± 0.29
pnpr@HEAD 0.320 ± 0.026 0.292 0.364 1.05 ± 0.09
pnpr@main 0.304 ± 0.012 0.288 0.327 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.12675014942,
      "stddev": 0.22597742276951424,
      "median": 2.1186399216200003,
      "user": 1.1945696,
      "system": 1.1715296799999997,
      "min": 1.86740390612,
      "max": 2.63682712812,
      "times": [
        1.86740390612,
        1.88440262312,
        1.96978970012,
        2.63682712812,
        2.20716327612,
        2.00623719512,
        2.0624375281200003,
        2.21589203612,
        2.1748423151200003,
        2.24250578612
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.00213588822,
      "stddev": 0.03951002512325133,
      "median": 1.99917019012,
      "user": 1.0760977,
      "system": 1.0263455799999999,
      "min": 1.94960910812,
      "max": 2.0793227041200004,
      "times": [
        2.0145550681200004,
        2.0793227041200004,
        2.04235189312,
        2.01364111112,
        1.97854286112,
        1.98469926912,
        1.94960910812,
        2.0207006571200004,
        1.97236350112,
        1.9655727091200001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.31967645672,
      "stddev": 0.02553372892295883,
      "median": 0.30715231212000005,
      "user": 0.2187074,
      "system": 0.56299638,
      "min": 0.29152174512,
      "max": 0.36408153912,
      "times": [
        0.36408153912,
        0.35283828712000004,
        0.33124852612,
        0.30876103112000003,
        0.30266165512000004,
        0.29804755612,
        0.29152174512,
        0.30115873112,
        0.30554359312,
        0.34090190312
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30404087112000006,
      "stddev": 0.012088089151992054,
      "median": 0.30487445812,
      "user": 0.1943276,
      "system": 0.53978228,
      "min": 0.28760444712,
      "max": 0.32716294112,
      "times": [
        0.32716294112,
        0.30954397512000004,
        0.28811044012000003,
        0.29513627312,
        0.30240063212,
        0.28760444712,
        0.31327962112,
        0.30009140112,
        0.30734828412000004,
        0.30973069612000004
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 266.6 ± 36.0 194.7 325.7 2.95 ± 0.41
pacquet@main 231.6 ± 11.9 205.3 251.8 2.56 ± 0.16
pnpr@HEAD 90.3 ± 3.2 85.7 97.3 1.00
pnpr@main 91.3 ± 3.2 85.3 101.5 1.01 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.2665720220133334,
      "stddev": 0.03600989663198067,
      "median": 0.27005935848000007,
      "user": 0.22028032666666666,
      "system": 0.08835091333333334,
      "min": 0.19466452048000002,
      "max": 0.3257278114800001,
      "times": [
        0.19466452048000002,
        0.23054253448,
        0.22240286048000002,
        0.24785154648000002,
        0.3257278114800001,
        0.29390801948000006,
        0.25179452448000006,
        0.29702458748000005,
        0.29859690948000006,
        0.28919920548000005,
        0.28531115348,
        0.29867092048000005,
        0.27005935848000007,
        0.23529113348000003,
        0.25753524448000004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.23158917097999998,
      "stddev": 0.011878748893002127,
      "median": 0.23118088148000002,
      "user": 0.17006194333333333,
      "system": 0.05506527999999999,
      "min": 0.20533731848,
      "max": 0.25180789648,
      "times": [
        0.23136120548000003,
        0.23441268948000002,
        0.23076718648000002,
        0.24058096648000002,
        0.23100055748,
        0.21984354748,
        0.24169883248000001,
        0.25180789648,
        0.22625726348000003,
        0.20533731848,
        0.23977306348000002,
        0.22622952448
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.0902959892864516,
      "stddev": 0.0032118572005253323,
      "median": 0.09028880248,
      "user": 0.02149469870967742,
      "system": 0.011942503870967743,
      "min": 0.08567021048000001,
      "max": 0.09730420548,
      "times": [
        0.09028880248,
        0.09217580448,
        0.09476116148000001,
        0.09486711248,
        0.08799776848,
        0.09318029948,
        0.08991806248,
        0.09131892148000001,
        0.09108115848000001,
        0.09243223448,
        0.08896244448,
        0.09730420548,
        0.08567021048000001,
        0.08763257548,
        0.08639637848000001,
        0.09055986548,
        0.09275383948,
        0.09020897048,
        0.09606618648000001,
        0.08679551448,
        0.08738420448,
        0.09270393548,
        0.08787923348,
        0.08612584848,
        0.08706604248000001,
        0.09051285448,
        0.08688498348000001,
        0.09168647448,
        0.09438662748,
        0.08710571148,
        0.08706823548
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.09132190699612906,
      "stddev": 0.003246680019051491,
      "median": 0.09093812148000001,
      "user": 0.020092247096774193,
      "system": 0.014072296129032262,
      "min": 0.08526660748,
      "max": 0.10148473748,
      "times": [
        0.08897146148,
        0.08648933748,
        0.09261697148,
        0.09153498848000001,
        0.09435949848,
        0.08526660748,
        0.09326723148,
        0.09509999148,
        0.08888454148000001,
        0.09000992348,
        0.09231374548,
        0.09127949648,
        0.09173982948,
        0.09665198248000001,
        0.09067947348000001,
        0.09186604048000001,
        0.08950605348,
        0.09017547448,
        0.08778753748000001,
        0.09160787148,
        0.09623380048,
        0.08795129548000001,
        0.10148473748,
        0.09032827548,
        0.09090328148,
        0.09074804248,
        0.08666406548000001,
        0.09177675848,
        0.09093812148000001,
        0.09324765748000001,
        0.09059502348000001
      ]
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 522.5 ± 70.1 397.3 616.9 1.00
pacquet@main 564.2 ± 136.8 401.2 813.5 1.08 ± 0.30
pnpm@HEAD 3075.5 ± 191.9 2880.0 3464.1 5.89 ± 0.87
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.522471818208889,
      "stddev": 0.07012572870694073,
      "median": 0.5159445743200001,
      "user": 0.48876868,
      "system": 0.1247643711111111,
      "min": 0.39730032732,
      "max": 0.61686227532,
      "times": [
        0.61686227532,
        0.5159445743200001,
        0.5466010953200001,
        0.49168602932,
        0.39730032732,
        0.5654197453200001,
        0.47346511832,
        0.60950589732,
        0.48546130132
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.5642204309866667,
      "stddev": 0.13677191684973747,
      "median": 0.5360882143200001,
      "user": 0.5305029022222222,
      "system": 0.12637492666666666,
      "min": 0.40119556832000003,
      "max": 0.8135356763200001,
      "times": [
        0.48436365732000003,
        0.8135356763200001,
        0.48404148732,
        0.5394244863200001,
        0.44169616532,
        0.40119556832000003,
        0.70675356432,
        0.5360882143200001,
        0.6708850593200001
      ]
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.0754828942088888,
      "stddev": 0.1919495538315992,
      "median": 3.02906105332,
      "user": 4.299499902222221,
      "system": 0.3282845933333333,
      "min": 2.87999365632,
      "max": 3.4641336793199997,
      "times": [
        2.90384879532,
        2.87999365632,
        3.02906105332,
        2.97039594132,
        3.06453669432,
        3.31395943832,
        3.05001366232,
        3.4641336793199997,
        3.00340312732
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.605 ± 0.108 4.432 4.771 1.31 ± 0.04
pacquet@main 4.524 ± 0.106 4.423 4.779 1.29 ± 0.04
pnpr@HEAD 3.593 ± 0.131 3.451 3.824 1.02 ± 0.04
pnpr@main 3.513 ± 0.059 3.455 3.630 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.60464550444,
      "stddev": 0.10814208271684489,
      "median": 4.61350525374,
      "user": 2.09966264,
      "system": 1.54828044,
      "min": 4.43168778024,
      "max": 4.77057975524,
      "times": [
        4.77057975524,
        4.43168778024,
        4.604345920239999,
        4.76505236624,
        4.635461622239999,
        4.629726896239999,
        4.48523874124,
        4.55871706524,
        4.62266458724,
        4.54298031024
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.52356369344,
      "stddev": 0.10641545223129419,
      "median": 4.4887690962399995,
      "user": 1.9402475399999997,
      "system": 1.51530294,
      "min": 4.423369860239999,
      "max": 4.779433023239999,
      "times": [
        4.47673136424,
        4.431578947239999,
        4.779433023239999,
        4.45898582124,
        4.607368312239999,
        4.56746102224,
        4.481488381239999,
        4.49604981124,
        4.423369860239999,
        4.51317039124
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.59315848404,
      "stddev": 0.13098607155860043,
      "median": 3.56165428774,
      "user": 1.3246142399999996,
      "system": 1.24538374,
      "min": 3.45065249124,
      "max": 3.8244311412400003,
      "times": [
        3.51346196224,
        3.47567664324,
        3.63073208124,
        3.54567531224,
        3.45065249124,
        3.57763326324,
        3.67485192524,
        3.77500148924,
        3.46346853124,
        3.8244311412400003
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.51299876474,
      "stddev": 0.05928373193187056,
      "median": 3.49312531874,
      "user": 1.32723544,
      "system": 1.26024554,
      "min": 3.4545847642400003,
      "max": 3.6302940932400003,
      "times": [
        3.52251659124,
        3.4695599292400003,
        3.46977539524,
        3.46203787124,
        3.6302940932400003,
        3.49455743224,
        3.59284688524,
        3.54212148024,
        3.4545847642400003,
        3.4916932052400003
      ]
    }
  ]
}

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13855
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,814.59 ms
(+3.99%)Baseline: 2,706.66 ms
3,247.99 ms
(86.66%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,867.40 ms
(+2.85%)Baseline: 1,815.60 ms
2,178.72 ms
(85.71%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
459.54 ms
(+1.53%)Baseline: 452.61 ms
543.13 ms
(84.61%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
194.66 ms
(-12.10%)Baseline: 221.45 ms
265.74 ms
(73.25%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,395.13 ms
(-3.11%)Baseline: 2,472.06 ms
2,966.47 ms
(80.74%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,431.69 ms
(-1.85%)Baseline: 4,515.12 ms
5,418.14 ms
(81.79%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
250.45 ms
(-14.78%)Baseline: 293.87 ms
352.65 ms
(71.02%)
isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
397.30 ms
(-41.90%)Baseline: 683.77 ms
820.53 ms
(48.42%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13855
Testbedpnpr

⚠️ 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-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,496.22 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
291.52 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
287.14 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
85.67 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,396.43 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,450.65 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
274.89 ms
🐰 View full continuous benchmarking report in Bencher

… sites

CI caught three things the resolver-only check did not:

- `pacquet-package-manager`'s lockfile fixture builds a `ResolvedTree`
  directly, so it needs the shared id type too.
- Two `use std::sync::Arc` lines sat beside an existing `use std::{...}`,
  which the repo's import lint rejects.
- The fixture's `Arc` clones need `Arc::<str>::clone`, per
  `clippy::clone_on_ref_ptr`.

My local run had been checking two crates and silently skipping every
test target: `pretty_assertions` was corrupt in this machine's cargo
registry, so `--all-targets` failed to compile a dependency and I read
that as unrelated noise. Re-extracting it surfaced the real errors.
Copilot AI review requested due to automatic review settings August 12, 2026 08:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 012a3c2

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 12, 2026
@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@codecov-commenter

codecov-commenter commented Aug 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.60000% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.25%. Comparing base (46a9fe4) to head (4caa998).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...resolving-deps-resolver/src/resolve_peers/cache.rs 81.48% 5 Missing ⚠️
...olver/src/resolve_dependency_tree/workspace_ctx.rs 88.88% 4 Missing ⚠️
...esolving-deps-resolver/src/resolve_peers/walker.rs 92.85% 2 Missing ⚠️
...-deps-resolver/src/resolve_dependency_tree/walk.rs 90.90% 1 Missing ⚠️
...solving-deps-resolver/src/resolve_peers/context.rs 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13855      +/-   ##
==========================================
+ Coverage   88.24%   88.25%   +0.01%     
==========================================
  Files         627      627              
  Lines      103300   103370      +70     
==========================================
+ Hits        91152    91230      +78     
+ Misses      12148    12140       -8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…hare

Review caught that the conversion to `Arc<str>` had left `Arc::from`
calls on paths that previously did no allocation at all, which is the
opposite of the point.

- `find_fast_hit`'s package-id checks built a whole `Arc<str>` per
  comparison, in the cache-matching loop. Comparing through `&*` is what
  was meant.
- `packages.insert` allocated the id twice — once for the key, once for
  `ResolvedPackage::id` — where one shared allocation serves both.
- `deferred_child_resolution` took `&str` and rebuilt an `Arc` its only
  caller already held; it now takes `&Arc<str>` and carries the caller's
  allocation through `Materialize`.
- `insert_tree_node` went `&str -> String -> Arc<str>`, and two
  `ChildEdge` builders cloned a `String` before converting it.
- One `Arc::clone` fed straight into `to_string`, bumping a refcount for
  nothing.

`DepPath`'s `From<Arc<str>>` is now derived. Per `pnpm/CLAUDE.md`,
`derive_more::From` is the convention when the conversion only wraps the
inner field; the `String` and `&str` conversions stay handwritten
because they allocate.

The measured win improves with these: peak RSS 3264 -> 3046 MB (-6.7%,
n=3 alternating A/B, was -5% before), lockfile unchanged.
Copilot AI review requested due to automatic review settings August 12, 2026 09:04
@greptile-apps
greptile-apps Bot dismissed their stale review August 12, 2026 09:04

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 12, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 0517cb7

…ions of nodes

The previous test handed an `Arc` to `DependenciesTreeNode::new` and
asserted it came back, which only proves the constructor keeps its
argument. It would pass while every occurrence still owned a separate
copy of its package id — the exact thing this change is about.

`realize_children_with` is where the millions of occurrences are
created, so the test now realizes a recorded child edge through it and
compares the edge's `Arc` with the resulting node's. Reverted against a
realization that copies the id, it fails.
@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Copilot AI review requested due to automatic review settings August 12, 2026 09:09
@greptile-apps
greptile-apps Bot dismissed their stale review August 12, 2026 09:09

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 12, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 4caa998

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan
zkochan merged commit 260fb13 into main Aug 12, 2026
45 checks passed
@zkochan
zkochan deleted the fix-13681-cycle-cache branch August 12, 2026 09:26
zkochan added a commit that referenced this pull request Aug 12, 2026
…truncation (#13859)

The third and largest piece of #13681, addressing what the first two PRs (#13844, #13855) deliberately left alone: the occurrence explosion itself.

### The problem

A walk that re-enters a package already on its ancestor chain resolves against a truncated subtree, so its verdict has never been cached — reusing it where the subtree is intact drops `transitivePeerDependencies` depending on traversal order (#5108). On a peer-cyclic graph this rule makes the peers cache inert. Resolving [bit](https://github.com/teambit/bit)'s env packages:

```
full walks:            188,707   (91% end in a cycle)
peers-cache hits:          155   of 188,862 lookups  (0.08%)
occurrence nodes:    2,008,130   for a 6,133-node graph
```

### The insight, measured before designed

The truncation is not arbitrary: `realize_children_with` drops exactly the edges `forms_cycle` finds in the occurrence's own ancestor ids. So a truncated verdict is a function of *(package, peer context, the chain entries the gate actually weighs)* — and everything else in the chain is noise. I instrumented the workload to check how much noise:

| candidate key | distinct keys / 171,508 cycle walks |
| --- | --- |
| full ancestor chain | 68,184 (2.5×) — and implemented honestly, memory got *worse* |
| chain ∩ reachable-set | 68,180 — useless, the cluster is one giant SCC |
| **chain ∩ consulted ids** | **~1,900 (91×)** |

### The mechanism

- Every full walk keeps a `ConsultedPkgs` frame — a bitset over interned package ids. Realization marks the package whose children are realized plus every child edge target (precisely the `forms_cycle` arguments); reusing an already-realized children map marks the same ids, since the map embodies the same answers. Finished walks fold their frame into their parent's; a cache hit folds the stored entry's set in. An outer frame therefore covers the dependence of everything under it.
- Cycle-resolved verdicts are now stored, tagged with a `CycleTruncationKey`: the consulted set plus the occurrence's ancestor ids restricted to it (base entries first — `forms_cycle` treats the halves differently, so the boundary is part of the key).
- `find_hit` hands a tagged verdict only to an occurrence whose ancestors, restricted to the entry's consulted set, are exactly the recorded chain. Equal restrictions ⇒ every gate answer equal ⇒ same realization, same truncation, same verdict, by induction on the walk. Non-matching occurrences — in particular ones whose ancestors don't truncate the subtree at all, the #5108 shape — re-walk exactly as before.

### Results

Same replayed install as the previous PRs (5 importers, 3,807 merged packages), alternating A/B:

| | peak RSS | wall time |
| --- | --- | --- |
| `main` | 3043 / 3056 / 3042 MB | 59 / 39 / 42 s |
| this branch | 1405 / 1416 / 1415 MB | 20 / 25 / 20 s |

**3047 → 1412 MB (−54%), roughly 2× faster.** Walk counts: full walks 188,707 → 33,648; cycle walks 171,508 → 16,563; the keyed entries hit 44,999 times. Cumulative across the three PRs the install has gone **3670 → 1412 MB (−62%)**.

### Correctness

This is the change #5108 exists to be afraid of, so I want to be explicit about the evidence and its limits.

- **328 tests pass**, including new ones that pin the key's semantics from both directions: unconsulted ancestors are noise (reuse happens), while order changes, extra occurrences, base/appended boundary moves, and — critically — *an occurrence whose ancestors don't truncate the subtree* all refuse reuse.
- **Repeat installs never churn.** Fixed-point checked both ways: the unmodified engine, handed this branch's lockfile as `wanted`, preserves it byte for byte; this branch preserves `main`'s lockfile byte for byte. Lockfile churn on repeat installs is the #5108 regression, and it cannot happen here.
- **Cold output is deterministic** — three cold runs, byte-identical.
- **Cold output differs from `main` in 13 snapshot entries** (52 diff lines of ~86k), all in the `@teambit/component → command-bar/pubsub/ui` cluster — the exact entries that already flip between *identical stock runs* (#13846, 96–197-line diffs). The branch picks a different valid peer variant there; the fixed-point check is what shows it is valid. I want to flag this honestly rather than bury it: if byte-identical cold output against current `main` is a hard requirement even inside the known-nondeterministic cluster, this needs a maintainer call.
- `cargo clippy --all-targets`, `cargo fmt`, and `cargo dylint` clean across the workspace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants