Go Execution Tracer

André Carvalho
André CarvalhoSoftware Engineer at Globo.com
Go execution tracer
Gophercon Brazil 2017
André Carvalho
$ whoami
• Developer @ globo.com /
tsuru
• Interested in all things
performance, tracing and
systems programming
• @andresantostc
• https://andrestc.com
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
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
Go execution tracer
• Events
• Goroutines creation/start/end/block/unblock
• Network
• Syscalls
• Memory allocation
• Garbage collection
Collecting traces
• Three ways to collect traces
• trace.Start / trace.Stop
• go test -trace=trace.out
• debug/pprof/trace handler
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
Go Execution Tracer
Debugging a strange
test behavior
Planb
• github.com/tsuru/planb
• reverse proxy based of hipache
• One of tsuru’s key components
• Used extensively on globo.com
Planb
Planb
Host: app.cloud.com
Backend
Backend
Backend
Go Execution Tracer
Go Execution Tracer
Let’s trace it!
Go Execution Tracer
Go Execution Tracer
Go Execution Tracer
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 documentation available
• Opportunity for contributions
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!
1 of 36

Recommended

Instrumenting Go applications with Prometheus by
Instrumenting Go applications with PrometheusInstrumenting Go applications with Prometheus
Instrumenting Go applications with PrometheusAndré Carvalho
1.4K views27 slides
DevRomagna / Golang Intro by
DevRomagna / Golang IntroDevRomagna / Golang Intro
DevRomagna / Golang IntroSimone Gentili
575 views25 slides
Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017) by
Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)
Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)Patricia Aas
750 views26 slides
Advanced memory allocation by
Advanced memory allocationAdvanced memory allocation
Advanced memory allocationJoris Bonnefoy
820 views39 slides
Docker Networking by
Docker NetworkingDocker Networking
Docker NetworkingKingston Smiler
3.4K views13 slides
OCCIware, an extensible, standard-based XaaS consumer platform to manage ever... by
OCCIware, an extensible, standard-based XaaS consumer platform to manage ever...OCCIware, an extensible, standard-based XaaS consumer platform to manage ever...
OCCIware, an extensible, standard-based XaaS consumer platform to manage ever...OCCIware
586 views32 slides

More Related Content

Viewers also liked

numPYNQ @ NGCLE@e-Novia 15.11.2017 by
numPYNQ @ NGCLE@e-Novia 15.11.2017numPYNQ @ NGCLE@e-Novia 15.11.2017
numPYNQ @ NGCLE@e-Novia 15.11.2017NECST Lab @ Politecnico di Milano
206 views15 slides
What in the World is Going on at The Linux Foundation? by
What in the World is Going on at The Linux Foundation?What in the World is Going on at The Linux Foundation?
What in the World is Going on at The Linux Foundation?Black Duck by Synopsys
695 views45 slides
Walk through an enterprise Linux migration by
Walk through an enterprise Linux migrationWalk through an enterprise Linux migration
Walk through an enterprise Linux migrationRogue Wave Software
670 views30 slides
Graduating To Go - A Jumpstart into the Go Programming Language by
Graduating To Go - A Jumpstart into the Go Programming LanguageGraduating To Go - A Jumpstart into the Go Programming Language
Graduating To Go - A Jumpstart into the Go Programming LanguageKaylyn Gibilterra
293 views57 slides
[若渴計畫] Challenges and Solutions of Window Remote Shellcode by
[若渴計畫] Challenges and Solutions of Window Remote Shellcode[若渴計畫] Challenges and Solutions of Window Remote Shellcode
[若渴計畫] Challenges and Solutions of Window Remote ShellcodeAj MaChInE
983 views39 slides
Communication hardware by
Communication hardwareCommunication hardware
Communication hardwareHans Mallen
13.9K views31 slides

Viewers also liked(20)

