You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/en/contribute/development/profiling.md
+58Lines changed: 58 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,34 @@ Since different profilers have different strengths. It is good to use more than
6
6
7
7
<!-- toc -->
8
8
9
+
## Build release version with debug info
10
+
11
+
Performance analysis should be conducted on a release version that includes debug information. This approach ensures accurate performance results while providing sufficient debug information for analysis. Use the following command to profiling using local build rspack.
12
+
13
+
1. Build a release version with debug information:
14
+
15
+
```sh
16
+
just build release-debug
17
+
```
18
+
19
+
2. Change `@rspack/core` and `@rspack/cli` to use `link` protocol to link to local build Rspack:
will print the options passed to Rspack as well as each individual tracing event.
48
76
77
+
## CPU profiling
78
+
79
+
### Samply
80
+
81
+
[Samply](https://github.com/mstange/samply) supports performance analysis for both Rust and JavaScript simultaneously. Follow these steps to perform a complete performance analysis:
82
+
83
+
- Run the following command to start performance analysis:
84
+
85
+
```sh
86
+
samply record -- node --perf-prof --perf-basic-prof {your_rspack_folder}/rspack-cli/bin/rspack.js -c {your project}/rspack.config.js
87
+
```
88
+
89
+
- After the command execution, the analysis results will automatically open in the [Firefox Profiler](https://profiler.firefox.com/). The screenshot below is from a [Samply profiler](https://profiler.firefox.com/public/5fkasm1wcddddas3amgys3eg6sbp70n82q6gn1g/calltree/?globalTrackOrder=0&symbolServer=http%3A%2F%2F127.0.0.1%3A3000%2F2fjyrylqc9ifil3s7ppsmbwm6lfd3p9gddnqgx1&thread=2&v=10).
90
+
91
+
:::warning
92
+
Node.js currently only supports `--perf-prof` on Linux platforms. JavaScript profiling in Samply depends on `--perf-prof` support. If you need to use Samply for JavaScript profiling on other platforms, consider using Docker for profiling, or you can compile Node.js yourself for macOS using [node-perf-maps](https://github.com/tmm1/node/tree/v8-perf-maps) for profiling purposes.
93
+
:::
94
+
95
+
#### JavaScript profiling
96
+
97
+
Rspack’s JavaScript typically runs in the Node.js thread. Select the Node.js thread to view the time distribution on the Node.js side.
If we find that the performance bottleneck is on the JS side (e.g. js loader), then we need to further analyse the js side, and we can use Nodejs Profiling to analyse. for example
0 commit comments