close
logologo
Guide
Config
Plugin
API
Community
Version
Changelog
Rsbuild 0.x Doc
English
简体中文
Guide
Config
Plugin
API
Community
Changelog
Rsbuild 0.x Doc
English
简体中文
logologo

Getting Started

Introduction
Quick start
Features
Glossary

Framework

React
Vue
Preact
Svelte
Solid

Basic

CLI
Dev server
Output files
Static assets
HTML
JSON
Wasm
TypeScript
Web Workers
Deploy static site
Upgrade Rsbuild

Configuration

Configure Rspack
Configure Rsbuild
Configure SWC

Styling

CSS
CSS Modules
CSS-in-JS
Tailwind CSS v4
Tailwind CSS v3
UnoCSS

Advanced

Path aliases
Environment variables
Hot module replacement
Browserslist
Browser compatibility
Module Federation
Multi-environment builds
Server-side rendering (SSR)
Testing

Optimization

Code splitting
Bundle size optimization
Improve build performance
Inline static assets

Migration

Migrating from Rsbuild 0.x
webpack
Create React App
Vue CLI
Vite
Vite plugin
Modern.js Builder

Debug

Debug mode
Build profiling
Use Rsdoctor

FAQ

General FAQ
Features FAQ
Exceptions FAQ
HMR FAQ
📝 Edit this page on GitHub
Previous PageDebug mode
Next PageUse Rsdoctor

#Build profiling

Performing a performance analysis can help you identify performance bottlenecks in your project, allowing for targeted optimization.

#Using Rsdoctor

Rsdoctor is a build analyzer that can visually display the compilation time of each loader and plugin.

Please refer to Use Rsdoctor for more information.

#Node.js profiling

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:

# dev
node --cpu-prof ./node_modules/@rsbuild/core/bin/rsbuild.js dev

# build
node --cpu-prof ./node_modules/@rsbuild/core/bin/rsbuild.js build

# Set higher precision sampling interval
node --cpu-prof --cpu-prof-interval=100 ./node_modules/@rsbuild/core/bin/rsbuild.js build

The above commands will generate a *.cpuprofile file. We can use speedscope to visualize this file:

# Install speedscope
npm install -g speedscope

# View cpuprofile content
# Replace the name with the local file name
speedscope CPU.date.000000.00000.0.001.cpuprofile

#Rspack profiling

Rsbuild supports the use of the RSPACK_PROFILE environment variable for Rspack build performance profile.

package.json
{
  "scripts": {
    "dev:profile": "RSPACK_PROFILE=OVERVIEW rsbuild dev",
    "build:profile": "RSPACK_PROFILE=OVERVIEW rsbuild build"
  }
}

As Windows does not support the above usage, you can also use cross-env to set environment variables. This ensures compatibility across different systems:

package.json
{
  "scripts": {
    "dev:profile": "cross-env RSPACK_PROFILE=OVERVIEW rsbuild dev",
    "build:profile": "cross-env RSPACK_PROFILE=OVERVIEW rsbuild build"
  },
  "devDependencies": {
    "cross-env": "^7.0.0"
  }
}

When the build command is finished, or the dev server is shut down, Rsbuild will create a .rspack-profile-${timestamp}-${pid} folder in the current directory, containing a rspack.pftrace file (in versions before 1.4.0, it was trace.json), which is generated by Rspack based on tracing and records the time spent on each phase at a granular level, and can be viewed using ui.perfetto.dev.

TIP
  • When shutting down the dev server, use CTRL + D instead of CTRL + C to ensure that Rspack can record the performance data completely.
  • The generated trace.json file is large, if you need to share it with others, you can compress it into a zip file to reduce the size.
  • For more information about Rspack profiling, refer to Rspack - Tracing.