SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
Where is the bottleneck
Manuel Miranda
Software Engineer
Contents
• Strategy: What/How to start
• Basic OS tools
• Resources tools
• Advanced
Strategy: Considerations
When you want to improve your program performance, ask yourself the following:
• Focus: What do you exactly want to accomplish?
• Cost: Does the time you will spend improving performance worth it?
• Code knowledge: Do you control all the code?
• Context awareness: Can external resources affect you?
• Local context: Are your tests reproducing exactly the production execution?
It’s really important to think about this points before starting. They
can save you lots of time!
Strategy: Start
OS tools
• time
• htop
• ntop
• lsof
• vmstat
Resources:memory_profiler
MEMORY_PROFILER
https://github.com/fabianp/memory_profiler
376 Commits
Last commit: 29th Jun
792 Stars
Resources:memory_profiler
Memory profiler is pretty useful, it allows us to have a per function view of memory
consumed. Easy to get a fast picture of how your program memory evolves.
• Full program graph
• Per function graph
• Per line memory consumption
• Trigger for debugger when limit of memory reached
Resources:memory_profiler
- mprof run main.py
- mprof plot
- python –m memory_profiler main.py
- python –m memory_profiler
--pdb-mmem=100 main.py
Resources:line_profiler
LINE_PROFILER
https://github.com/rkern/line_profiler
78 Commits
Last commit: 21st Dec
872 Stars
Resources:line_profiler
Advanced version of cProfile. Shows hits, total time, per hit time and time percentage
for each line of code. Easy for detecting hotspots in your program.
Also compatible with cProfile output.
Progress not lost when Ctrl+C. Displays current status J.
Resources:line_profiler
Resources:Ipython magic
- Supported plugins (not by 5.0 in the case of line_profiler though)
- Interactive profiling for any function
- Easy as:
- %load_ext memory_profiler
- %load_ext line_profiler
Resources:Ipython magic
Advanced:Plop
PLOP
https://github.com/bdarnell/plop
95 Commits
Last commit: 14th Feb
795 Stars
Advanced:Plop
Low overhead profiler. Some people is using it in production systems.
• Really low impact (use of strace and ltrace)
• It displays call graph with time spent on functions
• Flamegraph:
• http://www.brendangregg.com/flamegraphs.html
• https://github.com/brendangregg/FlameGraph
• Viewer running on Tornado
• With a decent setup, you can view the files while executing.
Advanced:Plop
- python -m plop.collector
random_algs.py
- python -m plop.viewer --
datadir=profiles
- python -f flamegraph -m
plop.collector myscript.py
- ./flamegraph.pl profile.flame >
profile.svg
Advanced:Pyformance
PYFORMANCE
https://github.com/omergertel/pyformance
123 Commits
Last commit: 20th Jun
68 Stars
Advanced:Pyformance
Utilities for system and business metrics:
• Counting calls
• Checking average time of a function
• Grouping regex expressions for measuring time
• Measure rate of events over time
• Histograms
• Timers are shared variables. You can use timer(“name”) wherever
Advanced:Pyformance
# Send alarm when average higher
# than expected
def inner_function():
for n in range(1, 100):
with timer("test").time():
sleep(random.uniform(0.1, 0.3))
n ** n
if timer("test").get_mean() > threshold:
print "nnOMG SLOW EXECUTION"
print timer("test").get_mean()
print timer("test").get_max()
print timer("test").get_var()
print "mean rate", timer("test").get_mean_rate()
print "1 min rate", timer("test").get_one_minute_rate()
Advanced:Kcachegrind
KCACHEGRIND
https://kcachegrind.github.io/html/Home.html
809 Commits
Last commit: 6th Jul
--
Advanced:Kcachegrind
Awesome (old) tool for giving global sight of your code:
• Call graph
• Execution time with percentage of time spent
• Block view of time spent for functions
• Time cost per line
• Even assembly code (which of course I use every day)
• Reads from cProfile output (pyprof2calltree)
Advanced:Kcachegrind
Summary
Use whatever tool fits your needs. Some others for other use cases:
• Aiohttp/Django/Flash debug toolbars
• vmprof
• Objgraph
• Snakeviz
• GreenletProfiler
• …
Questions
manuel.miranda@skyscanner.net
manu.mirandad@gmail.com

Mais conteúdo relacionado

Mais procurados

Mais procurados (12)

