Skip to content

perf: avoid parsing concatenated module codegen#14852

Draft
LingyuCoder wants to merge 5 commits into
mainfrom
seal/concat-local-ident
Draft

perf: avoid parsing concatenated module codegen#14852
LingyuCoder wants to merge 5 commits into
mainfrom
seal/concat-local-ident

Conversation

@LingyuCoder

Copy link
Copy Markdown
Contributor

Summary

  • capture a compact concatenation scope snapshot during the existing make-time parser traversal instead of traversing or parsing generated code again
  • let dependency templates and init fragments register generated top-level bindings, removed source ranges, and module-reference placeholders so concatenated modules can deconflict names from make-time coordinates
  • remove the SWC parser/resolver path from concatenated-module and modern-module linking, while preserving dynamic bindings for JavaScript, JSON, CSS, assets, externals, async imports, and injected helpers
  • avoid cloning dependency replacements when taking ownership of concatenated JavaScript sources

The earlier approach in #14033 added a second AST traversal and persisted high-cardinality identifier/reference maps for every eligible ESM module. That shifted substantial allocation, serialization, and cache-restore work into make while still rebuilding name-analysis state during code generation. This version fuses collection into an existing visitor, stores only compact identifier records, and resolves generated bindings lazily from dependency-template metadata.

The focused optimized-profile benchmark is approximately 6.98 ms locally versus 7.07 ms on origin/main for rust@concatenate_module_code_generation. CI CodSpeed is the final performance gate.

Related links

Checklist

  • Tests updated.
  • Documentation not required.

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 315eb5e to chore(deps): update dependency @rslint/core to v0.7.0 (#14849) by renovate[bot]

❌ Size increased by 120.00KB from 66.60MB to 66.72MB (⬆️0.18%)

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 1 project with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 552.1 KB 0 0
react-10k 5.6 MB 1.3 MB 0 0
react-1k 823.1 KB 217.0 KB 0 0
react-5k 2.7 MB 663.8 KB 0 0
ui-components 4.9 MB 1.4 MB +36.0 B (0.0%) +10.0 B (0.0%)
📋 Detailed Reports (Click to expand)

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

📌 Baseline Commit: e8a7bce74b | PR: #14849

Metric Current Baseline Change
📊 Total Size 4.9 MB 4.9 MB +36.0 B (0.0%)
🗜️ Gzip Size 1.4 MB 1.4 MB +10.0 B (0.0%)
📄 JavaScript 4.8 MB 4.8 MB +36.0 B (0.0%)
🎨 CSS 112.1 KB 112.1 KB 0
🌐 HTML 328.0 B 328.0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: ui-components Bundle Diff

🤖 AI Degradation Analysis (Click to expand)

📊 Size Changes

No significant regressions detected 🎉.

🔍 Root Cause Analysis

  • Minor fluctuation in element-plus (v2.14.3): vnode.mjs parsed size increased 465 → 501 bytes (+7.74%).
  • Total JS bundle: 5,007,425 → 5,007,461 bytes (+36 bytes, +0.0007%).

⚠️ Risk Assessment

Overall severity: Low

  • Initial chunk increase is 36 bytes, which is statistically noise relative to the ~5 MB total bundle size.

💡 Optimization Suggestions

  1. Approve merge; no optimization needed.
  2. Monitor element-plus updates if minor version bumps continue to trigger build diff noise.

Analysis by qwen3.5-plus

Generated by Rsdoctor GitHub Action

@codspeed-hq

codspeed-hq Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 14.07%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
✅ 40 untouched benchmarks
⏩ 47 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation bundle@threejs-production-sourcemap 192.9 ms 155 ms +24.46%
Simulation rust@concatenate_module_code_generation 45.1 ms 39.2 ms +15.21%
Simulation bundle@misc-production-sourcemap 3.7 s 3.5 s +3.53%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing seal/concat-local-ident (315eb5e) with main (e8a7bce)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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.

1 participant