Skip to content

Instantly share code, notes, and snippets.

@mks0ff
Forked from prasanthj/java-async-profiler.txt
Created June 8, 2018 11:01
Show Gist options
  • Save mks0ff/26a0a82775450703192fea9d417194a5 to your computer and use it in GitHub Desktop.
Save mks0ff/26a0a82775450703192fea9d417194a5 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