Skip to content

Instantly share code, notes, and snippets.

@prasanthj
Created December 13, 2017 23:41
Show Gist options
  • Save prasanthj/c4e2e6a39c3dde5c3a4c05eca9b5493a to your computer and use it in GitHub Desktop.
Save prasanthj/c4e2e6a39c3dde5c3a4c05eca9b5493a to your computer and use it in GitHub Desktop.
Java Async Profiler Usage
# Pre-req: gcc, gcc-c++, git (to clone), openjdk with debug symbols (centos: java-1.8.0-openjdk-debug.x86_64, ubuntu: openjdk-8-dbg)
# Git clone async-profiler https://github.com/jvm-profiling-tools/async-profiler
# Make sure JAVA_HOME is set and you are logged as same user running the java process
cd async-profiler
make all
# Also git clone FlameGraph in the same directory as you clone async-profiler
# sysctl changes
echo 1 > /proc/sys/kernel/perf_event_paranoid
echo 0 > /proc/sys/kernel/kptr_restrict
# CPU profiling for 200s with 1ms sampling interval and flame graph generation
./profiler.sh -d 200 -o collapsed -f /tmp/collapsed.txt `pgrep -f ProcessName` && ../FlameGraph/flamegraph.pl --colors=java /tmp/collapsed.txt > /tmp/flamegraph.svg
# Heap profiling
./profiler.sh -d 200 -e alloc -f /tmp/heap.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment