Commit 26d804e
committed
perf: use flag-based convergence detection in include_statements (#8412)
Replace O(N) linear scan of is_module_included_vec per convergence
iteration with a boolean flag (module_inclusion_changed) that is set
when include_module() transitions a module to included. This avoids
scanning ~19K entries on every loop iteration to detect fixpoint.
Benchmark (10K module project, 15 runs):
- System time: 2.68s -> 2.52s (-5.9%)
- Wall clock: 4.42s -> 4.41s (-0.2%)
Co-Authored-By: Claude Opus 4.6 <[email protected]>
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Behavior should be unchanged (only alters fixpoint detection), but mistakes could cause premature termination and missed module inclusion in tree-shaking.
>
> **Overview**
> Speeds up tree-shaking convergence in `include_statements` by replacing per-iteration O(N) scans of `is_module_included_vec` with a `module_inclusion_changed` flag that is reset each loop and set when `include_module` newly includes a module.
>
> Extends `IncludeContext` (and its construction sites, including `chunk_optimizer`) to carry this flag so the dynamic-entry inclusion loop can stop at fixpoint without counting included modules each iteration.
>
> <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 50910e2. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 7b23a52 commit 26d804e
File tree
2 files changed
+10
-8
lines changed- crates/rolldown/src/stages
- generate_stage
- link_stage/tree_shaking
2 files changed
+10
-8
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
906 | 906 | | |
907 | 907 | | |
908 | 908 | | |
| 909 | + | |
909 | 910 | | |
910 | 911 | | |
911 | 912 | | |
| |||
Lines changed: 9 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
69 | 73 | | |
70 | 74 | | |
71 | 75 | | |
| |||
100 | 104 | | |
101 | 105 | | |
102 | 106 | | |
| 107 | + | |
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
| |||
209 | 214 | | |
210 | 215 | | |
211 | 216 | | |
212 | | - | |
213 | | - | |
214 | 217 | | |
215 | 218 | | |
| 219 | + | |
| 220 | + | |
216 | 221 | | |
217 | 222 | | |
218 | 223 | | |
| |||
236 | 241 | | |
237 | 242 | | |
238 | 243 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
| 244 | + | |
243 | 245 | | |
244 | 246 | | |
245 | | - | |
246 | | - | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| 581 | + | |
581 | 582 | | |
582 | 583 | | |
583 | 584 | | |
| |||
0 commit comments