Skip to content

perf(rust/tla): skip compute_tla if there is no module use TLA#8487

Merged
hyf0 merged 4 commits intorolldown:mainfrom
ShroXd:skip-compute-tla-if-possible
Feb 27, 2026
Merged

perf(rust/tla): skip compute_tla if there is no module use TLA#8487
hyf0 merged 4 commits intorolldown:mainfrom
ShroXd:skip-compute-tla-if-possible

Conversation

@ShroXd
Copy link
Contributor

@ShroXd ShroXd commented Feb 27, 2026

A todo in compute_tla indicates that this process could be skipped when there is no module that uses TLA — which is also the common case for many real-world projects.

This PR tracks the count of TLA-using modules during the scan stage and stores it in tla_module_count. Link stage will check this counter and return early if the count is zero.

@ShroXd ShroXd marked this pull request as draft February 27, 2026 09:21
@ShroXd ShroXd marked this pull request as ready for review February 27, 2026 10:29
@hyf0
Copy link
Member

hyf0 commented Feb 27, 2026

Is count a bit of unnecessary?

I would go for having a big flag under module scanner and return a has_module_used_tla bitflag/boolean in the final ModuleLoaderOutput.

@ShroXd
Copy link
Contributor Author

ShroXd commented Feb 27, 2026

Is count a bit of unnecessary?

I would go for having a big flag under module scanner and return a has_module_used_tla bitflag/boolean in the final ModuleLoaderOutput.

Hi, thanks for the feedback.

I think the counter is necessary because it makes it easier to check if any other TLA modules remain in the scan_stage_cache.rs:merge method. A bool or bit flag cannot tell us whether other modules still have TLA after one TLA is removed.

@hyf0
Copy link
Member

hyf0 commented Feb 27, 2026

Well done!

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 implements a performance optimization for the compute_tla function by tracking the number of modules using top-level await (TLA) during the scan stage. The implementation adds an early return when no TLA modules exist, avoiding unnecessary computation for the common case where projects don't use TLA.

Changes:

  • Added tla_module_count field to track TLA-using modules throughout the pipeline
  • Implemented early return in compute_tla when count is zero
  • Updated merge logic in ScanStageCache to maintain accurate counts during partial scans

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/rolldown/src/types/scan_stage_cache.rs Added module_has_tla helper and logic to track TLA count during cache merge operations
crates/rolldown/src/stages/scan_stage.rs Added tla_module_count field to scan stage output structures
crates/rolldown/src/stages/link_stage/mod.rs Added tla_module_count field to LinkStage struct
crates/rolldown/src/stages/link_stage/compute_tla.rs Added early return optimization when no TLA modules exist
crates/rolldown/src/module_loader/module_loader.rs Added TLA counting during module loading

@hyf0 hyf0 enabled auto-merge (squash) February 27, 2026 13:01
@hyf0 hyf0 force-pushed the skip-compute-tla-if-possible branch from 2b3172f to b4a6959 Compare February 27, 2026 13:01
@hyf0 hyf0 changed the title perf(compute_tla): skip compute_tla if there is no module use TLA perf(rust/tla): skip compute_tla if there is no module use TLA Feb 27, 2026
@netlify
Copy link

netlify bot commented Feb 27, 2026

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit b4a6959
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69a195984ac2250008f581c7

@hyf0 hyf0 merged commit edf8917 into rolldown:main Feb 27, 2026
35 checks passed
@ShroXd ShroXd deleted the skip-compute-tla-if-possible branch February 27, 2026 14:30
This was referenced Mar 4, 2026
shulaoda added a commit that referenced this pull request Mar 5, 2026
## [1.0.0-rc.7] - 2026-03-05

⚡ Smarter Code Generation Defaults
- DCE-only minification and smart constant inlining are now enabled by default
- Produces cleaner, smaller output bundles without requiring explicit configuration

💡 LLM-Friendly Bundle Analyzer Reports
- New markdown output format for the bundle analyzer plugin with bundle summaries, module graphs, dependency chains, and optimization suggestions
- Optimization suggestions now also recommend using the entriesAware option when common chunks contain modules only reachable from specific entries


### 💥 BREAKING CHANGES

