Performing a performance analysis can help you identify performance bottlenecks in your project, allowing for targeted optimization.
Rsdoctor is a build analyser that can visually display the compilation time of each loaders and plugins.
Please refer to Use Rsdoctor for more information.
When Rsbuild executes a build, it will include the runtime overhead of both JavaScript and Rust code, and the overhead of data communication between JavaScript and Rust.
In general, the performance overhead on the JavaScript side will be greater than that on the Rust side. You can use Node.js profiling to analyze the overhead on the JS side, which helps to identify performance bottlenecks on the JS side.
For example, to perform the CPU profiling analysis, run the following command in the root directory of your project:
The above commands will generate a *.cpuprofile
file. We can use speedscope to visualize this file:
Rsbuild supports the use of the RSPACK_PROFILE
environment variable for Rspack build performance profile.
The command will generate a rspack-profile-${timestamp}
folder in the dist folder, and it will contain logging.json
, trace.json
and jscpuprofile.json
files:
trace.json
: The time spent on each phase of the Rust side is recorded at a granular level using tracing and can be viewed using ui.perfetto.dev.jscpuprofile.json
: The time spent at each stage on the JavaScript side is recorded at a granular level using Node.js inspector and can be viewed using speedscope.app.logging.json
: Includes some logging information that keeps a coarse-grained record of how long each phase of the build took. (Not supported in development mode yet)For more information about Rspack build performance analysis, please refer to Rspack - Profiling.