Graduating To Go - A Jumpstart into the Go Programming Language by Kaylyn Gibilterra
Graduating To Go - A Jumpstart into the Go Programming LanguageGraduating To Go - A Jumpstart into the Go Programming Language
Graduating To Go - A Jumpstart into the Go Programming Language
Kaylyn Gibilterra293 views
[若渴計畫] Challenges and Solutions of Window Remote Shellcode by Aj MaChInE
[若渴計畫] Challenges and Solutions of Window Remote Shellcode[若渴計畫] Challenges and Solutions of Window Remote Shellcode
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
Aj MaChInE983 views
Communication hardware by Hans Mallen
Communication hardwareCommunication hardware
Communication hardware
Hans Mallen13.9K views
In-depth forensic analysis of Windows registry files by Maxim Suhanov
In-depth forensic analysis of Windows registry filesIn-depth forensic analysis of Windows registry files
In-depth forensic analysis of Windows registry files
Maxim Suhanov10K views
Deep dive into Coroutines on JVM @ KotlinConf 2017 by Roman Elizarov
Deep dive into Coroutines on JVM @ KotlinConf 2017Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017
Roman Elizarov5.8K views
Introduction to OpenFlow, SDN and NFV by Kingston Smiler
Introduction to OpenFlow, SDN and NFVIntroduction to OpenFlow, SDN and NFV
Introduction to OpenFlow, SDN and NFV
Kingston Smiler35.5K views
Scaling and Transaction Futures by MongoDB
Scaling and Transaction FuturesScaling and Transaction Futures
Scaling and Transaction Futures
MongoDB1.6K views
2018 State of the Union Address: Rediscovering the American way: USA XXI: Fut... by Azamat Abdoullaev
2018 State of the Union Address: Rediscovering the American way: USA XXI: Fut...2018 State of the Union Address: Rediscovering the American way: USA XXI: Fut...
2018 State of the Union Address: Rediscovering the American way: USA XXI: Fut...
Azamat Abdoullaev11K views
Blockchain demystification by Bellaj Badr
Blockchain demystificationBlockchain demystification
Blockchain demystification
Bellaj Badr2.8K views
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ... by Chris Fregly
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
Chris Fregly3K views
Jörg Schad - NO ONE PUTS Java IN THE CONTAINER - Codemotion Milan 2017 by Codemotion
Jörg Schad - NO ONE PUTS Java IN THE CONTAINER - Codemotion Milan 2017Jörg Schad - NO ONE PUTS Java IN THE CONTAINER - Codemotion Milan 2017
Jörg Schad - NO ONE PUTS Java IN THE CONTAINER - Codemotion Milan 2017
Codemotion692 views
Andrea Tosatto - Kubernetes Beyond - Codemotion Milan 2017 by Codemotion
Andrea Tosatto - Kubernetes Beyond - Codemotion Milan 2017Andrea Tosatto - Kubernetes Beyond - Codemotion Milan 2017
Andrea Tosatto - Kubernetes Beyond - Codemotion Milan 2017
Codemotion350 views

Similar to Go Execution Tracer

Tracer by
TracerTracer
TracerSiddharth Singhal
41 views13 slides
A Taste of Monitoring and Post Mortem Debugging with Node by
A Taste of Monitoring and Post Mortem Debugging with Node A Taste of Monitoring and Post Mortem Debugging with Node
A Taste of Monitoring and Post Mortem Debugging with Node ibmwebspheresoftware
2.2K views51 slides
Reproducibility and automation of machine learning process by
Reproducibility and automation of machine learning processReproducibility and automation of machine learning process
Reproducibility and automation of machine learning processDenis Dus
2.3K views39 slides
Что нам стоіт таск манагер построіт. Ігор Лущик. LvivPy #6 by
Что нам стоіт таск манагер построіт. Ігор Лущик. LvivPy #6Что нам стоіт таск манагер построіт. Ігор Лущик. LvivPy #6
Что нам стоіт таск манагер построіт. Ігор Лущик. LvivPy #6Serhii Ruskykh
31 views37 slides
Silicon Valley Code Camp 2016 - MongoDB in production by
Silicon Valley Code Camp 2016 - MongoDB in productionSilicon Valley Code Camp 2016 - MongoDB in production
Silicon Valley Code Camp 2016 - MongoDB in productionDaniel Coupal
544 views47 slides
Monitoring your API by
Monitoring your APIMonitoring your API
Monitoring your APIAndrés F Vargas
928 views32 slides

Similar to Go Execution Tracer(20)

