Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Go execution tracer
Gophercon Brazil 2017
André Carvalho
$ whoami
• Developer @ globo.com /
tsuru
• Interested in all things
performance, tracing and
systems programming
• @andres...
Agenda
• The tool basics
• What is the Go execution tracer
• How to collect trace data
• How to analyze trace data
• Using...
Go execution tracer
• Gives insight into the execution of a Go program
• What are my goroutines doing when not in CPU?
• I...
Go execution tracer
• Events
• Goroutines creation/start/end/block/unblock
• Network
• Syscalls
• Memory allocation
• Garb...
Collecting traces
• Three ways to collect traces
• trace.Start / trace.Stop
• go test -trace=trace.out
• debug/pprof/trace...
Collecting traces
• Writes the tracing output to
os.Stderr
• go run main.go 2> trace.out
• go tool trace trace.out
Trace
View Trace
1. Timeline
2. Heap usage
3. goroutines
1
2
3
4
5
4. OS threads
5. Virtual Processors
6. goroutine + events
6
View Trace
Selecting a goroutine
View Trace
Selecting an event
Tracing web applications
https://github.com/andrestc/go-tracing/tree/master/07-web
Using the tracer to
improve working code
Mandelbrot
CPU intensive calculations to
figure out each pixel’s color
https://github.com/campoy/
mandelbrot/
Pixel
Sequential
Sequential
One goroutine per pixel
One goroutine per pixel
One goroutine per pixel
One goroutine per column
Debugging a strange
test behavior
Planb
• github.com/tsuru/planb
• reverse proxy based of hipache
• One of tsuru’s key components
• Used extensively on glob...
Planb
Planb
Host: app.cloud.com
Backend
Backend
Backend
Let’s trace it!
https://github.com/golang/go/issues/21204
Workaround
https://github.com/tsuru/planb/pull/35
Conclusions
• Go execution tracer helps understand concurrency
• Complements other tools (eg memory/cpu
profile)
• Not much...
Reference
• Using the go tracer to speed up fractal rendering
• Just for func #22
• Go Execution Tracer (Design Doc)
Slides and notes in english
will be available at
https://andrestc.com
Obrigado!
Go Execution Tracer
Go Execution Tracer
Go Execution Tracer
Go Execution Tracer
Go Execution Tracer
Go Execution Tracer
You’ve finished this document.
Download and read it offline.
Upcoming SlideShare
Instrumenting Go applications with Prometheus
Next
Upcoming SlideShare
Instrumenting Go applications with Prometheus
Next
Download to read offline and view in fullscreen.

Share

Go Execution Tracer

Download to read offline

Slides for my talk at Gophercon Brazil 2017 on the Go execution tracer.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Go Execution Tracer

  1. 1. Go execution tracer Gophercon Brazil 2017 André Carvalho
  2. 2. $ whoami • Developer @ globo.com / tsuru • Interested in all things performance, tracing and systems programming • @andresantostc • https://andrestc.com
  3. 3. Agenda • The tool basics • What is the Go execution tracer • How to collect trace data • How to analyze trace data • Using the tracer • to improve working code • to investigate a strange behavior
  4. 4. Go execution tracer • Gives insight into the execution of a Go program • What are my goroutines doing when not in CPU? • Instruments the go runtime • Captures events in nanosecond precision • Data is not aggregated/sampled! • Available since go 1.5
  5. 5. Go execution tracer • Events • Goroutines creation/start/end/block/unblock • Network • Syscalls • Memory allocation • Garbage collection
  6. 6. Collecting traces • Three ways to collect traces • trace.Start / trace.Stop • go test -trace=trace.out • debug/pprof/trace handler
  7. 7. Collecting traces • Writes the tracing output to os.Stderr • go run main.go 2> trace.out • go tool trace trace.out
  8. 8. Trace
  9. 9. View Trace 1. Timeline 2. Heap usage 3. goroutines 1 2 3 4 5 4. OS threads 5. Virtual Processors 6. goroutine + events 6
  10. 10. View Trace Selecting a goroutine
  11. 11. View Trace Selecting an event
  12. 12. Tracing web applications https://github.com/andrestc/go-tracing/tree/master/07-web
  13. 13. Using the tracer to improve working code
  14. 14. Mandelbrot CPU intensive calculations to figure out each pixel’s color https://github.com/campoy/ mandelbrot/
  15. 15. Pixel
  16. 16. Sequential
  17. 17. Sequential
  18. 18. One goroutine per pixel
  19. 19. One goroutine per pixel
  20. 20. One goroutine per pixel
  21. 21. One goroutine per column
  22. 22. Debugging a strange test behavior
  23. 23. Planb • github.com/tsuru/planb • reverse proxy based of hipache • One of tsuru’s key components • Used extensively on globo.com
  24. 24. Planb Planb Host: app.cloud.com Backend Backend Backend
  25. 25. Let’s trace it!
  26. 26. https://github.com/golang/go/issues/21204
  27. 27. Workaround https://github.com/tsuru/planb/pull/35
  28. 28. Conclusions • Go execution tracer helps understand concurrency • Complements other tools (eg memory/cpu profile) • Not much documentation available • Opportunity for contributions
  29. 29. Reference • Using the go tracer to speed up fractal rendering • Just for func #22 • Go Execution Tracer (Design Doc)
  30. 30. Slides and notes in english will be available at https://andrestc.com Obrigado!
  • hussan1

    Nov. 21, 2017

Slides for my talk at Gophercon Brazil 2017 on the Go execution tracer.

Views

Total views

1,034

On Slideshare

0

From embeds

0

Number of embeds

120

Actions

Downloads

3

Shares

0

Comments

0

Likes

1

×