Profiling Go Code FLAME GRAPHS Ram Nadella Online Marketplace CPU - - PowerPoint PPT Presentation
Profiling Go Code FLAME GRAPHS Ram Nadella Online Marketplace CPU - - PowerPoint PPT Presentation
Profiling Go Code FLAME GRAPHS Ram Nadella Online Marketplace CPU Flame Graph of Linux Kernel Flame Graphs Function call stacks Each cell => Function Width => cost of the function Colors have no meaning Flame Graphs
Online Marketplace
CPU Flame Graph of Linux Kernel
Flame Graphs
- Function call stacks
- Each cell => Function
- Width => cost of the function
- Colors have no meaning
Flame Graphs
- SVG file
- Interactive
Generating CPU Flame Graphs
- Use perf/stap/dtrace to
generate call stacks
- Collapse stacks & generate
SVG file
brendangregg.com/FlameGraphs/cpuflamegraphs.html
Go
Setting up
import _ “net/http/pprof"
Setting up
import _ “net/http/pprof"
pprof
- Registers http handlers that expose profiling
actions
- /debug/pprof/profile
- /debug/pprof/trace
- /debug/pprof/heap
Setting up
package main import _ "net/http/pprof" func main() { … go func() { http.ListenAndServe(":27590", nil) }() … }
Setting up
package main import _ "net/http/pprof" func main() { … go func() { http.ListenAndServe(":27590", nil) }() … }
Profiling Go Code: Flame Graphs
> go get https://github.com/uber/go-torch > git clone https://github.com/brendangregg/FlameGraph > go-torch --time=10 --file “torch.svg" \
- -url http://<host>:<port>
Profiling Go Code: Flame Graphs
> go get https://github.com/uber/go-torch > git clone https://github.com/brendangregg/FlameGraph > go-torch --time=10 --file “torch.svg" \
- -url http://<host>:<port>
Search – stats*
References
- Flame Graphs
- go-torch