SlideShare a Scribd company logo
Profile all the things!
Using pprof in Go
John Potocny
Capital Go 2017
About Me
● @johnpotocny1
● Backend Developer @ VividCortex
● We’re hiring!
So, let’s talk about pprof
● Been around since before Go1 was released
● Initial support for CPU and heap profiling
● Full list of default profiles as of Go1.8:
○ CPU
○ Goroutine
○ Heap
○ ThreadCreate
○ Block
○ Mutex (New in Go1.8!)
● Godoc here: https://golang.org/pkg/runtime/pprof/
How do I use pprof?
● https://play.golang.org/p/FvEMZw0GhD
● Alternative: import “net/http/pprof”
○ Demo1
How do I use pprof? (cont.)
● Use ‘go tool pprof’ to fetch profiles from a program with a pprof server:
● Can also use write profiles when running ‘go test’
○ ex: go test -cpuprofile=cpu.out; go tool pprof presentation.test cpu.out
Add the binary for more visibility!
Types of Profiles: CPU
Types of Profiles: Heap
● 4 different modes to view
○ --inuse_space (default): shows live heap memory in bytes
○ --inuse_objects: shows # of live heap objects
○ --alloc_objects: shows # of allocated objects
○ --alloc_space: shows allocated bytes over time
Types of Profiles: Goroutine
● List goroutines aggregated by stack
● Use debug=2 to have all routines separated, with current state included.
Types of Profiles: ThreadCreate
● Shows which goroutines lead to creation of threads in an app
○ Broken? See https://github.com/golang/go/issues/6104
Types of Profiles: Block
● Shows time spent blocked on synchronization (mutexes, channels, etc.)
● Not enabled by default call runtime.SetBlockProfileRate() to enable
○ Argument is rate in ns to sample blocked routines
○ 1 = sample all events
○ 0 = disable
○ 100 = sample every 100ns
Types of Profiles: Block (cont.)
Demo2
Types of Profiles: Mutex
● Added in Go1.8
● Block showed us blocked routines; Mutex profile shows us blockers
○ Specifically, which routines spend time holding a mutex
● Disabled by default; call runtime.SetMutexProfileFraction() to enable
Type of Profiles: Mutex (cont.)
Demo3
Types of Profiles: Mutex (cont.)
● What if we use a RWMutex?
○ RLock/RUnlock are not tracked; RWMutex.Lock/Unlock are though
○ Milestone for Go1.9; https://github.com/golang/go/issues/18496
Types of Profiles: Custom!
● runtime/pprof exposes an API for creating our own profiles!
Custom Profiles (cont.)
Custom Profiles (cont.)
When to Use Custom Profiles
● Track a critical resource in your application
○ Open files
○ Active DB handles
○ Open Network sockets
○ In-use worker routines
● Make it easier to identify resource leaks in our apps
● We can also identify contention around bounded resources
A real-world case for custom Profiles
● I added support for tracking active-queries in a service at VividCortex!
○ Now it’s easier for us to track db-concurrency in our apps
What’s next for pprof?
- Support tracking file descriptors? https://github.com/golang/go/issues/16379
- Profile non-heap memory too? https://github.com/golang/go/issues/15848
- Count-oriented custom profiles? https://github.com/golang/go/issues/18454
- Allow aggregating events forever rather than showing current-state only
- Accepted proposal, Go1.9 milestone
- Support profiles with labels: https://github.com/golang/go/issues/17280
- Accepted proposal, Go1.9 milestone
Thank You!

More Related Content

What's hot

Jinja2 filters
Jinja2 filtersJinja2 filters
Jinja2 filters
jtyr
 
Git In One Evening
Git In One EveningGit In One Evening
Git In One Evening
Maxwell Pearl
 
Gulp presentation
Gulp presentationGulp presentation
Gulp presentation
mclise
 
Beginning python programming
Beginning python programmingBeginning python programming
Beginning python programming
kanteshraj
 
An invitation to PL/Ruby
An invitation to PL/RubyAn invitation to PL/Ruby
An invitation to PL/Ruby
Satoru Koizumi
 
The History of Free Software
The History of Free SoftwareThe History of Free Software
The History of Free Software
Sebastian Krzyszkowiak
 
TDD for joomla extensions
TDD for joomla extensionsTDD for joomla extensions
TDD for joomla extensions
Roberto Segura
 
ProjectTox: Free as in freedom Skype replacement
ProjectTox: Free as in freedom Skype replacementProjectTox: Free as in freedom Skype replacement
ProjectTox: Free as in freedom Skype replacement
Wei-Ning Huang
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in os
GenchiLu1
 
