Add ideal graph native bundling algorithm#1025
Open
mattcompiles wants to merge 38 commits intomainfrom
Open
Conversation
…edup Replace String-based IdealBundleId with u32-based keys backed by AssetInterner. All HashMap/HashSet operations now use integer hashing instead of string hashing. Real app results (60k assets): - create_shared_bundles: 1.85s -> 403ms (4.6x) - compute_availability: 1.57s -> 129ms (12x) - internalize_async: 710ms -> 259ms (2.7x) - Total build: 4.54s -> 1.18s (3.8x) Combined with previous optimizations: 86.9s -> 1.18s (74x total)
Replace HashMap<IdealBundleId, IdealBundle> with Vec<Option<IdealBundle>> indexed by the u32 bundle ID. Eliminates hash computation for all bundle lookups and mutations. Benchmark: 7.6% improvement at xlarge (60k assets, 2.79s -> 2.57s).
…y pass Remove compute_availability_dag_fast and compute_availability_dag functions (~290 lines). Real apps always have cycles, so the DAG fast path was wasted work that always fell through to SCC condensation. Reorder phases to match JS version: availability -> internalize -> shared bundles. This eliminates the second availability recomputation after shared bundle insertion. Real app results (60k assets): 1.18s -> 861ms (-27%) Overall journey: 86.9s -> 861ms (101x total speedup)
…onversion Fix two critical performance bottlenecks outside the bundling algorithm: 1. from_asset_graph: move node_weights().collect() outside edge loop - Was creating 60k-element Vec for each of 223k edges - ~91s eliminated 2. Bundle conversion: precompute deps_by_target HashMap - Three O(N*M) loops iterated all 223k deps for each of ~7k bundles - ~34s eliminated Real app results (60k assets): - bundle_graph_request: 127s -> 1.77s (72x) - build_bundle_graph: 165s -> 43.6s (3.8x, limited by asset graph build)
🦋 Changeset detectedLatest commit: 912dc4c The changes in this PR will be included in the next version bump. This PR includes changesets to release 112 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
📊 Type Coverage ReportCoverage Comparison
Files with Most Type Issues (Top 15)
This report was generated by the Type Coverage GitHub Action |
marcins
approved these changes
Feb 18, 2026
Contributor
marcins
left a comment
There was a problem hiding this comment.
There's way too much stuff here to really get a good mental context of it, but conceptually looks fine to me!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The existing bundling algorithm lives in JS and is one of the targets for native migration. This adds a Rust
implementation of the ideal graph bundling algorithm behind the nativeBundling feature flag. It's still a work in progress, but it's enough to build a real world app.
Changes
• Add the ideal graph bundler implementation (ideal_graph/builder.rs, ideal_graph/types.rs, ideal_graph/mod.rs) with
all core phases: boundary identification, sync graph construction, reachability, asset placement, availability,
shared bundle creation, and async bundle internalization
• Add conversion layer from IdealGraph back to NativeBundleGraph for integration with the existing pipeline
• Add a comprehensive benchmark suite with configurable graph generation that approximates real-world app
characteristics
• Add native bundler parity integration tests
• Fix an O(N^2) in from_asset_graph that was causing massive slowdowns in the bundle graph request
• Wire up the native bundler behind setupV3Flags({nativeBundling: true})
Checklist