Skip to content

perf: optimize create chunk assets#14332

Open
LingyuCoder wants to merge 1 commit into
mainfrom
codex/perf-create-chunk-assets
Open

perf: optimize create chunk assets#14332
LingyuCoder wants to merge 1 commit into
mainfrom
codex/perf-create-chunk-assets

Conversation

@LingyuCoder

@LingyuCoder LingyuCoder commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Round 6 for rust@create_chunk_assets reached the requested +5% target.

  • skip per-asset chunk_asset hook dispatch when the hook has no actual taps, including JS interceptor registrations that resolve to no taps
  • keep full-build render results as a linear Vec and avoid building ChunkRenderArtifact/FxHashMap unless incremental chunk-asset caching is enabled
  • collect full-build chunks into a Vec instead of hashing them into a set before render-manifest dispatch; incremental updates still dedupe affected chunks
  • split the no-chunk_asset fast path from the hooked path so the common path avoids a per-chunk hook-state branch
  • preserve the previous non-fatal behavior for interceptor registration errors by falling back to the hooked path instead of propagating probe errors
  • skip empty diagnostics extension while processing chunk render results
  • preallocate chunk render result storage before merging parallel render manifest output
  • preallocate each chunk render manifest vector for the common small-manifest case
  • keep the existing per-asset path when chunk_asset is observed by Rust or JS plugins

Expected performance mechanism

The create chunk assets stage can emit many chunk assets. In the common full-build no-listener path, this avoids hash-set construction for the chunk list, resolves chunk asset taps once for the pass, avoids an async hook call per emitted file, avoids full-build hash-map/artifact construction, reduces small Vec growth while collecting render manifests, skips empty diagnostics merging, batches chunk rendered/file bookkeeping per chunk, and keeps the hot no-hook loop separate from the compatibility hook loop.

Validation

CI-only workflow: local build, test, lint, and benchmark commands were not run. cargo fmt --all was run only to apply formatting after CI reported a rustfmt diff in an earlier round.

Round 6 head: 96029d1fd1c71b1361f3a5b80db73e5febb80df9.

GitHub Actions for this head passed:

  • CI Diff: success
  • CI-Dylint: success
  • CI-Rust: success
  • CI: success
  • CI-Lint: success

CodSpeed for this head reported:

  • rust@create_chunk_assets: 3.2 ms -> 3 ms, +5.14%
  • js@collect imported identifiers: 222.4 us -> 228.6 us, -2.71%

CodSpeed also reported Walltime/runtime-environment warnings, so the exact percentages should be read with that context. Binary size-limit reported +12.00KB / +0.02% for this head.

Copilot AI review requested due to automatic review settings June 9, 2026 08:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 targets the create_chunk_assets compilation pass to reduce overhead when many assets are emitted, primarily by avoiding per-asset chunk_asset hook dispatch in the no-listener case and by reducing allocation churn when collecting parallel render results.

Changes:

  • Preallocates storage for chunk render results before merging parallel render_manifest outputs.
  • Adds a fast path that batches per-chunk “rendered/files bookkeeping” and skips per-asset chunk_asset hook calls when the hook is empty.
  • Preserves the existing per-asset behavior when chunk_asset is observed (taps/interceptors present).

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

Comment thread crates/rspack_core/src/compilation/create_chunk_assets/mod.rs Outdated
@LingyuCoder LingyuCoder force-pushed the codex/perf-create-chunk-assets branch from 17409b2 to f8d1a60 Compare June 9, 2026 08:14
@codspeed-hq

codspeed-hq Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ 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

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 50 untouched benchmarks
⏩ 40 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation js@collect imported identifiers 222.4 µs 228.6 µs -2.71%
Simulation rust@create_chunk_assets 3.2 ms 3 ms +5.14%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing codex/perf-create-chunk-assets (96029d1) with main (b04d9f4)

Open in CodSpeed

Footnotes

  1. 40 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.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 96029d1 to feat: support rspack magic comment prefix (#14323) by AsyncIter

❌ Size increased by 12.00KB from 62.60MB to 62.61MB (⬆️0.02%)

@LingyuCoder LingyuCoder force-pushed the codex/perf-create-chunk-assets branch from f8d1a60 to cb9013a Compare June 9, 2026 08:45
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 551.3 KB 0 0
react-10k 5.6 MB 1.3 MB 0 0
react-1k 822.8 KB 218.3 KB 0 0
react-5k 2.7 MB 669.1 KB 0 0
ui-components 4.8 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

@LingyuCoder LingyuCoder force-pushed the codex/perf-create-chunk-assets branch from cb9013a to 5de5eb2 Compare June 9, 2026 09:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5de5eb2107

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/rspack_core/src/compilation/create_chunk_assets/mod.rs Outdated
@LingyuCoder LingyuCoder force-pushed the codex/perf-create-chunk-assets branch 3 times, most recently from 8bee73a to 253e4d6 Compare June 9, 2026 14:18
@LingyuCoder LingyuCoder force-pushed the codex/perf-create-chunk-assets branch from 253e4d6 to 96029d1 Compare June 9, 2026 14:37
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