Skip to content

refactor(loader): schedule loader chains as execution units - #15219

Draft
intellild wants to merge 9 commits into
mainfrom
codex/loader-chain
Draft

refactor(loader): schedule loader chains as execution units#15219
intellild wants to merge 9 commits into
mainfrom
codex/loader-chain

Conversation

@intellild

@intellild intellild commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • make Loaders<Context> the single owner of raw loaders, loader items, and execution chains
  • expose loader execution as Loaders::run_loaders
  • use ArcComputed to project lazy items/chains directly from Arc<Loaders>
  • separate shared immutable loader metadata from per-run execution state
  • schedule consecutive JavaScript loaders as one execution span while keeping native loaders as individual spans
  • serialize worker options only for loaders inside the active JavaScript chain

This reduces repeated Rust ↔ JavaScript scheduling boundaries and avoids rebuilding loader items for every module build.

For example, a chain like js-a -> js-b -> builtin:swc-loader -> js-c is planned as [js-a, js-b], [builtin:swc-loader], and [js-c]. The first two JavaScript loaders execute in one JavaScript scheduling unit, while the native loader stays on the Rust side. When a parallel worker runs that first span, options outside [js-a, js-b] are excluded from structured cloning.

Implementation flow

NormalModule build
  Arc<Loaders>::run_loaders
       ↓
lazy loader_items + loader_chains
  computed once in Loaders
       ↓
ArcComputed projections
  owner: Arc<Loaders>
       ↓
LoaderContext
  per-run loader state
       ↓
chain-based pitch/normal execution

Loaders and the other ArcComputed owner, ResolvedModuleOptions, carry PhantomPinned. Loader-chain ranges remain compact u8 values, with a debug assertion protecting the internal maximum-loader-count invariant.

Validation

  • cargo fmt --all --check
  • cargo check -p rspack_loader_runner -p rspack_core -p rspack_binding_api --all-targets --locked
  • cargo test -p rspack_loader_runner --locked (10 passed)
  • ./node_modules/.bin/tsc --noEmit --pretty false -p packages/rspack/tsconfig.json
  • pnpm run build:js
  • staged Rust/TypeScript format and lint hooks

Related links

N/A

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

by OpenAI Codex

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing f02ffaf to perf(binding): exclude perfetto from release WASI builds (#15221) by Jiahan Chen

❌ Size increased by 8.00KB from 68.26MB to 68.27MB (⬆️0.01%)

@github-actions

github-actions Bot commented Aug 17, 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 556.5 KB 0 0
react-1k 823.1 KB 218.4 KB 0 0
react-10k 5.6 MB 1.3 MB 0 0
react-5k 2.7 MB 669.3 KB 0 0
ui-components 4.9 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

@codspeed-hq

codspeed-hq Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 50 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing codex/loader-chain (f02ffaf) with main (7830b53)

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