Clone
5
Runtime debugging
Robo edited this page 2025-11-26 11:18:53 +09:00

Table of Contents

CPU profiling unresponsive window via tracing

When a window (renderer process) is unresponsive the devtools might be unable to collect the required cpu profile. A reliable way to profile in such cases is with the tracing infra using the steps below,

  • Restart VS Code with the following flags --trace --trace-category-filter="renderer,blink,v8,disabled-by-default-v8.cpu_profiler"
  • Once the unresponsive dialog pop ups, click on the Reopen button
  • In the new window, execute "F1 > Developer: Stop Tracing"

This will generate a trace json file which can be loaded into any of the following clients that supports the Google's Trace Event format

  1. chrome://tracing in any chromium browser
  2. ui.perfetto.dev
  3. Firefox profiler

Using samply on macOS

If you have an unsigned build of VSCode, then samply can be used to capture both JIT and native traces

  • Download the latest release of https://github.com/mstange/samply/releases
  • Start from the command line with following samply.exe record -s -o profile.json.gz --browsers -- <path>/Visual\ Studio\ Code.app/Contents/MacOS/Electron --js-flags="--perf-basic-prof --perf-prof-unwinding-info --interpreted-frames-native-stack"
  • Perform the steps for unresponsiveness or slow startups etc
  • Exit the application and the profile will be saved to profile.json.gz

You can inspect the profile with samply.exe load --breakpad-symbol-dir <path> profile.json.gz

Using samply on windows

If you want to capture only application related cpu profile with both JIT and native traces

  • Download the latest release of https://github.com/mstange/samply/releases
  • Start from the command line with following samply.exe record -s -o profile.json.gz --browsers -- <path>/Microsoft\ VS\ Code/Code.exe --js-flags="--enable-etw-stack-walking --interpreted-frames-native-stack"
  • Perform the steps for unresponsiveness or slow startups etc
  • Exit the application and the profile will be saved to profile.json.gz

You can inspect the profile with samply.exe load --breakpad-symbol-dir <path> profile.json.gz

Using samply on linux

  • Download the latest release of https://github.com/mstange/samply/releases
  • Start from the command line with following samply.exe record -s -o profile.json.gz --browsers -- <path>/code --js-flags="--perf-basic-prof --perf-prof-unwinding-info --interpreted-frames-native-stack"
  • Perform the steps for unresponsiveness or slow startups etc
  • Exit the application and the profile will be saved to profile.json.gz

You can inspect the profile with samply.exe load --breakpad-symbol-dir <path> profile.json.gz

Using etw on windows

The .etl file should not be attached to public issues since they contain PII and only shared via trusted channels.