Profiling Extension in Production

March 7, 2024 Engineering/VS Code

The VS Code extension runtime uses Node.js (via Electron) and you can thus use Node.js related debugging tool.

Here's a quick guide on how to record performances traces of VS Code extensions:

/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron --inspect-extensions=9333

After VS Code is started, you want to head over to Chrome and go to chrome://inspect which should open up a view like this:

tracing overview

From here you want to configure the inspect server that we just started on port 9333. To do this, click on "Open dedicated DevTools for Node", go to the "Connection" tab if that is not open yet, and make sure to add localhost:9333 to the list like this:

add localhost to the list

Now, head back to the chrome://inspect tab and you should see a new remote target that you can inspect. For me this looks like this:

tracing overview with a new electron option

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. Then, swap tabs to the VS Code window and interact with the extension. Come back later to stop the recording and export it. Voila!

screenshot of the performance tab in the nodejs profiler


Pssst! If you liked what you just read, I just started a newsletter where I share things whenever inspiration strikes. You'd be among the first to join our little secret club. No spam, pinky promise.

About the author

Philipp Spiess
Philipp Spiess [ˈʃpiːs]

Engineer at Tailwind Labs.
Prev: Engineer at Sourcegraph and Meta, curator of This Week in React, React DOM team member, and Team Lead at PSPDFKit.