Optimize Web Application Infrastructure by Rizki Nanda Agam
Optimize Web Application Infrastructure by Rizki Nanda Agam Optimize Web Application Infrastructure by Rizki Nanda Agam
Optimize Web Application Infrastructure by Rizki Nanda Agam
 
Kernel Recipes 2017: Using Linux perf at Netflix
Kernel Recipes 2017: Using Linux perf at NetflixKernel Recipes 2017: Using Linux perf at Netflix
Kernel Recipes 2017: Using Linux perf at Netflix
 
Linux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old SecretsLinux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old Secrets
 
Linux Performance Tools
Linux Performance ToolsLinux Performance Tools
Linux Performance Tools
 
Using Erlang in an Embedded and Cross-Compiled World
Using Erlang in an Embedded and Cross-Compiled WorldUsing Erlang in an Embedded and Cross-Compiled World
Using Erlang in an Embedded and Cross-Compiled World
 
Analyzing OS X Systems Performance with the USE Method
Analyzing OS X Systems Performance with the USE MethodAnalyzing OS X Systems Performance with the USE Method
Analyzing OS X Systems Performance with the USE Method
 
Building a Network IP Camera using Erlang
Building a Network IP Camera using ErlangBuilding a Network IP Camera using Erlang
Building a Network IP Camera using Erlang
 
Embedded Erlang, Nerves, and SumoBots
Embedded Erlang, Nerves, and SumoBotsEmbedded Erlang, Nerves, and SumoBots
Embedded Erlang, Nerves, and SumoBots
 
TAU on Power 9
TAU on Power 9TAU on Power 9
TAU on Power 9
 
Performance Analysis: The USE Method
Performance Analysis: The USE MethodPerformance Analysis: The USE Method
Performance Analysis: The USE Method
 
Terraform 0.12 + Terragrunt
Terraform 0.12 + TerragruntTerraform 0.12 + Terragrunt
Terraform 0.12 + Terragrunt
 
Meego apt
Meego aptMeego apt
Meego apt
 

Destaque

SWISS FREIGHT TECHNICAL PROPOSAL COMPANY PROFILE ALN
SWISS FREIGHT TECHNICAL PROPOSAL COMPANY PROFILE ALNSWISS FREIGHT TECHNICAL PROPOSAL COMPANY PROFILE ALN
SWISS FREIGHT TECHNICAL PROPOSAL COMPANY PROFILE ALN
Ligson Ndebele
 
New Urbanism and Transit Oriented Development in Los Angeles
New Urbanism and Transit Oriented Development in Los AngelesNew Urbanism and Transit Oriented Development in Los Angeles
New Urbanism and Transit Oriented Development in Los Angeles
John Dornoff
 

Destaque (15)

SWISS FREIGHT TECHNICAL PROPOSAL COMPANY PROFILE ALN
SWISS FREIGHT TECHNICAL PROPOSAL COMPANY PROFILE ALNSWISS FREIGHT TECHNICAL PROPOSAL COMPANY PROFILE ALN
SWISS FREIGHT TECHNICAL PROPOSAL COMPANY PROFILE ALN
 
New Urbanism and Transit Oriented Development in Los Angeles
New Urbanism and Transit Oriented Development in Los AngelesNew Urbanism and Transit Oriented Development in Los Angeles
New Urbanism and Transit Oriented Development in Los Angeles
 
BA Press Releases
BA Press ReleasesBA Press Releases
BA Press Releases
 
westminster
westminsterwestminster
westminster
 
Digital Transformation - Real TECH IPP (Innovation Partnership Program)
Digital Transformation - Real TECH IPP (Innovation Partnership Program)Digital Transformation - Real TECH IPP (Innovation Partnership Program)
Digital Transformation - Real TECH IPP (Innovation Partnership Program)
 
Midtown Portland
Midtown PortlandMidtown Portland
Midtown Portland
 
Working paper - Industrial Economics (only descriptive statistics)
Working paper - Industrial Economics (only descriptive statistics)Working paper - Industrial Economics (only descriptive statistics)
Working paper - Industrial Economics (only descriptive statistics)
 
Digital Transformation - Real TECH IPP (Innovatio Partnership Program)
Digital Transformation - Real TECH IPP (Innovatio Partnership Program)Digital Transformation - Real TECH IPP (Innovatio Partnership Program)
Digital Transformation - Real TECH IPP (Innovatio Partnership Program)
 
Développer votre activité e-commerce en Espagne
Développer votre activité e-commerce en EspagneDévelopper votre activité e-commerce en Espagne
Développer votre activité e-commerce en Espagne
 
Barcode Labels manufacturer
Barcode Labels  manufacturerBarcode Labels  manufacturer
Barcode Labels manufacturer
 
Mayil.CVN
Mayil.CVNMayil.CVN
Mayil.CVN
 
Indian Barcode Corporation Labels and tags for barcode and rfid industry i...
Indian Barcode Corporation  Labels and tags  for barcode  and rfid industry i...Indian Barcode Corporation  Labels and tags  for barcode  and rfid industry i...
Indian Barcode Corporation Labels and tags for barcode and rfid industry i...
 
Online Marketing Rockstars Daily Präsentation 2016
Online Marketing Rockstars Daily Präsentation 2016Online Marketing Rockstars Daily Präsentation 2016
Online Marketing Rockstars Daily Präsentation 2016
 
プロジェクト向けランチャーを用いた開発フロー
プロジェクト向けランチャーを用いた開発フロープロジェクト向けランチャーを用いた開発フロー
プロジェクト向けランチャーを用いた開発フロー
 
Online Marketing Rockstars Präsentation NPA 2016 #NPA16
Online Marketing Rockstars Präsentation NPA 2016 #NPA16Online Marketing Rockstars Präsentation NPA 2016 #NPA16
Online Marketing Rockstars Präsentation NPA 2016 #NPA16
 

Semelhante a Where is the bottleneck

これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
goccy
 
Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012
Mike Willbanks
 
Debugging PySpark - PyCon US 2018
Debugging PySpark -  PyCon US 2018Debugging PySpark -  PyCon US 2018
Debugging PySpark - PyCon US 2018
Holden Karau
 

Semelhante a Where is the bottleneck (20)

20 x Tips to better Optimize your Flash content
20 x Tips to better Optimize your Flash content20 x Tips to better Optimize your Flash content
20 x Tips to better Optimize your Flash content
 
Hands-on go profiling
Hands-on go profilingHands-on go profiling
Hands-on go profiling
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
My "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsMy "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails Projects
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 
Monitorama 2015 Netflix Instance Analysis
Monitorama 2015 Netflix Instance AnalysisMonitorama 2015 Netflix Instance Analysis
Monitorama 2015 Netflix Instance Analysis
 
Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)
 
HiPEAC 2019 Tutorial - Maestro RTOS
HiPEAC 2019 Tutorial - Maestro RTOSHiPEAC 2019 Tutorial - Maestro RTOS
HiPEAC 2019 Tutorial - Maestro RTOS
 
Guider: An Integrated Runtime Performance Analyzer on AGL
Guider: An Integrated Runtime Performance Analyzer on AGLGuider: An Integrated Runtime Performance Analyzer on AGL
Guider: An Integrated Runtime Performance Analyzer on AGL
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
Metasploit For Beginners
Metasploit For BeginnersMetasploit For Beginners
Metasploit For Beginners
 
Apache Spark Performance is too hard. Let's make it easier
Apache Spark Performance is too hard. Let's make it easierApache Spark Performance is too hard. Let's make it easier
Apache Spark Performance is too hard. Let's make it easier
 
Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
 
Debugging PySpark - PyCon US 2018
Debugging PySpark -  PyCon US 2018Debugging PySpark -  PyCon US 2018
Debugging PySpark - PyCon US 2018
 
Tech Days 2015: ARM Programming with GNAT and Ada 2012
Tech Days 2015: ARM Programming with GNAT and Ada 2012Tech Days 2015: ARM Programming with GNAT and Ada 2012
Tech Days 2015: ARM Programming with GNAT and Ada 2012
 
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
 
Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2
 
Taboola's experience with Apache Spark (presentation @ Reversim 2014)
Taboola's experience with Apache Spark (presentation @ Reversim 2014)Taboola's experience with Apache Spark (presentation @ Reversim 2014)
Taboola's experience with Apache Spark (presentation @ Reversim 2014)
 
Optimizing and Profiling Golang Rest Api
Optimizing and Profiling Golang Rest ApiOptimizing and Profiling Golang Rest Api
Optimizing and Profiling Golang Rest Api
 

Último

Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 

Where is the bottleneck