JS - flame graph로 cpu profiling
2022. 4. 24. 20:25ㆍ개발/Node & Javascript
728x90
반응형
개요
- flamegraph를 통해서 쉽게 성능 분석을 할 수 있다.
- 아래 예제는 dtrace를 mac 환경에서 실행했고, 이외에도 perf나 다양한 툴들을 통해 profiling하고, 이를 flamegraph로 만들어 낼 수 있다.
준비사항
flamegraph를 아래와 같이 설치해준다.
brew install flamegraph # 패키징된걸 사용한다.
test app
# app 실행 후, pid 확인
ps | grep -e "node";
# 가능한 probe 정보를 확인할 수 있다. profile probe에 관련된 것들을 확인
sudo dtrace -l | grep -e "profile"
# user stack을 확인한다. pid를 알맞게 넣어주면 된다.
# -x는 runtime args를 지정할 수 있다. 여기서는 ustackframes는 stackframe의 최대 depth를 설정한다.
sudo dtrace -x ustackframes=1000 -n 'profile-97 /pid == 80428/ { @[ustack()] = count(); } tick-60s { exit(0); }' -o out.user_stacks
# 해당 stack을 call별로 count를 만들어 준다.
stackcollapse.pl out.user_stacks > out.user_folded
# 해당 내용을 flamegraph로 만들어준다.
flamegraph.pl out.user_folded > out.svg
출처
GitHub - brendangregg/FlameGraph: Stack trace visualizer
Stack trace visualizer. Contribute to brendangregg/FlameGraph development by creating an account on GitHub.
github.com
Linux perf Examples
perf Examples These are some examples of using the perf Linux profiler, which has also been called Performance Counters for Linux (PCL), Linux perf events (LPE), or perf_events. Like Vince Weaver, I'll call it perf_events so that you can search on that ter
www.brendangregg.com
728x90
반응형
'개발 > Node & Javascript' 카테고리의 다른 글
[RxJS] bufferCount 써보기 (0) | 2022.05.08 |
---|---|
[RxJS] Promise.all 대신 mergeMap 써보기 (0) | 2022.05.08 |
Sharp.js로 blurhash 이미지 합성하기 (1) | 2022.03.31 |
Node.js - trampoline이란? ( tail call, recursion ) (2) | 2022.03.13 |
Nest.js 탐험기 7 - microservice (grpc) 를 사용해보자 - 인터셉터 (1) | 2022.03.06 |