SlideShare a Scribd company logo
1 of 22
Download to read offline
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 filtersjtyr
 
Gulp presentation
Gulp presentationGulp presentation
Gulp presentationmclise
 
Beginning python programming
Beginning python programmingBeginning python programming
Beginning python programmingkanteshraj
 
An invitation to PL/Ruby
An invitation to PL/RubyAn invitation to PL/Ruby
An invitation to PL/RubySatoru Koizumi
 
TDD for joomla extensions
TDD for joomla extensionsTDD for joomla extensions
TDD for joomla extensionsRoberto 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 replacementWei-Ning Huang
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in osGenchiLu1
 
Symfony2 - A Short Introduction
Symfony2 - A Short IntroductionSymfony2 - A Short Introduction
Symfony2 - A Short IntroductionAndy Grunwald
 
Python debugging techniques
Python debugging techniquesPython debugging techniques
Python debugging techniquesTuomas Suutari
 
Puppet managed loadays
Puppet managed loadaysPuppet managed loadays
Puppet managed loadaysYankee Nemoy
 
Python Django Basics
Python Django BasicsPython Django Basics
Python Django BasicsRahilMemon5
 
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
 
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 PythonAll Things Open
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingAlessandro Molina
 
Testing Django APIs
Testing Django APIsTesting Django APIs
Testing Django APIstyomo4ka
 
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 introductionWilliam Lin
 
Programming with Python - Basic
Programming with Python - BasicProgramming with Python - Basic
Programming with Python - BasicMosky 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 kiteChristian Opitz
 
Pentester++
Pentester++Pentester++
Pentester++CTruncer
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logsJeremy 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 pythonCodeSyntax
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logsJeremy 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 ExfiltrationCTruncer
 
Hands-on go profiling
Hands-on go profilingHands-on go profiling
Hands-on go profilingDaniel 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 performanceBoris Farber
 
Introduction to containers
Introduction to containersIntroduction to containers
Introduction to containersNitish 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 ShubinNETWAYS
 
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 systemsNETWAYS
 
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 UpdatedAlessandro Molina
 
ownCloud - Webmontag Wasserburg
ownCloud - Webmontag WasserburgownCloud - Webmontag Wasserburg
ownCloud - Webmontag Wasserburggomez_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

Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 

Recently uploaded (20)

Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 

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