Skip to content

perf: reduce federation lookup overhead and track runtime costs - #5237

Open
2heal1 wants to merge 1 commit into
mainfrom
perf/runtime-dod-20261103
Open

2heal1 wants to merge 1 commit into
mainfrom
perf/runtime-dod-20261103

Conversation

@2heal1

@2heal1 2heal1 commented Nov 3, 2026

Copy link
Copy Markdown
Member

Remote matching allocated expose strings even for failed candidates, large compiler remote lists scanned every request, and shared version selection repeatedly created the same regular expressions. This reduces that work while preserving public APIs, live runtime remote mutations, configuration order, fallback requests and share scopes.

  • Materialize runtime exposes only after a complete name/alias match; index compiler lists above 32 entries by their original configuration ordinal.
  • Reuse ten fixed semver regular expressions. Shared resolution results and user ranges are not cached. Add compatibility coverage for matching boundaries, duplicates, mutation and interleaved semver calls.
  • Add Runtime Core Performance CI: seven interleaved A/A + A/B rounds on Ubuntu 24.04 / Node 24.18.1, real runtime API startup diagnostics, shared-prefix controls, separate V8 profiles, complete browser payload measurements, job summaries and raw artifacts.

CPU timings remain advisory and are reported against same-runner A/A noise. The size gate covers full-featured runtime closures in webpack and esbuild, allowing max(1%, 1,024 raw bytes) and max(1%, 128 compressed bytes) of growth. Feature opt-outs cannot satisfy that gate.

Local webpack web-runtime payload: 64,704 B raw (-71), 18,841 B gzip (+28), 16,726 B Brotli (+6). The tradeoff is reduced CPU work with essentially unchanged compressed payload. Cold-start and full-build improvements are not claimed; the Node fixture excludes network, browser rendering and application work. Shared prefix hooks are measured without changing their implementation.

Validation:

  • pnpm exec turbo run build --filter=@module-federation/runtime-core --filter=@module-federation/enhanced --concurrency=4 — 15 tasks passed.
  • pnpm --filter @module-federation/runtime-core run test — 140 passed.
  • pnpm --filter @module-federation/enhanced run test — 505 passed, one existing skip; six serial tests passed.
  • pnpm exec prettier --check .
  • actionlint .github/workflows/runtime-performance.yml (v1.7.12).
  • node --test tools/scripts/report-runtime-dod.test.mjs — three gate tests passed.
  • node tools/scripts/benchmark-runtime-dod.mjs --baseline 512bef835 --rounds 1 --output /private/tmp/mf-dod-ci-pilot.json --profile-dir /private/tmp/mf-dod-ci-profiles — complete harness/profile smoke test. The subsequent seven-round local run completed four rounds before being stopped to move formal timing validation to CI.
  • node tools/scripts/measure-runtime-footprint.mjs --baseline 512bef835 --output tmp/runtime-performance/size.json — 23 paired payload scenarios; repeated web-full hashes matched.
  • node tools/scripts/report-runtime-dod.mjs /private/tmp/mf-dod-ci-final.json tmp/runtime-performance/size.json tmp/runtime-performance/report.md — size gate passed.
  • git diff --check.
  • Confirm seven-round performance job and its uploaded profiles on this PR.

The pre-existing skipped test is the HoistContainerReferencesPlugin federationRuntimeOriginModule case. Browser/network E2E, unrelated package suites, Metro and release execution were not run locally: this change affects runtime CPU matching/parsing and compiler lookup; existing package integration suites and the new CPU/payload workflow cover that scope. Reproduction and interpretation details are in tools/scripts/runtime-performance.md.

Preserve ordered and mutable runtime behavior while reducing remote matching
and semver allocations. Add calibrated performance reports, startup profiles,
and complete runtime payload budgets in CI.
@changeset-bot

changeset-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c27a72f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 48 packages
Name Type
@module-federation/runtime-core Patch
@module-federation/enhanced Patch
@module-federation/nextjs-mf Patch
@module-federation/runtime Patch
@module-federation/bridge-react Patch
@module-federation/modern-js-v3 Patch
@module-federation/modern-js Patch
@module-federation/node Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspress-plugin Patch
@module-federation/rstest Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
@module-federation/devtools Patch
@module-federation/dts-plugin Patch
@module-federation/esbuild Patch
@module-federation/metro Patch
@module-federation/observability-plugin Patch
@module-federation/playground Patch
@module-federation/retry-plugin Patch
@module-federation/runtime-tools Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/bridge-vue3 Patch
website-new Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
remote5 Patch
remote6 Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rock Patch
@module-federation/rspack Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/cli Patch
create-module-federation Patch
@module-federation/error-codes Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/sdk Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/treeshake-frontend Patch
@module-federation/treeshake-server Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/bridge-shared Patch
@module-federation/utilities Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T09:15:07.614079Z c27a72f PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/@module-federation/devtools@c27a72f

@module-federation/cli

pnpm add https://pkg.pr.new/@module-federation/cli@c27a72f

create-module-federation

pnpm add https://pkg.pr.new/create-module-federation@c27a72f

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/@module-federation/dts-plugin@c27a72f

@module-federation/enhanced

pnpm add https://pkg.pr.new/@module-federation/enhanced@c27a72f

@module-federation/error-codes

pnpm add https://pkg.pr.new/@module-federation/error-codes@c27a72f