Symfony2 - A Short Introduction
Symfony2 - A Short IntroductionSymfony2 - A Short Introduction
Symfony2 - A Short Introduction
Andy Grunwald
 
Python debugging techniques
Python debugging techniquesPython debugging techniques
Python debugging techniques
Tuomas Suutari
 
Puppet managed loadays
Puppet managed loadaysPuppet managed loadays
Puppet managed loadays
Yankee Nemoy
 
Python Django Basics
Python Django BasicsPython Django Basics
Python Django Basics
RahilMemon5
 
kikstart journey of Golang with Hello world - Gopherlabs
kikstart journey of Golang with Hello world - Gopherlabs kikstart journey of Golang with Hello world - Gopherlabs
kikstart journey of Golang with Hello world - Gopherlabs
sangam biradar
 
Python_Session
Python_SessionPython_Session
Python_Sessionsiva ram
 
Write an Android library
Write an Android libraryWrite an Android library
Write an Android library
Romain Rochegude
 
Go in Production
Go in ProductionGo in Production
Go in Production
John-Alan Simmons
 
Source code analyzer
Source code analyzer Source code analyzer
Source code analyzer
OSLL
 

What's hot (20)

Jinja2 filters
Jinja2 filtersJinja2 filters
Jinja2 filters
 
Git In One Evening
Git In One EveningGit In One Evening
Git In One Evening
 
Gulp presentation
Gulp presentationGulp presentation
Gulp presentation
 
Beginning python programming
Beginning python programmingBeginning python programming
Beginning python programming
 
An invitation to PL/Ruby
An invitation to PL/RubyAn invitation to PL/Ruby
An invitation to PL/Ruby
 
The History of Free Software
The History of Free SoftwareThe History of Free Software
The History of Free Software
 
Virtual domains
Virtual domainsVirtual domains
Virtual domains
 
TDD for joomla extensions
TDD for joomla extensionsTDD for joomla extensions
TDD for joomla extensions
 
ProjectTox: Free as in freedom Skype replacement
ProjectTox: Free as in freedom Skype replacementProjectTox: Free as in freedom Skype replacement
ProjectTox: Free as in freedom Skype replacement
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in os
 
Symfony2 - A Short Introduction
Symfony2 - A Short IntroductionSymfony2 - A Short Introduction
Symfony2 - A Short Introduction
 
Python debugging techniques
Python debugging techniquesPython debugging techniques
Python debugging techniques
 
Puppet managed loadays
Puppet managed loadaysPuppet managed loadays
Puppet managed loadays
 
Python Django Basics
Python Django BasicsPython Django Basics
Python Django Basics
 
kikstart journey of Golang with Hello world - Gopherlabs
kikstart journey of Golang with Hello world - Gopherlabs kikstart journey of Golang with Hello world - Gopherlabs
kikstart journey of Golang with Hello world - Gopherlabs
 
Python_Session
Python_SessionPython_Session
Python_Session
 
Write an Android library
Write an Android libraryWrite an Android library
Write an Android library
 
Ruxmon.2013-08.-.CodeBro!
Ruxmon.2013-08.-.CodeBro!Ruxmon.2013-08.-.CodeBro!
Ruxmon.2013-08.-.CodeBro!
 
Go in Production
Go in ProductionGo in Production
Go in Production
 
Source code analyzer
Source code analyzer Source code analyzer
Source code analyzer
 

Similar to Profile all the things! - Capital Go 2017

The New York Times: Sustainable Systems, Powered by Python
The New York Times: Sustainable Systems, Powered by PythonThe New York Times: Sustainable Systems, Powered by Python
The New York Times: Sustainable Systems, Powered by Python
All Things Open
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears Training
Alessandro Molina
 
Testing Django APIs
Testing Django APIsTesting Django APIs
Testing Django APIs
tyomo4ka
 
Introducing Yeoman 1.0 beta
Introducing Yeoman 1.0 betaIntroducing Yeoman 1.0 beta
Introducing Yeoman 1.0 betadigitalzombie
 
Go profiling introduction
Go profiling introductionGo profiling introduction
Go profiling introduction
William Lin
 
Programming with Python - Basic
Programming with Python - BasicProgramming with Python - Basic
Programming with Python - Basic
Mosky Liu
 
Development and deployment with composer and kite
Development and deployment with composer and kiteDevelopment and deployment with composer and kite
Development and deployment with composer and kite
Christian Opitz
 
