From 0aa7f38a9737638e7d1b5ad1c034540093679a2c Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 8 Oct 2024 19:24:58 -0700 Subject: [PATCH 1/3] Document profiling with pprof-it & pprof. --- Performance.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/Performance.md b/Performance.md index 7bf4dbe6..7f249b21 100644 --- a/Performance.md +++ b/Performance.md @@ -741,7 +741,43 @@ This will generate two files: * `dexnode` will emit to a file of the `isolate-*-*-*.log` (e.g. `isolate-00000176DB2DF130-17676-v8.log`). * `--generateCpuProfile` will emit to a file with the name of your choice. In the above example, it will be a file named `profile.cpuprofile`. -> ⚠ Warning: These files may include information from your workspace, including file paths and source code. +> [!WARNING] +> These files may include information from your workspace, including file paths and source code. +> Both of these files are readable as plain-text, and you can modify them before attaching them as part of a GitHub issue. (e.g. to scrub them of file paths that may expose internal-only information). +> +> However, if you have any concerns about posting these publicly on GitHub, let us know and you can share the details privately. + +## Profiling the Compiler with pprof + +[pprof](https://github.com/google/pprof) is a helpful utility for visualizing CPU and memory profiles. +pprof has different visualization modes that may make problem areas more obvious, and its profiles tend to be smaller than those produced from `--generateCpuProfile`. + +The easiest way to generate a profile for pprof is to use [pprof-it](https://github.com/jakebailey/pprof-it). +There are [different ways to use pprof-it](https://github.com/jakebailey/pprof-it?tab=readme-ov-file#usage), but a quick way is to use npx or a similar tool: + +```sh +npx pprof-it ./node_modules/typescript/lib/tsc.js ... +``` + +You can also install it locally: + +```sh +npm install --no-save pprof-it +``` + +and run certain build scripts via npm, npx, and similar tools with the `--node-option` flag: + +```sh +npm --node-option="--require pprof-it" run +``` + +To actually view the generated profile with [pprof](https://github.com/google/pprof), the Go toolset is required at minimum, and Graphviz is required for certain visualization capabilities. +[See more here](https://github.com/google/pprof?tab=readme-ov-file#building-pprof). + +Alternatively, you can use [SpeedScope](https://www.speedscope.app/) directly from your browser. + +> [!WARNING] +> These files may include information from your workspace, including file paths and source code. > Both of these files are readable as plain-text, and you can modify them before attaching them as part of a GitHub issue. (e.g. to scrub them of file paths that may expose internal-only information). > > However, if you have any concerns about posting these publicly on GitHub, let us know and you can share the details privately. From f83229d8e96f23d844f7f6680de1c19a592738b1 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 8 Oct 2024 19:29:35 -0700 Subject: [PATCH 2/3] Point out `PPROF_SANITIZE`. --- Performance.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Performance.md b/Performance.md index 7f249b21..08e37b1a 100644 --- a/Performance.md +++ b/Performance.md @@ -780,7 +780,8 @@ Alternatively, you can use [SpeedScope](https://www.speedscope.app/) directly fr > These files may include information from your workspace, including file paths and source code. > Both of these files are readable as plain-text, and you can modify them before attaching them as part of a GitHub issue. (e.g. to scrub them of file paths that may expose internal-only information). > -> However, if you have any concerns about posting these publicly on GitHub, let us know and you can share the details privately. +> pprof-it does recognize [the `PPROF_SANITIZE` environment variable to sanitize your profiles](https://github.com/jakebailey/pprof-it?tab=readme-ov-file#options) before posting them publicly. +> You can also share an unsanitized profile privately if you would prefer. ## Reporting Editing Performance Issues From e0aa6748539f1522d415924b900fd0aa05f6364b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 8 Oct 2024 19:31:33 -0700 Subject: [PATCH 3/3] More warning blocks. --- Performance.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Performance.md b/Performance.md index 08e37b1a..d9554b0a 100644 --- a/Performance.md +++ b/Performance.md @@ -662,9 +662,11 @@ Note that, even if your build doesn't directly invoke `tsc` (e.g. because you us You can [read more about performance tracing in more detail here](https://github.com/microsoft/TypeScript/wiki/Performance-Tracing). -⚠ Warning: A performance trace may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on GitHub, let us know and you can share the details privately. +> [!WARNING] +> A performance trace may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on GitHub, let us know and you can share the details privately. -⚠ Warning: The format of performance trace files is not stable, and may change from version to version. +> [!WARNING] +> The format of performance trace files is not stable, and may change from version to version. # Common Issues @@ -804,4 +806,5 @@ Including the output from `tsc --extendedDiagnostics` is always good context, bu 1. In VS Code, run the `TypeScript: Open TS Server log` command 1. This should open the `tsserver.log` file. -⚠ Warning: A TSServer log may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on GitHub, let us know and you can share the details privately. +> [!WARNING] +> A TSServer log may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on GitHub, let us know and you can share the details privately.