Skip to content

perf: share dependency graph and materialization cache across importers in list/why#10596

Merged
zkochan merged 11 commits intomainfrom
perf/list
Feb 13, 2026
Merged

perf: share dependency graph and materialization cache across importers in list/why#10596
zkochan merged 11 commits intomainfrom
perf/list

Conversation

@zkochan
Copy link
Member

@zkochan zkochan commented Feb 11, 2026

No description provided.

@zkochan zkochan marked this pull request as ready for review February 13, 2026 19:58
Copilot AI review requested due to automatic review settings February 13, 2026 19:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes the performance of pnpm why and pnpm list commands in workspaces with many importers by sharing the dependency graph and materialization cache across all importers instead of rebuilding them independently for each one.

Changes:

  • Refactored dependency graph building to accept multiple root nodes and build a single shared graph
  • Modified tree materialization to return structured results with deduplication metadata
  • Implemented cross-importer caching to avoid redundant tree materialization

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
reviewing/dependencies-hierarchy/src/buildDependencyGraph.ts Changed to accept an array of root IDs instead of a single root, enabling building a unified graph for multiple importers
reviewing/dependencies-hierarchy/src/getTree.ts Added return type GetTreeResult with deduplication metadata, and implemented top-level caching to detect already-materialized subtrees
reviewing/dependencies-hierarchy/src/buildDependenciesHierarchy.ts Refactored to build a single shared graph and materialization cache for all importers, with logic to handle deduped results in search scenarios
reviewing/dependencies-hierarchy/test/getTree.test.ts Added comprehensive tests for multi-root graph building and cross-call deduplication behavior
reviewing/list/src/index.ts Enabled showDedupedSearchMatches flag for search operations
pnpm-lock.yaml Updated dependencies (@types/node, semver, string-width)
.changeset/optimize-why-many-importers.md Added changeset documenting the performance optimization
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zkochan zkochan merged commit 472d3af into main Feb 13, 2026
19 checks passed
@zkochan zkochan deleted the perf/list branch February 13, 2026 20:13
zkochan added a commit that referenced this pull request Feb 13, 2026
zkochan added a commit to teambit/bit that referenced this pull request Feb 17, 2026
`bit why` now shows a reverse dependency tree. The searched package
appears at the root with its dependents as branches, walking back to
workspace components. This replaces the previous forward-tree output
which was noisy and hard to read for deeply nested dependencies.

Also with the complete rewrite of the dependency tree builder we have
fixed the out-of-memory errors that were frequent with the why command.
The command also became a lot faster.

## Proposed Changes

Related PRs:
- pnpm/pnpm#10582
- pnpm/pnpm#10586
- pnpm/pnpm#10615
- pnpm/pnpm#10616
- pnpm/pnpm#10627
- pnpm/pnpm#10629
- pnpm/pnpm#10596

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants