Profiling Go Code FLAME GRAPHS Ram Nadella Online Marketplace CPU - - PowerPoint PPT Presentation

profiling go code
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Profiling Go Code

FLAME GRAPHS

Ram Nadella

slide-2
SLIDE 2
slide-3
SLIDE 3

Online Marketplace

slide-4
SLIDE 4
slide-5
SLIDE 5
slide-6
SLIDE 6

CPU Flame Graph of Linux Kernel

slide-7
SLIDE 7

Flame Graphs

  • Function call stacks
  • Each cell => Function
  • Width => cost of the function
  • Colors have no meaning
slide-8
SLIDE 8

Flame Graphs

  • SVG file
  • Interactive
slide-9
SLIDE 9
slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12
slide-13
SLIDE 13
slide-14
SLIDE 14

Generating CPU Flame Graphs

  • Use perf/stap/dtrace to

generate call stacks

  • Collapse stacks & generate

SVG file

brendangregg.com/FlameGraphs/cpuflamegraphs.html

slide-15
SLIDE 15

Go

slide-16
SLIDE 16

Setting up

import _ “net/http/pprof"

slide-17
SLIDE 17

Setting up

import _ “net/http/pprof"

slide-18
SLIDE 18

pprof

  • Registers http handlers that expose profiling

actions

  • /debug/pprof/profile
  • /debug/pprof/trace
  • /debug/pprof/heap
slide-19
SLIDE 19

Setting up

package main import _ "net/http/pprof" func main() { … go func() { http.ListenAndServe(":27590", nil) }() … }

slide-20
SLIDE 20

Setting up

package main import _ "net/http/pprof" func main() { … go func() { http.ListenAndServe(":27590", nil) }() … }

slide-21
SLIDE 21

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>
slide-22
SLIDE 22

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>
slide-23
SLIDE 23
slide-24
SLIDE 24
slide-25
SLIDE 25
slide-26
SLIDE 26

Search – stats*

slide-27
SLIDE 27
slide-28
SLIDE 28

References

  • Flame Graphs
  • go-torch