Pentester++
Pentester++Pentester++
Pentester++
CTruncer
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logs
Jeremy Cook
 
Buildout: creating and deploying repeatable applications in python
Buildout: creating and deploying repeatable applications in pythonBuildout: creating and deploying repeatable applications in python
Buildout: creating and deploying repeatable applications in python
CodeSyntax
 
Go at Skroutz
Go at SkroutzGo at Skroutz
Go at Skroutz
AgisAnastasopoulos
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logs
Jeremy Cook
 
What Goes In Must Come Out: Egress-Assess and Data Exfiltration
What Goes In Must Come Out: Egress-Assess and Data ExfiltrationWhat Goes In Must Come Out: Egress-Assess and Data Exfiltration
What Goes In Must Come Out: Egress-Assess and Data Exfiltration
CTruncer
 
Hands-on go profiling
Hands-on go profilingHands-on go profiling
Hands-on go profiling
Daniel Ammar
 
10 ways to improve your Android app performance
10 ways to improve your Android app performance10 ways to improve your Android app performance
10 ways to improve your Android app performance
Boris Farber
 
Introduction to containers
Introduction to containersIntroduction to containers
Introduction to containers
Nitish Jadia
 
OSDC 2017 | Mgmt Config: Autonomous systems by James Shubin
OSDC 2017 | Mgmt Config: Autonomous systems by James ShubinOSDC 2017 | Mgmt Config: Autonomous systems by James Shubin
OSDC 2017 | Mgmt Config: Autonomous systems by James Shubin
NETWAYS
 
OSDC 2017 - James Shubin - MGMT config autonomous systems
OSDC 2017 - James Shubin - MGMT config autonomous systemsOSDC 2017 - James Shubin - MGMT config autonomous systems
OSDC 2017 - James Shubin - MGMT config autonomous systems
NETWAYS
 
PyConUK 2014 - PostMortem Debugging and Web Development Updated
PyConUK 2014 - PostMortem Debugging and Web Development UpdatedPyConUK 2014 - PostMortem Debugging and Web Development Updated
PyConUK 2014 - PostMortem Debugging and Web Development Updated
Alessandro Molina
 
ownCloud - Webmontag Wasserburg
ownCloud - Webmontag WasserburgownCloud - Webmontag Wasserburg
ownCloud - Webmontag Wasserburg
gomez_r
 

Similar to Profile all the things! - Capital Go 2017 (20)

The New York Times: Sustainable Systems, Powered by Python
The New York Times: Sustainable Systems, Powered by PythonThe New York Times: Sustainable Systems, Powered by Python
The New York Times: Sustainable Systems, Powered by Python
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears Training
 
Testing Django APIs
Testing Django APIsTesting Django APIs
Testing Django APIs
 
Introducing Yeoman 1.0 beta
Introducing Yeoman 1.0 betaIntroducing Yeoman 1.0 beta
Introducing Yeoman 1.0 beta
 
Go profiling introduction
Go profiling introductionGo profiling introduction
Go profiling introduction
 
Programming with Python - Basic
Programming with Python - BasicProgramming with Python - Basic
Programming with Python - Basic
 
Development and deployment with composer and kite
Development and deployment with composer and kiteDevelopment and deployment with composer and kite
Development and deployment with composer and kite
 
Pentester++
Pentester++Pentester++
Pentester++
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logs
 
Buildout: creating and deploying repeatable applications in python
Buildout: creating and deploying repeatable applications in pythonBuildout: creating and deploying repeatable applications in python
Buildout: creating and deploying repeatable applications in python
 
Go at Skroutz
Go at SkroutzGo at Skroutz
Go at Skroutz
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logs
 
What Goes In Must Come Out: Egress-Assess and Data Exfiltration
What Goes In Must Come Out: Egress-Assess and Data ExfiltrationWhat Goes In Must Come Out: Egress-Assess and Data Exfiltration
What Goes In Must Come Out: Egress-Assess and Data Exfiltration
 
Hands-on go profiling
Hands-on go profilingHands-on go profiling
Hands-on go profiling
 
10 ways to improve your Android app performance
10 ways to improve your Android app performance10 ways to improve your Android app performance
10 ways to improve your Android app performance
 
Introduction to containers
Introduction to containersIntroduction to containers
Introduction to containers
 
OSDC 2017 | Mgmt Config: Autonomous systems by James Shubin
OSDC 2017 | Mgmt Config: Autonomous systems by James ShubinOSDC 2017 | Mgmt Config: Autonomous systems by James Shubin
OSDC 2017 | Mgmt Config: Autonomous systems by James Shubin
 
