기본 웹 사이트 : http://www.brendangregg.com/flamegraphs.html
예제 (줌 클릭) :
상자를 클릭하여 화염 그래프를이 스택 프레임으로 확대하십시오. 정규 표현식과 일치하는 모든 스택 프레임을 검색하고 강조하려면 오른쪽 상단의 검색 버튼을 클릭하거나 Ctrl-F를 누릅니다. 기본적으로 검색은 CASE에 민감하지만 CTRL-I를 누르거나 오른쪽 상단의 IC 버튼을 클릭하여 토글 할 수 있습니다.
기타 사이트 :
화염 그래프는 세 단계로 만들 수 있습니다.
스택 샘플은 Linux Perf_events, Freebsd PMCSTAT (HWPMC), DTRACE, SYSTEMTAP 및 기타 많은 프로파일 러를 사용하여 캡처 할 수 있습니다. stackcollapse-* 변환기를 참조하십시오.
Linux Perf_events (일명 "Perf")를 사용하여 99 개의 Hertz 스택 샘플, 사용자- 및 커널 레벨 스택 모두, 모든 프로세스를 캡처합니다.
# perf record -F 99 -a -g -- sleep 60
# perf script > out.perf
이제 PID 181 만 캡처합니다.
# perf record -F 99 -p 181 -g -- sleep 60
# perf script > out.perf
DTRACE를 사용하여 997 Hertz에서 60 초의 커널 스택을 캡처합니다.
# dtrace -x stackframes=100 -n 'profile-997 /arg0/ { @[stack()] = count(); } tick-60s { exit(0); }' -o out.kern_stacks
DTRACE를 사용하여 97 Hertz에서 PID 12345의 60 초의 사용자 수준 스택을 캡처합니다.
# dtrace -x ustackframes=100 -n 'profile-97 /pid == 12345 && arg1/ { @[ustack()] = count(); } tick-60s { exit(0); }' -o out.user_stacks
97 Hertz의 PID 12345에 대한 커널을 포함한 시간을 포함하여 60 초의 사용자 수준 스택 :
# dtrace -x ustackframes=100 -n 'profile-97 /pid == 12345/ { @[ustack()] = count(); } tick-60s { exit(0); }' -o out.user_stacks
응용 프로그램에 번역 된 프레임 (예 : Node.js 프레임; http://dtrace.org/blogs/dap/2012/01/05/where-does를 포함하도록 USTACK 도우미가있는 경우 jstack ustack()
jstack()
-당신의-노드-프로그램-스펜트-트 시간/). 사용자 수준의 스택 컬렉션의 속도는 커널보다 고의적으로 느리게 느리므로 프레임을 번역하기 위해 추가 작업을 수행하므로 jstack()
사용할 때 특히 중요합니다.
StackCollapse 프로그램을 사용하여 스택 샘플을 단일 라인으로 접습니다. 제공된 프로그램은 다음과 같습니다.
stackcollapse.pl
: dtrace 스택 용stackcollapse-perf.pl
: Linux Perf_events "Perf Script"출력 용stackcollapse-pmc.pl
: freebsd pmcstat -g 스택stackcollapse-stap.pl
: SystemTap 스택 용stackcollapse-instruments.pl
: Xcode Instruments 용stackcollapse-vtune.pl
: Intel vtune 프로파일 용stackcollapse-ljp.awk
: 경량 Java 프로파일 러 용stackcollapse-jstack.pl
: Java Jstack (1) 출력stackcollapse-gdb.pl
: gdb (1) 스택stackcollapse-go.pl
: Golang pprof 스택 용stackcollapse-vsprof.pl
: Microsoft Visual Studio 프로필 용stackcollapse-wcp.pl
: WallClockProfiler 출력 용사용 예 :
For perf_events:
$ ./stackcollapse-perf.pl out.perf > out.folded
For DTrace:
$ ./stackcollapse.pl out.kern_stacks > out.kern_folded
출력은 다음과 같습니다.
unix`_sys_sysenter_post_swapgs 1401
unix`_sys_sysenter_post_swapgs;genunix`close 5
unix`_sys_sysenter_post_swapgs;genunix`close;genunix`closeandsetf 85
unix`_sys_sysenter_post_swapgs;genunix`close;genunix`closeandsetf;c2audit`audit_closef 26
unix`_sys_sysenter_post_swapgs;genunix`close;genunix`closeandsetf;c2audit`audit_setf 5
unix`_sys_sysenter_post_swapgs;genunix`close;genunix`closeandsetf;genunix`audit_getstate 6
unix`_sys_sysenter_post_swapgs;genunix`close;genunix`closeandsetf;genunix`audit_unfalloc 2
unix`_sys_sysenter_post_swapgs;genunix`close;genunix`closeandsetf;genunix`closef 48
[...]
svg를 렌더링하려면 flamegraph.pl을 사용하십시오.
$ ./flamegraph.pl out.kern_folded > kernel.svg
접힌 입력 파일을 갖는 장점 (그리고 이것이 FlameGraph.pl과 분리 된 이유)은 관심있는 함수에 grep을 사용할 수 있다는 것입니다. 예 : :
$ grep cpuid out.kern_folded | ./flamegraph.pl > cpuid.svg
Linux "Perf Script"의 출력 예제는 example-perf-stacks.txt.gz로 Gzip'd가 포함되어 있습니다. 결과 화염 그래프는 example-perf.svg입니다.
다음을 사용 하여이 작업을 만들 수 있습니다.
$ gunzip -c example-perf-stacks.txt.gz | ./stackcollapse-perf.pl --all | ./flamegraph.pl --color=java --hash > example-perf.svg
이것은 내 일반적인 워크 플로를 보여줍니다. 대상의 프로필을 GZIP 프로파일로 한 다음 분석을 위해 랩톱에 복사 할 것입니다. 수백 개의 프로필이 있기 때문에 gzip'd를 남겨 둡니다!
이 프로파일에는 Java가 포함되었으므로 flamegraph.pl -color = java 팔레트를 사용했습니다. 또한 stackCollapse-perf.pl (all)을 사용했습니다. 여기에는 flamegraph.pl이 커널 및 사용자 수준 코드에 별도의 색상을 사용하는 데 도움이되는 모든 주석이 포함되어 있습니다. 결과 화염 그래프는 Green == Java, Yellow == C ++, Red == 사용자 모드 네이티브, Orange == 커널을 사용합니다.
이 프로파일은 Vert.x 성능 분석에서 나온 것입니다. 벤치 마크 클라이언트 인 WRK도 화염 그래프에서 볼 수 있습니다.
dtrace의 예제 출력도 포함되어 있습니다. example-dtrace-stacks.txt 및 결과 화염 그래프, example-dtrace.svg :
다음을 사용 하여이를 생성 할 수 있습니다.
$ ./stackcollapse.pl example-stacks.txt | ./flamegraph.pl > example.svg
이것은 특정 성능 조사에서 나온 것입니다. 화염 그래프는 CPU 시간이 LOFS 모듈에 소비되었음을 확인하고 그 시간을 정량화했습니다.
옵션은 사용법 메시지 (-Help)를 참조하십시오.
사용법 : ./flamegraph.pl [옵션] infile> outfile.svg
--title TEXT # change title text
--subtitle TEXT # second level title (optional)
--width NUM # width of image (default 1200)
--height NUM # height of each frame (default 16)
--minwidth NUM # omit smaller functions. In pixels or use "%" for
# percentage of time (default 0.1 pixels)
--fonttype FONT # font type (default "Verdana")
--fontsize NUM # font size (default 12)
--countname TEXT # count type label (default "samples")
--nametype TEXT # name type label (default "Function:")
--colors PALETTE # set color palette. choices are: hot (default), mem,
# io, wakeup, chain, java, js, perl, red, green, blue,
# aqua, yellow, purple, orange
--bgcolors COLOR # set background colors. gradient choices are yellow
# (default), blue, green, grey; flat colors use "#rrggbb"
--hash # colors are keyed by function name hash
--cp # use consistent palette (palette.map)
--reverse # generate stack-reversed flame graph
--inverted # icicle graph
--flamechart # produce a flame chart (sort by time, do not merge stacks)
--negate # switch differential hues (blue<->red)
--notes TEXT # add notes comment in SVG (for debugging)
--help # this message
eg,
./flamegraph.pl --title="Flame Graph: malloc()" trace.txt > graph.svg
예제에서 제안한 바와 같이, 화염 그래프는 스택 추적이 수집 된 경우 malloc () s와 같은 모든 이벤트의 흔적을 처리 할 수 있습니다.
--cp
옵션을 사용하는 경우 $ Colors 선택을 사용하고 일반적인 팔레트를 평범하게 무작위로 생성합니다. --cp
옵션을 사용하여 생성 된 향후 Flamegraphs는 동일한 팔레트 맵을 사용합니다. Future Flamegraphs의 새로운 기호는 $ colors 선택을 사용하여 색상이 무작위로 생성됩니다.
팔레트가 마음에 들지 않으면 팔레트 .map 파일을 삭제하십시오.
이를 통해 화염 그래프 사이의 ColorsCheme을 변경하여 차이점을 실제로 눈에 띄게 만듭니다.
예:
문제가있는 2 개의 캡처가 있고, 일할 때 ( "무엇이든"캡처가 있다고 가정 해 봅시다.
cat working.folded | ./flamegraph.pl --cp > working.svg
# this generates a palette.map, as per the normal random generated look.
cat broken.folded | ./flamegraph.pl --cp --colors mem > broken.svg
# this svg will use the same palette.map for the same events, but a very
# different colorscheme for any new events.
예를 들어 데모 디렉토리를 살펴보십시오.
팔레트-예비-작업 .svg
Palette-Axample Broken.svg