Skip to content

WIP: Update Cody performance tracing documentation #1047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 37 additions & 14 deletions docs/cody/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -153,30 +153,53 @@ To fix this, navigate to https://sourcegraph.your-domain.com/cody/chat and click

### Record performance traces for Cody

You can get performance traces from the Cody VS Code extension in production with full support for source maps. To do so:
#### VS Code

- Start VS Code with a special runtime flag. In macOS, you can do so via the terminal like this:
You can capture performance traces from the Cody VS Code extension to help diagnose memory issues. To do so:

```bash
/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron --inspect-extensions=9333
```
1. Quit VS Code and start it with a special runtime flag (on Mac):
```bash
/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron --inspect-extensions=9333
```

2. Open Chrome and go to `chrome://inspect`

3. Configure the inspect server you started on port 9333:
- Click on **Open dedicated DevTools for Node**
- Go to the **Connection** tab
- Click **Add connection** and type `localhost:9333`

4. Return to the `chrome://inspect` tab, and you should see a new remote target that you can click **inspect** on

5. Click on the **Memory** tab, select **Allocation sampling** and click **Start** to begin profiling. Continue until the issue you're experiencing occurs

6. Let it run for a moment to register increasing memory usage (1-3 minutes should be fine). During that time, use VS Code normally.

7. Click **Stop** and when profiling is complete, right-click on the profile name and select **Save profile...**

8. Send us the saved profile file

#### JetBrains/IntelliJ

Note that you may need to quit VSCode first, then run that command to re-launch it. It will open all of your windows and tabs again.
- After VS Code is started, head over to Chrome and go to `chrome://inspect`, which takes you to the following:
To record performance traces in JetBrains IDEs:

![](https://gist.github.com/assets/458591/0a17881b-5449-48d5-a53e-5556f4f2dedd)
1. Start IntelliJ with the `CODY_AGENT_DEBUG_INSPECT=true` environment flag set. On macOS, you can do this by running:
```bash
CODY_AGENT_DEBUG_INSPECT=true open -na "IntelliJ IDEA.app"
```
(Note: App name may differ for other JetBrains variants)

- Configure the inspect server you started on port `9333` from here. To do so, click on **Open dedicated DevTools for Node**, then go to the **Connection** tab, and make sure to add `localhost:9333` to the list
2. Open Chrome and navigate to `chrome://inspect` in the address bar

![](https://gist.github.com/assets/458591/972ce113-88f0-482a-99b7-5e51957981ef)
3. You will see available targets - click **inspect** on the relevant one

- Now head back to the `chrome://inspect` tab, and you should see a new remote target that you can inspect
4. Select **Allocation sampling** and click **Start** to begin profiling. Continue until the issue you're experiencing occurs

![](https://gist.github.com/assets/458591/06b2e293-aea7-42e8-a9cc-592863b6fb07)
5. Let it run for 1-3 minutes while using IntelliJ normally

- Clicking this will open a (somewhat reduced) DevTools view. Great! We've almost got it. From here you can go to the **Performance** tab to record a trace. And finally, swap tabs to the VS Code window and interact with the extension. Come back later to stop the recording and export it.
6. Click **Stop**, and when profiling is complete, right-click on the profile name and select **Save profile...**

![](https://gist.github.com/assets/458591/d590636b-31e5-4436-8039-ee62b7a8e59f)
7. Send us the saved profile file

### Record a CPU profile for Cody in VSCode

Expand Down