denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.52k stars 5.18k forks source link

feat: `deno flamegraph` #22102

Open KnorpelSenf opened 6 months ago

KnorpelSenf commented 6 months ago

In order to analyse application performance, it can be useful to view a flamegraph, much like what cargo flamegraph is doing (https://github.com/flamegraph-rs/flamegraph). I suggest to have deno flamegraph that outputs a similar SVG file for the JavaScript side.

Deno can already do benchmarks with deno bench and perhaps someone has a good idea how to integrate these two related features?

mmastrac commented 6 months ago

We may be able to better integrate the v8 profiler to remove a lot of the required steps to get a profiling trace.

bartlomieju commented 6 months ago

For starters, as Matt pointed out we need to be able to acquire the profiling data from V8.

To do that we need to write out structures for types listed here: https://chromedevtools.github.io/devtools-protocol/tot/Profiler/#type-Profile This should be done in https://github.com/denoland/deno/blob/main/cli/cdp.rs.

Once we have that, it should be easy to collect a profile when a flag/env var is specified. Then the real fun begins where we need to provide a visualization for that data.