A Taste of Monitoring and Post Mortem Debugging with Node by ibmwebspheresoftware
A Taste of Monitoring and Post Mortem Debugging with Node A Taste of Monitoring and Post Mortem Debugging with Node
A Taste of Monitoring and Post Mortem Debugging with Node
Reproducibility and automation of machine learning process by Denis Dus
Reproducibility and automation of machine learning processReproducibility and automation of machine learning process
Reproducibility and automation of machine learning process
Denis Dus2.3K views
Что нам стоіт таск манагер построіт. Ігор Лущик. LvivPy #6 by Serhii Ruskykh
Что нам стоіт таск манагер построіт. Ігор Лущик. LvivPy #6Что нам стоіт таск манагер построіт. Ігор Лущик. LvivPy #6
Что нам стоіт таск манагер построіт. Ігор Лущик. LvivPy #6
Serhii Ruskykh31 views
Silicon Valley Code Camp 2016 - MongoDB in production by Daniel Coupal
Silicon Valley Code Camp 2016 - MongoDB in productionSilicon Valley Code Camp 2016 - MongoDB in production
Silicon Valley Code Camp 2016 - MongoDB in production
Daniel Coupal544 views
PyCon AU 2012 - Debugging Live Python Web Applications by Graham Dumpleton
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
Graham Dumpleton11.4K views
Campus days 2013 - Instrumentation by Anders Lybecker
Campus days 2013 - InstrumentationCampus days 2013 - Instrumentation
Campus days 2013 - Instrumentation
Anders Lybecker752 views
Forensics WS Consolidated by Karter Rohrer
Forensics WS ConsolidatedForensics WS Consolidated
Forensics WS Consolidated
Karter Rohrer244 views
MW_Arch Fastest_way_to_hunt_on_Windows_v1.01 by Michael Gough
MW_Arch Fastest_way_to_hunt_on_Windows_v1.01MW_Arch Fastest_way_to_hunt_on_Windows_v1.01
MW_Arch Fastest_way_to_hunt_on_Windows_v1.01
Michael Gough1.1K views
Introducing ArTHIR - ATT&CK Remote Threat Hunting Incident Response Windows tool by Michael Gough
Introducing ArTHIR - ATT&CK Remote Threat Hunting Incident Response Windows toolIntroducing ArTHIR - ATT&CK Remote Threat Hunting Incident Response Windows tool
Introducing ArTHIR - ATT&CK Remote Threat Hunting Incident Response Windows tool
Michael Gough2.4K views
Cloud Foundry Monitoring How-To: Collecting Metrics and Logs by Altoros
Cloud Foundry Monitoring How-To: Collecting Metrics and LogsCloud Foundry Monitoring How-To: Collecting Metrics and Logs
Cloud Foundry Monitoring How-To: Collecting Metrics and Logs
Altoros6.3K views
Operating System Forensics by ArunJS5
Operating System ForensicsOperating System Forensics
Operating System Forensics
ArunJS5540 views
2_Big Data Sources part3-Day 1-B Tools.pptx by ssuser87a462
2_Big Data Sources part3-Day 1-B Tools.pptx2_Big Data Sources part3-Day 1-B Tools.pptx
2_Big Data Sources part3-Day 1-B Tools.pptx
ssuser87a4624 views
When Security Tools Fail You by Michael Gough
When Security Tools Fail YouWhen Security Tools Fail You
When Security Tools Fail You
Michael Gough83 views
Pekka_Aho_Complementing GUI Testing Scripts - Testing Assembly 2022.pdf by FiSTB
Pekka_Aho_Complementing GUI Testing Scripts -  Testing Assembly 2022.pdfPekka_Aho_Complementing GUI Testing Scripts -  Testing Assembly 2022.pdf
Pekka_Aho_Complementing GUI Testing Scripts - Testing Assembly 2022.pdf
FiSTB91 views
Hands-on go profiling by Daniel Ammar
Hands-on go profilingHands-on go profiling
Hands-on go profiling
Daniel Ammar105 views
DEEPSEC 2013: Malware Datamining And Attribution by Michael Boman
DEEPSEC 2013: Malware Datamining And AttributionDEEPSEC 2013: Malware Datamining And Attribution
DEEPSEC 2013: Malware Datamining And Attribution
Michael Boman6K views

More from André Carvalho

Containers na Globo.com - Passado, Presente e Futuro by
Containers na Globo.com - Passado, Presente e FuturoContainers na Globo.com - Passado, Presente e Futuro
Containers na Globo.com - Passado, Presente e FuturoAndré Carvalho
819 views93 slides
Tsuru - Deploys Fáceis e Seguros by
Tsuru - Deploys Fáceis e SegurosTsuru - Deploys Fáceis e Seguros
Tsuru - Deploys Fáceis e SegurosAndré Carvalho
447 views28 slides
Classificação de séries temporais via divergente entre densidades de probabil... by
Classificação de séries temporais via divergente entre densidades de probabil...Classificação de séries temporais via divergente entre densidades de probabil...
Classificação de séries temporais via divergente entre densidades de probabil...André Carvalho
236 views67 slides
Instrumentando aplicações Go com Prometheus by
Instrumentando aplicações Go com PrometheusInstrumentando aplicações Go com Prometheus
Instrumentando aplicações Go com PrometheusAndré Carvalho
294 views13 slides
Um estudo sobre a aplicação de algoritmos genéticos no investimento em ações ... by
Um estudo sobre a aplicação de algoritmos genéticos no investimento em ações ...Um estudo sobre a aplicação de algoritmos genéticos no investimento em ações ...
Um estudo sobre a aplicação de algoritmos genéticos no investimento em ações ...André Carvalho
1.1K views39 slides
Uma comparação do desempenho de SGBDS de grafos com armazenamento nativo e SG... by
Uma comparação do desempenho de SGBDS de grafos com armazenamento nativo e SG...Uma comparação do desempenho de SGBDS de grafos com armazenamento nativo e SG...
Uma comparação do desempenho de SGBDS de grafos com armazenamento nativo e SG...André Carvalho
473 views26 slides

More from André Carvalho(7)

