- flamegraph-rs ()
- flamescope (https://github.com/Netflix/flamescope)
Example using perf on and visualising using flamescope:
Example running deno_tcp.ts
in combination with flamegraph (script.sh
):
sudo flamegraph -o flamegraph.svg target/debug/deno run --allow-net cli/bench/deno_tcp.ts &
sleep 1
./third_party/prebuilt/linux64/wrk http://localhost:4500/
sleep 1
kill `pgrep perf`
Example using v8 profiling on micro_bench_ops
:
# build `deno`
cargo build --release
./target/release/deno --v8-flags=--prof --allow-net cli/bench/deno_tcp.ts &
sleep 1
./third_party/prebuilt/linux64/wrk http://localhost:4500/
sleep 1
kill `pgrep deno`
V8 will write a file in the current directory that looks like this:
isolate-0x7fad98242400-v8.log
. To examine this file:
prof.log
will contain information about tick distribution of different calls.
To view the log with Web UI, generate JSON file of the log:
Useful V8 flags during profiling:
- —prof
- —log-internal-timer-events
- —log-timer-events
- —track-gc
- —log-source-code
- —track-gc-object-stats
To learn more about profiling, check out the following links:
To debug the deno binary, we can use rust-lldb
. It should come with rustc
and is a wrapper around LLDB.
# `ImportError: cannot import name _remove_dead_weakref`
# In that case, use system python by setting PATH, e.g.
# PATH=/System/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH
(lldb) command script import "/Users/kevinqian/.rustup/toolchains/1.36.0-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py"
(lldb) type summary add --no-value --python-function lldb_rust_formatters.print_val -x ".*" --category Rust
(lldb) type category enable Rust
(lldb) target create "../deno/target/debug/deno"
Current executable set to '../deno/target/debug/deno' (x86_64).
(lldb) settings set -- target.run-args "tests/http_bench.ts" "--allow-net"
(lldb) b op_start
(lldb) r
Particularly useful ones:
--async-stack-trace