- enable minify: 'dce-only' by default (#8465) by @IWANABETHATGUY
- settings `inlineConst: { mode: 'smart', pass: 1}`  by default (#8444) by @IWANABETHATGUY

### 🚀 Features

- binding: add original getter to BindingMagicString (#8533) by @IWANABETHATGUY
- native-magic-string: add `offset` property support (#8531) by @IWANABETHATGUY
- add `output.strict` option to control `"use strict"` directive emission (#8489) by @Copilot
- watch: expose `watcher.compareContentsForPolling` (#8526) by @hyf0
- watch: use new watcher to support watch mode (#8475) by @hyf0
- rust/watch: handle bulk-change (#8466) by @hyf0
- add LLM-friendly markdown output format to bundle analyzer plugin (#8242) by @IWANABETHATGUY

### 🐛 Bug Fixes

- expose `plugins` on `NormalizedInputOptions` for `buildStart` hook (#8521) by @Copilot
- only uppercase facade symbols in JSX preserve mode (#8519) by @IWANABETHATGUY
- binding: export BindingResult in generated dts header (#8537) by @minsoo-web
- pre-resolve paths option to avoid `invoke_sync` deadlock (#8518) by @IWANABETHATGUY
- remove debug-only jsx_preset and UntranspiledSyntaxError (#8511) by @IWANABETHATGUY
- apply `topLevelVar` to exported `const`/`let` declarations (#8507) by @IWANABETHATGUY
- rolldown_plugin_vite_web_worker_post: avoid replacing `new.target` (#8488) by @sapphi-red
- update copyright year to 2026 (#8486) by @maciekzygmunt

### 🚜 Refactor

- rust: use Oxc's SymbolFlags::ConstVariable instead of custom IsConst flag (#8543) by @Dunqing
- rust: remove FacadeScoping, use Scoping::create_symbol for facade symbols (#8540) by @Dunqing
- rust/watch: remove hacky `reset_closed_for_watch_mode` (#8530) by @hyf0
- binding: return &str instead of String in filename() getter (#8534) by @IWANABETHATGUY
- rust: remove old watch mode implementation (#8525) by @hyf0
- rust/watch: simply watch logic in the binding layer (#8516) by @hyf0
- rust/watch: tweak struct/function names (#8464) by @hyf0

### 📚 Documentation

- explain how external modules work in rolldown (#8457) by @sapphi-red
- add some diagrams using graphviz (#8499) by @sapphi-red
- use `vitepress-plugin-graphviz` (#8498) by @sapphi-red
- list s390x/ppc64le prebuilt binaries (#8495) by @crusty-voidzero
- fix error type for `RolldownBuild.generate` and others (#8490) by @sapphi-red

### ⚡ Performance

- string_wizard: reduce allocations and add ASCII fast paths (#8541) by @IWANABETHATGUY
- use IndexBitSet to replace IndexVec<XXXIdx, bool> for module/stmt inclusion tracking (#8503) by @IWANABETHATGUY
- plugin: use IndexBitSet to optimize skipped plugins checking (#8497) by @ShroXd
- rust/tla: skip compute_tla if there is no module use TLA (#8487) by @ShroXd

### 🧪 Testing

- node/watch: make watch tests run in concurrent and retry-able (#8512) by @hyf0
- add test case for static flag tree-shaking (#8476) by @IWANABETHATGUY
- migrate post-banner sourcemap-with-shebang to Rust (#8477) by @Copilot

### ⚙️ Miscellaneous Tasks

- vscode: `formatOnSave` for markdown files using oxc formatter (#8536) by @minsoo-web
- deps: update test262 submodule for tests (#8528) by @sapphi-red
- remove `retry` workaround from output paths test fixtures (#8520) by @Copilot
- docs: add Shuyuan Wang (h-a-n-a) and remove from acknowledgements (#8509) by @Copilot
- consolidate top_level_var test cases using configVariants (#8508) by @IWANABETHATGUY
- add s390x and ppc64le linux gnu targets (#8493) by @Brooooooklyn

### ◀️ Revert

- fix(rolldown): increase tokio blocking threads size for watch mode (#8517) by @hyf0

### ❤️ New Contributors

* @minsoo-web made their first contribution in [#8536](#8536)
* @crusty-voidzero made their first contribution in [#8495](#8495)
* @maciekzygmunt made their first contribution in [#8486](#8486)

Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.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.

3 participants