Containers na Globo.com - Passado, Presente e Futuro by André Carvalho
Containers na Globo.com - Passado, Presente e FuturoContainers na Globo.com - Passado, Presente e Futuro
Containers na Globo.com - Passado, Presente e Futuro
André Carvalho819 views
Tsuru - Deploys Fáceis e Seguros by André Carvalho
Tsuru - Deploys Fáceis e SegurosTsuru - Deploys Fáceis e Seguros
Tsuru - Deploys Fáceis e Seguros
André Carvalho447 views
Classificação de séries temporais via divergente entre densidades de probabil... by André Carvalho
Classificação de séries temporais via divergente entre densidades de probabil...Classificação de séries temporais via divergente entre densidades de probabil...
Classificação de séries temporais via divergente entre densidades de probabil...
André Carvalho236 views
Instrumentando aplicações Go com Prometheus by André Carvalho
Instrumentando aplicações Go com PrometheusInstrumentando aplicações Go com Prometheus
Instrumentando aplicações Go com Prometheus
André Carvalho294 views
Um estudo sobre a aplicação de algoritmos genéticos no investimento em ações ... by André Carvalho
Um estudo sobre a aplicação de algoritmos genéticos no investimento em ações ...Um estudo sobre a aplicação de algoritmos genéticos no investimento em ações ...
Um estudo sobre a aplicação de algoritmos genéticos no investimento em ações ...
André Carvalho1.1K views
Uma comparação do desempenho de SGBDS de grafos com armazenamento nativo e SG... by André Carvalho
Uma comparação do desempenho de SGBDS de grafos com armazenamento nativo e SG...Uma comparação do desempenho de SGBDS de grafos com armazenamento nativo e SG...
Uma comparação do desempenho de SGBDS de grafos com armazenamento nativo e SG...
André Carvalho473 views
Clusterização de padrões de candlesticks utilizando Mapas de Kohonen by André Carvalho
Clusterização de padrões de candlesticks utilizando Mapas de KohonenClusterização de padrões de candlesticks utilizando Mapas de Kohonen
Clusterização de padrões de candlesticks utilizando Mapas de Kohonen
André Carvalho645 views

Recently uploaded

Flask-Python.pptx by
Flask-Python.pptxFlask-Python.pptx
Flask-Python.pptxTriloki Gupta
9 views12 slides
Quality Engineer: A Day in the Life by
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the LifeJohn Valentino
7 views18 slides
nintendo_64.pptx by
nintendo_64.pptxnintendo_64.pptx
nintendo_64.pptxpaiga02016
6 views7 slides
Navigating container technology for enhanced security by Niklas Saari by
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas SaariMetosin Oy
14 views34 slides
FOSSLight Community Day 2023-11-30 by
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30Shane Coughlan
6 views18 slides
FIMA 2023 Neo4j & FS - Entity Resolution.pptx by
FIMA 2023 Neo4j & FS - Entity Resolution.pptxFIMA 2023 Neo4j & FS - Entity Resolution.pptx
FIMA 2023 Neo4j & FS - Entity Resolution.pptxNeo4j
17 views26 slides

Recently uploaded(20)

Quality Engineer: A Day in the Life by John Valentino
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the Life
John Valentino7 views
Navigating container technology for enhanced security by Niklas Saari by Metosin Oy
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas Saari
Metosin Oy14 views
FOSSLight Community Day 2023-11-30 by Shane Coughlan
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30
Shane Coughlan6 views
FIMA 2023 Neo4j & FS - Entity Resolution.pptx by Neo4j
FIMA 2023 Neo4j & FS - Entity Resolution.pptxFIMA 2023 Neo4j & FS - Entity Resolution.pptx
FIMA 2023 Neo4j & FS - Entity Resolution.pptx
Neo4j17 views
predicting-m3-devopsconMunich-2023.pptx by Tier1 app
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptx
Tier1 app8 views
Generic or specific? Making sensible software design decisions by Bert Jan Schrijver
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
Fleet Management Software in India by Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable12 views
Electronic AWB - Electronic Air Waybill by Freightoscope
Electronic AWB - Electronic Air Waybill Electronic AWB - Electronic Air Waybill
Electronic AWB - Electronic Air Waybill
Freightoscope 5 views
Top-5-production-devconMunich-2023-v2.pptx by Tier1 app
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptx
Tier1 app6 views
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx by animuscrm
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
animuscrm15 views
360 graden fabriek by info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info33492162 views
tecnologia18.docx by nosi6702
tecnologia18.docxtecnologia18.docx
tecnologia18.docx
nosi67025 views
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated... by TomHalpin9
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
TomHalpin96 views
Airline Booking Software by SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta9 views
Introduction to Git Source Control by John Valentino
Introduction to Git Source ControlIntroduction to Git Source Control
Introduction to Git Source Control
John Valentino7 views

Go Execution Tracer