This repository is used to monitor Rspack performance.
Usage
You can use the scripts in the bin directory to prepare and run benchmark. All interactions are of the form
node bin/cli.js [command] [args]
If no command is specified, then build, bench and compare commands will all be ran by default.
Commands
build
node bin/cli.js build [--ref <ref>]
Clone and build Rspack in the folder which defined by the environment variable of RSPACK_DIR or <project_root>/.rspack. You can set Git ref with the parameter, e.g.:
node bin/cli.js build # use the main branch to build
node bin/cli.js build --ref main # use the main branch to build
node bin/cli.js build --ref pull/1000/head # use the pull request with index 1000 to build
Run benchmark with Rspack and write the output to output folder. You can configure the environment variable of RSPACK_DIR to set the Rspack project path, and it will use the Rspack from the .rspack folder by default. eg.
node bin/cli.js bench # run all benchmarks
node bin/cli.js bench --job 10000_development-mode --job 10000_production-mode # run benchmarks named 10000_development-mode and 10000_production-mode
RSPACK_DIR=<your-rspack-path> node bin/cli.js bench --job 10000_development-mode_hmr # set the rspack command path, and run 10000_development-mode_hmr
Compare and print the difference between <baseDate> and <currentDate>. The parameter has three types, "current" will use the data from output folder. "latest" will use the latest data from data branch. A date string like YYYY-MM-DD will use the data of that day from data branch. eg.
node bin/cli.js compare --base current --current latest # use output data as base, and latest data as current
node bin/cli.js compare --base latest --current 2023-08-17 # use latest data as base, and the data of 2023-08-17 as current
Glossary
Benchmark Name
Benchmark name is a string containing the case name and the addon names. A benchmark name is separated by “_“, the first part is the case name, amd the other parts are the addon names.
Case
The benchmark case is the Rspack project in cases folder. It must contain rspack.config.js and hmr.js, the first one is the default config for Rspack, the next one is used to tell benchmark how to change file when hmr.
10000 is a project with 10000 modules
threejs is a copy of three js
bundled-threejs imports the three package directly to benchmark large bundled-library builds
Addon
The addon is used to change Rspack configuration and benchmark parameters. All addons are registered in lib/addons.
development-mode is used to set the development mode
production-mode is used to set the production mode
10x is used to make the project module 10 times larger
hmr is used to change the phase of collected metrics to hmr instead of build
Metric
The metrics collected through benchmarking includes stats, exec, dist size, etc.
Tag
The tag is benchmarkName + metric, it is used to display information on website and comparison results.
How benchmark works
Rspack benchmark consists of the following steps.
flowchart LR
A("Setup") --> B("Generate")
B --> C("Warmup")
C --> D("Run")
D --> E("Statistic")
E --> F("Teardown")
Setup is used to prepare the benchmark case environment and global context.
Generate will generate the benchmark case.
Warmup will attempt to run the benchmark case.
Run will run the benchmark case multiple times and collect metric data.
Statistic will calculate the final result through multiple benchmarks.
Teardown is used to clean up.
The main process is controlled by scenario, and its structure is:
Rspack Benchmark
This repository is used to monitor Rspack performance.
Usage
You can use the scripts in the
bindirectory to prepare and run benchmark. All interactions are of the formIf no command is specified, then
build,benchandcomparecommands will all be ran by default.Commands
build
Clone and build Rspack in the folder which defined by the environment variable of
RSPACK_DIRor<project_root>/.rspack. You can set Git ref with the parameter, e.g.:bench
Run benchmark with Rspack and write the output to
outputfolder. You can configure the environment variable ofRSPACK_DIRto set the Rspack project path, and it will use the Rspack from the.rspackfolder by default. eg.compare
Compare and print the difference between
<baseDate>and<currentDate>. The parameter has three types,"current"will use the data fromoutputfolder."latest"will use the latest data fromdatabranch. A date string likeYYYY-MM-DDwill use the data of that day fromdatabranch. eg.Glossary
Benchmark Name
Benchmark name is a string containing the case name and the addon names. A benchmark name is separated by “_“, the first part is the case name, amd the other parts are the addon names.
Case
The benchmark case is the Rspack project in
casesfolder. It must containrspack.config.jsandhmr.js, the first one is the default config for Rspack, the next one is used to tell benchmark how to change file when hmr.10000is a project with 10000 modulesthreejsis a copy of three jsbundled-threejsimports thethreepackage directly to benchmark large bundled-library buildsAddon
The addon is used to change Rspack configuration and benchmark parameters. All addons are registered in
lib/addons.development-modeis used to set the development modeproduction-modeis used to set the production mode10xis used to make the project module 10 times largerhmris used to change the phase of collected metrics to hmr instead of buildMetric
The metrics collected through benchmarking includes
stats,exec,dist size, etc.Tag
The tag is
benchmarkName+metric, it is used to display information on website and comparison results.How benchmark works
Rspack benchmark consists of the following steps.
flowchart LR A("Setup") --> B("Generate") B --> C("Warmup") C --> D("Run") D --> E("Statistic") E --> F("Teardown")Setupis used to prepare the benchmark case environment and global context.Generatewill generate the benchmark case.Warmupwill attempt to run the benchmark case.Runwill run the benchmark case multiple times and collect metric data.Statisticwill calculate the final result through multiple benchmarks.Teardownis used to clean up.The main process is controlled by
scenario, and its structure is:The addons can change context in most steps, and its structure is:
How to add a benchmark case
casesfolderrspack.config.jsto make the project runnable by Rspackhmr.jsto make the project support hmr changesRSPACK_DIR=<your-rspack-path> node bin/cli.js bench <your case>_<your addons>to testHow to create a addon
lib/addonswith kebab case like “a-b-c.js”lib/addons/commonand implement the hooks you want to listenRSPACK_DIR=<your-rspack-path> node bin/cli.js bench <case>_<your addons>to testjobsfield in./bench.config.js.License
MIT licensed.