Skip to content

Commit 0b99d1d

Browse files
juristrvsavkin
authored andcommitted
docs(misc): add videos plus details to performance profiling
1 parent 035b406 commit 0b99d1d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docs/shared/guides/performance-profiling.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Visualizing where and when the tasks were executed can help optimize the entire
55

66
## How to Profile the Performance of Running Tasks
77

8+
{% youtube src="https://youtu.be/Esx-P1Zf1-E" title="Performance Profiling Nx Tasks with Chrome Devtools" /%}
9+
810
1. Prepend `NX_PROFILE=profile.json` before running targets with Nx. For example,
911

1012
```shell
@@ -20,10 +22,24 @@ NX_PROFILE=profile.json nx affected --target build
2022
3. Click the upload button and open the `profile.json` that was created. (Or drag the file into the window)
2123
4. Expand each group to see the names of the tasks which were run
2224

23-
## Optimizing the Performance of Running Tasks
25+
### Optimizing the Performance of Running Tasks
2426

2527
Now that you have visualized how the tasks were run, you can try tweaking things to make the process faster. Generate profiles after each tweak and compare the results.
2628

2729
1. Are there tasks that you did not expect to be necessary? Sometimes, more tasks are captured by a command than expected. Excluding them could free up workers for other tasks.
2830
2. Try adding more workers. Did the new workers handle tasks while other workers were busy? This will likely result in faster runs.
2931
3. Are a lot of the tasks waiting on a single task to be completed? Splitting that project into smaller projects may allow fewer projects and therefore tasks to depend on a single project/task. This will allow for more room to parallelize the tasks.
32+
33+
## Profiling Nx Commands
34+
35+
{% youtube src="https://youtu.be/olkVyoc2MAQ" title="Performance Profiling Nx" /%}
36+
37+
Nx offloads much of the heavy lifting to the [Nx Daemon](/concepts/nx-daemon), which helps speed up task execution. However, you might still encounter slowdowns, not during the task execution itself, but in the moments leading up to it when invoking tasks through Nx. This can often happen when you're using a large number of [Nx Plugins](/plugin-registry), whether they come from the core team or the community.
38+
39+
To investigate and optimize these slowdowns, you can use the `NX_PERF_LOGGING` [environment variable](/reference/environment-variables). This will give you detailed performance logs and more precise timings, allowing you to pinpoint where the delays occur.
40+
41+
Here's an example of running the `build` of the `admin` project with performance logging enabled:
42+
43+
```shell
44+
NX_PERF_LOGGING=true NX_DAEMON=false npx nx build admin
45+
```

0 commit comments

Comments
 (0)