Test app for benchmarking rspack's beforeModuleIds hook performance, as implemented in this pr: web-infra-dev/rspack#12809.
Link to local copy of rspack (with these changes). Make sure rspack is built first:
cd local/copy/of/rspack
pnpm run build:binding:dev
pnpm run build:jsThen install dependencies:
cd copy/of/this/repo
bun installCompare build performance with and without the beforeModuleIds hook:
bun run bench # 10 runs, 3 warmups
bun run bench:quick # 5 runs, 1 warmup
bun run bench:detailed # 20 runs, exports to bench-results.jsonbun run bench:detailed
$ hyperfine --warmup 3 --runs 20 --export-json bench-results.json 'bun run build:no-hook' 'bun run build:with-hook'
Benchmark 1: bun run build:no-hook
Time (mean ± σ): 486.5 ms ± 12.7 ms [User: 2164.4 ms, System: 243.9 ms]
Range (min … max): 466.8 ms … 510.1 ms 20 runs
Benchmark 2: bun run build:with-hook
Time (mean ± σ): 502.3 ms ± 14.4 ms [User: 2192.6 ms, System: 251.0 ms]
Range (min … max): 483.3 ms … 546.9 ms 20 runs
Summary
bun run build:no-hook ran
1.03 ± 0.04 times faster than bun run build:with-hookUSE_BEFORE_MODULE_IDS_HOOK=0 bun run build # Without hook
USE_BEFORE_MODULE_IDS_HOOK=1 bun run build # With hookGenerates 500 modules across 20 chunks. Edit scripts/generate-modules.mjs to adjust.
bun run generate