@module-federation/esbuild

pnpm add https://pkg.pr.new/@module-federation/esbuild@c27a72f

@module-federation/managers

pnpm add https://pkg.pr.new/@module-federation/managers@c27a72f

@module-federation/manifest

pnpm add https://pkg.pr.new/@module-federation/manifest@c27a72f

@module-federation/metro

pnpm add https://pkg.pr.new/@module-federation/metro@c27a72f

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnc-cli@c27a72f

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnef@c27a72f

@module-federation/metro-plugin-rock

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rock@c27a72f

@module-federation/modern-js

pnpm add https://pkg.pr.new/@module-federation/modern-js@c27a72f

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/@module-federation/modern-js-v3@c27a72f

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/@module-federation/native-federation-tests@c27a72f

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/@module-federation/native-federation-typescript@c27a72f

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/@module-federation/nextjs-mf@c27a72f

@module-federation/node

pnpm add https://pkg.pr.new/@module-federation/node@c27a72f

@module-federation/observability-plugin

pnpm add https://pkg.pr.new/@module-federation/observability-plugin@c27a72f

@module-federation/playground

pnpm add https://pkg.pr.new/@module-federation/playground@c27a72f

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/@module-federation/retry-plugin@c27a72f

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/@module-federation/rsbuild-plugin@c27a72f

@module-federation/rspack

pnpm add https://pkg.pr.new/@module-federation/rspack@c27a72f

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/@module-federation/rspress-plugin@c27a72f

@module-federation/rstest

pnpm add https://pkg.pr.new/@module-federation/rstest@c27a72f

@module-federation/runtime

pnpm add https://pkg.pr.new/@module-federation/runtime@c27a72f

@module-federation/runtime-core

pnpm add https://pkg.pr.new/@module-federation/runtime-core@c27a72f

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/@module-federation/runtime-tools@c27a72f

@module-federation/sdk

pnpm add https://pkg.pr.new/@module-federation/sdk@c27a72f

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/@module-federation/storybook-addon@c27a72f

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/@module-federation/third-party-dts-extractor@c27a72f

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/@module-federation/treeshake-frontend@c27a72f

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/@module-federation/treeshake-server@c27a72f

@module-federation/typescript

pnpm add https://pkg.pr.new/@module-federation/typescript@c27a72f

@module-federation/utilities

pnpm add https://pkg.pr.new/@module-federation/utilities@c27a72f

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/@module-federation/webpack-bundler-runtime@c27a72f

@module-federation/bridge-react

pnpm add https://pkg.pr.new/@module-federation/bridge-react@c27a72f

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/@module-federation/bridge-react-webpack-plugin@c27a72f

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/@module-federation/bridge-shared@c27a72f

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/@module-federation/bridge-vue3@c27a72f

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/@module-federation/inject-external-runtime-core-plugin@c27a72f

commit: c27a72f

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Report

10 package(s) changed, 33 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/bridge-react 310.0 kB -1152 B (-0.4%) 1.5 kB -1 B (-0.1%)
@module-federation/bridge-vue3 191.3 kB -369 B (-0.2%) 27.4 kB +20 B (+0.1%)
@module-federation/enhanced 820.0 kB +757 B (+0.1%) 672 B no change
@module-federation/playground 16.07 MB -3572 B (-0.0%) 45.7 kB -97 B (-0.2%)
@module-federation/runtime-core 354.0 kB -184 B (-0.1%) 570 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/bridge-react 13.5 kB -16 B (-0.1%) 14.4 kB -15 B (-0.1%)
@module-federation/bridge-vue3 20.1 kB +34 B (+0.2%) 20.2 kB +31 B (+0.2%)
@module-federation/cli 2.3 kB -9 B (-0.4%) 2.4 kB -31 B (-1.3%)
@module-federation/core 1.0 kB -4 B (-0.4%) 1.0 kB -33 B (-3.0%)
@module-federation/devtools 30.3 kB no change 30.3 kB -24 B (-0.1%)
@module-federation/enhanced 2.7 kB +8 B (+0.3%) 2.8 kB -43 B (-1.5%)
@module-federation/metro-plugin-rnc-cli 416 B -1 B (-0.2%) 435 B -25 B (-5.4%)
@module-federation/node 9.1 kB +3 B (+0.0%) 9.1 kB -28 B (-0.3%)
@module-federation/playground 41.6 kB -92 B (-0.2%) 41.6 kB -92 B (-0.2%)
@module-federation/runtime-core 16.2 kB +20 B (+0.1%) 15.8 kB +22 B (+0.1%)

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 22.2 kB +30 B (+0.1%) 23.8 kB +28 B (+0.1%) +1.6 kB -2 B

Total dist (raw): 23.62 MB (-4520 B (-0.0%))
Total ESM gzip: 111.6 kB (-78 B (-0.1%))
Total web bundle (gzip): 253.3 kB (-57 B (-0.0%))
Total node bundle (gzip): 255.5 kB (-238 B (-0.1%))
Tracked ./bundler entry gzip: 563 B (no change)
Tracked ./bundler web bundle (gzip): 4.9 kB (no change)
Tracked ./bundler node bundle (gzip): 4.9 kB (no change)

Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as ./bundler are measured separately so ENV_TARGET-driven tree-shaking is visible. Bare imports are externalized to keep package-level sizes consistent, and assets are emitted as resources.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant