Example using perf on and visualising using flamescope:

Example running deno_tcp.ts in combination with flamegraph (script.sh):

  1. sudo flamegraph -o flamegraph.svg target/debug/deno run --allow-net cli/bench/deno_tcp.ts &
  2. sleep 1
  3. ./third_party/prebuilt/linux64/wrk http://localhost:4500/
  4. sleep 1
  5. kill `pgrep perf`

Example using v8 profiling on micro_bench_ops:

  1. # build `deno`
  2. cargo build --release
  3. ./target/release/deno --v8-flags=--prof --allow-net cli/bench/deno_tcp.ts &
  4. sleep 1
  5. ./third_party/prebuilt/linux64/wrk http://localhost:4500/
  6. sleep 1
  7. 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.

  1. # `ImportError: cannot import name _remove_dead_weakref`
  2. # In that case, use system python by setting PATH, e.g.
  3. # PATH=/System/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH
  4. (lldb) command script import "/Users/kevinqian/.rustup/toolchains/1.36.0-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py"
  5. (lldb) type summary add --no-value --python-function lldb_rust_formatters.print_val -x ".*" --category Rust
  6. (lldb) type category enable Rust
  7. (lldb) target create "../deno/target/debug/deno"
  8. Current executable set to '../deno/target/debug/deno' (x86_64).
  9. (lldb) settings set -- target.run-args "tests/http_bench.ts" "--allow-net"
  10. (lldb) b op_start
  11. (lldb) r

Particularly useful ones:

  1. --async-stack-trace