OSDC 2017 - James Shubin - MGMT config autonomous systems
OSDC 2017 - James Shubin - MGMT config autonomous systemsOSDC 2017 - James Shubin - MGMT config autonomous systems
OSDC 2017 - James Shubin - MGMT config autonomous systems
 
PyConUK 2014 - PostMortem Debugging and Web Development Updated
PyConUK 2014 - PostMortem Debugging and Web Development UpdatedPyConUK 2014 - PostMortem Debugging and Web Development Updated
PyConUK 2014 - PostMortem Debugging and Web Development Updated
 
ownCloud - Webmontag Wasserburg
ownCloud - Webmontag WasserburgownCloud - Webmontag Wasserburg
ownCloud - Webmontag Wasserburg
 

Recently uploaded

Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
vrstrong314
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
abdulrafaychaudhry
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 

Recently uploaded (20)

Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 

Profile all the things! - Capital Go 2017

  • 1. Profile all the things! Using pprof in Go John Potocny Capital Go 2017
  • 2. About Me ● @johnpotocny1 ● Backend Developer @ VividCortex ● We’re hiring!
  • 3. So, let’s talk about pprof ● Been around since before Go1 was released ● Initial support for CPU and heap profiling ● Full list of default profiles as of Go1.8: ○ CPU ○ Goroutine ○ Heap ○ ThreadCreate ○ Block ○ Mutex (New in Go1.8!) ● Godoc here: https://golang.org/pkg/runtime/pprof/
  • 4. How do I use pprof? ● https://play.golang.org/p/FvEMZw0GhD ● Alternative: import “net/http/pprof” ○ Demo1
  • 5. How do I use pprof? (cont.) ● Use ‘go tool pprof’ to fetch profiles from a program with a pprof server: ● Can also use write profiles when running ‘go test’ ○ ex: go test -cpuprofile=cpu.out; go tool pprof presentation.test cpu.out
  • 6. Add the binary for more visibility!
  • 8. Types of Profiles: Heap ● 4 different modes to view ○ --inuse_space (default): shows live heap memory in bytes ○ --inuse_objects: shows # of live heap objects ○ --alloc_objects: shows # of allocated objects ○ --alloc_space: shows allocated bytes over time
  • 9. Types of Profiles: Goroutine ● List goroutines aggregated by stack ● Use debug=2 to have all routines separated, with current state included.
  • 10. Types of Profiles: ThreadCreate ● Shows which goroutines lead to creation of threads in an app ○ Broken? See https://github.com/golang/go/issues/6104
  • 11. Types of Profiles: Block ● Shows time spent blocked on synchronization (mutexes, channels, etc.) ● Not enabled by default call runtime.SetBlockProfileRate() to enable ○ Argument is rate in ns to sample blocked routines ○ 1 = sample all events ○ 0 = disable ○ 100 = sample every 100ns
  • 12. Types of Profiles: Block (cont.) Demo2
  • 13. Types of Profiles: Mutex ● Added in Go1.8 ● Block showed us blocked routines; Mutex profile shows us blockers ○ Specifically, which routines spend time holding a mutex ● Disabled by default; call runtime.SetMutexProfileFraction() to enable
  • 14. Type of Profiles: Mutex (cont.) Demo3
  • 15. Types of Profiles: Mutex (cont.) ● What if we use a RWMutex? ○ RLock/RUnlock are not tracked; RWMutex.Lock/Unlock are though ○ Milestone for Go1.9; https://github.com/golang/go/issues/18496
  • 16. Types of Profiles: Custom! ● runtime/pprof exposes an API for creating our own profiles!
  • 19. When to Use Custom Profiles ● Track a critical resource in your application ○ Open files ○ Active DB handles ○ Open Network sockets ○ In-use worker routines ● Make it easier to identify resource leaks in our apps ● We can also identify contention around bounded resources
  • 20. A real-world case for custom Profiles ● I added support for tracking active-queries in a service at VividCortex! ○ Now it’s easier for us to track db-concurrency in our apps
  • 21. What’s next for pprof? - Support tracking file descriptors? https://github.com/golang/go/issues/16379 - Profile non-heap memory too? https://github.com/golang/go/issues/15848 - Count-oriented custom profiles? https://github.com/golang/go/issues/18454 - Allow aggregating events forever rather than showing current-state only - Accepted proposal, Go1.9 milestone - Support profiles with labels: https://github.com/golang/go/issues/17280 - Accepted proposal, Go1.9 milestone