Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mloayzagahona/6b203a84d14003ac4e02e81e7fc7674f to your computer and use it in GitHub Desktop.
Save mloayzagahona/6b203a84d14003ac4e02e81e7fc7674f to your computer and use it in GitHub Desktop.
## Install perf in docker container
### ubuntu 18.4
### kernel 4.14.173-137.229.amzn2.x86_64
docker exec -it {containerid} sh
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.173.tar.xz && tar -xf ./linux-4.14.173.tar.xz && cd linux-4.14.173/tools/perf/ && apt -y install flex bison && make -C . && make install
./perf
./perf list
./perf bench mem all
Note: Run docker in privileged mode
References
https://medium.com/@geekidea_81313/running-perf-in-docker-kubernetes-7eb878afcd42
https://stackoverflow.com/questions/44745987/use-perf-inside-a-docker-container-without-privileged
## cpu profiling of a process
git clone https://github.com/brendangregg/FlameGraph
cd FlameGraph
/linux-4.14.173/tools/perf/perf record -F 99 -p {pid} -g -- sleep 60
/linux-4.14.173/tools/perf/perf script | ./stackcollapse-perf.pl > out.perf-folded
./flamegraph.pl out.perf-folded > perf-kernel.svg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment