Skip to content

Commit

Permalink
[analysis_server] Add some notes on how to use the CPU Profiler for t…
Browse files Browse the repository at this point in the history
…he analysis server hosted by VS Code

Change-Id: I1af51746901d0eb579431c277b0cff204f025c42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397840
Reviewed-by: Brian Wilkerson <[email protected]>
Reviewed-by: Kenzie Davisson <[email protected]>
Commit-Queue: Brian Wilkerson <[email protected]>
Reviewed-by: Samuel Rawlins <[email protected]>
  • Loading branch information
DanTup authored and Commit Queue committed Dec 2, 2024
1 parent 0f723b3 commit e013a4c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/analysis_server/doc/process/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ The documentation covers the following topics:

- [Implementing a new language feature](new_language_feature.md)
- [Running/Debugging analysis_server from source in VS Code](running_in_vs_code.md)
- [Profiling the analysis server hosted by VS Code](profiling_for_vs_code)
40 changes: 40 additions & 0 deletions pkg/analysis_server/doc/process/profiling_for_vs_code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Profiling the analysis server hosted by VS Code

The steps below show how to use the DevTools CPU profiler against the instance
of the analysis server being hosted by VS Code. This allows profiling a short
window of operations (such as typing in the editor or invoking code completion).

- Open a project in VS Code that can be used to trigger the bad performance
- Run the **Preferences: Open Workspace Settings (JSON)** command from the
command palette (`F1`) or open the `.vscode/settings.json` file
- Add `"dart.analyzerVmServicePort": 8855` (the exact port number is not important
but you'll need it further down)
- Save the settings file
- A toast notification should appear in the bottom right warning you that the
analysis server's VM Service is enabled. This is a reminder that you should
remove the `dart.analyzerVmServicePort` setting when you are done.
- Wait for initial analysis to complete (No "Analyzing..." or spinners in the
status bar)
- Open a file and find a location where you can reproduce the bad performance
- Run the **Dart: Open DevTools in Browser** command from the palette (`F1`)
- In DevTools, enter `http://localhost:8855/` (using the port number from above)
and click **Connect**
- Navigate to the **CPU Profiler** tab
- Click **Enable Profiler**
- In the isolate selector (bottom middle of the page), select the Isolate named
**main**
- Click the **Start recording** button
- Switch back to VS Code and perform the actions that cause bad performance
- Back in DevTools, click the **Stop recording** button in the CPU Profiler

Profiling information should be displayed automatically and can be exported
using the export button on the top right corner. Exported information may
contain paths and class/member names from your project.

When you are done, don't forget to remove the VM Service port from your
workspace settings:

- Run the **Preferences: Open Workspace Settings (JSON)** command from the
command palette (`F1`) or open the `.vscode/settings.json` file
- Remove the `"dart.analyzerVmServicePort": 8855` setting
- Save the settings file

0 comments on commit e013a4c

Please sign in to comment.