SlideShare a Scribd company logo
Python performance
engineering in 2017
Alex Chistyakov, an engineer @ some company
Agenda
- Is Python slow?
- How to profile a Python program?
- We are not going to talk about blockchain, sorry
2
Is Python slow?
- Definitely, because of GIL and lack of proper JIT
3
Is Python slow?
- Definitely, because of GIL and a lack of a proper JIT
compiler
4
Is Python slow?
- Seriously, how do you define “to be slow”?
5
Okay, let’s do our homework finally
- Vagrant + https://github.com/alexclear/piterpy2017
6
Okay, let’s do our homework finally
- Vagrant + https://github.com/alexclear/piterpy2017
- 2-cores VirtualBox VM
7
Okay, let’s do our homework finally
- Vagrant + https://github.com/alexclear/piterpy2017
- 2-cores VirtualBox VM
- Something called Sanic:
https://github.com/channelcat/sanic because it’s 2017
and 2.x era should have ended years ago
8
Okay, let’s do our homework finally
- Vagrant + https://github.com/alexclear/piterpy2017
- 2-cores VirtualBox VM
- Something called Sanic:
https://github.com/channelcat/sanic because it’s 2017
and 2.x era should have ended years ago
- A load testing tool called ab because we love classics
9
What is a typical Python program?
- https://goo.gl/Abz8LX (Please note that this link will
produce different results in 5 years)
- Something not too server-side (or a framework)
- Something scientifical
- Some utility
10
What is a typical Python program?
- https://goo.gl/Abz8LX (Please note that this link will
produce different results in 5 years)
- Something not too server-side
- Something scientifical
- Some utility
- An async web application!
11
A crash course in modern profiling
- Collect stack samples at all costs
12
A crash course in modern profiling
- Collect stack samples at all costs
- Convert collected samples to Brendan Gregg’s
flamegraph.pl format
13
A crash course in modern profiling
- Collect stack samples at all costs
- Convert collected samples to Brendan Gregg’s
flamegraph.pl format
- Create a flamegraph
14
Collecting samples
15
Collecting samples
- Uber’s pyflame: https://github.com/uber/pyflame
16
A bit of internal dark magic
- pyflame uses ptrace(2) system call
17
A bit of internal dark magic
- pyflame uses ptrace(2) system call
- It attaches to a running process and traverses its memory
18
Limitations
- Linux only
- CPython only
- Should have enough privileges
- Can be slow (again, what is “to be slow”? I honestly have
no idea)
19
Enough on that, let’s get real
- Starting the server:
python3 ./sanic-app.py 1>/dev/null 2>/dev/null
- (It does basically nothing, just “hello world” stuff)
20
Enough on that, let’s get real
- Stressing the server:
ab -n 300000 -c 300 http://127.0.0.1:8000/
- Please note that using ab for real world simulations is
totally insane, but this is exactly what we want now
21
How slow is pyflame?
- We run tests with and without pyflame
22
Interactive demo time!
23
Conclusions
- Pyflame is surprisingly fast!
- Python is not slow, it’s just drawn that way
24
Questions, please?
- alexclear@gmail.com
- Skype, Telegram: demeliorator
- Shameless advertising: http://t.me/lhommequipleure
25

More Related Content

What's hot

Gopenflow demo v1 (english)
Gopenflow demo v1 (english)Gopenflow demo v1 (english)
Gopenflow demo v1 (english)
Hiroaki Kawai
 

What's hot (20)

Decision making - for loop , nested loop ,if-else statements , switch in goph...
Decision making - for loop , nested loop ,if-else statements , switch in goph...Decision making - for loop , nested loop ,if-else statements , switch in goph...
Decision making - for loop , nested loop ,if-else statements , switch in goph...
 
Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014
Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014
Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014
 
PuppetConf 2014 Killer R10K Workflow With Notes
PuppetConf 2014 Killer R10K Workflow With NotesPuppetConf 2014 Killer R10K Workflow With Notes
PuppetConf 2014 Killer R10K Workflow With Notes
 
Continuous Delivery of Puppet Manifests
Continuous Delivery of Puppet ManifestsContinuous Delivery of Puppet Manifests
Continuous Delivery of Puppet Manifests
 
Git why how when and more
Git   why how when and moreGit   why how when and more
Git why how when and more
 
Tracing python applications
Tracing python applicationsTracing python applications
Tracing python applications
 
AGES Presentation on Web, Python, Django and GeoServer
AGES Presentation on Web, Python, Django and GeoServerAGES Presentation on Web, Python, Django and GeoServer
AGES Presentation on Web, Python, Django and GeoServer
 
Puppet Data Mining
Puppet Data MiningPuppet Data Mining
Puppet Data Mining
 
Aplicações realtime com gRPC
Aplicações realtime com gRPCAplicações realtime com gRPC
Aplicações realtime com gRPC
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
 
Recompose react
Recompose reactRecompose react
Recompose react
 
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
 
Gopenflow demo v1 (english)
Gopenflow demo v1 (english)Gopenflow demo v1 (english)
Gopenflow demo v1 (english)
 
Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Git Basics - RubyFest 2009
Git Basics - RubyFest 2009
 
App modernization and evented architectures with Node.js
App modernization and evented architectures with Node.jsApp modernization and evented architectures with Node.js
App modernization and evented architectures with Node.js
 
Kubernetes at Datadog Scale - Ara Pulido
Kubernetes at Datadog Scale - Ara PulidoKubernetes at Datadog Scale - Ara Pulido
Kubernetes at Datadog Scale - Ara Pulido
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
 
Lcna 2012-example
Lcna 2012-exampleLcna 2012-example
Lcna 2012-example
 
Effortless network response logging on Android
Effortless network response logging on AndroidEffortless network response logging on Android
Effortless network response logging on Android
 
Terraform & IaC - Nam CXN
Terraform & IaC - Nam CXNTerraform & IaC - Nam CXN
Terraform & IaC - Nam CXN
 

Similar to Python performance engineering in 2017

Similar to Python performance engineering in 2017 (20)

Serial Data from Arduino to Raspberry Pi to MySQL using CoAP Protocol
Serial Data from Arduino to Raspberry Pi to MySQL using CoAP ProtocolSerial Data from Arduino to Raspberry Pi to MySQL using CoAP Protocol
Serial Data from Arduino to Raspberry Pi to MySQL using CoAP Protocol
 
Pcapy and dpkt - tcpdump on steroids - Ran Leibman - DevOpsDays Tel Aviv 2018
Pcapy and dpkt - tcpdump on steroids - Ran Leibman - DevOpsDays Tel Aviv 2018Pcapy and dpkt - tcpdump on steroids - Ran Leibman - DevOpsDays Tel Aviv 2018
Pcapy and dpkt - tcpdump on steroids - Ran Leibman - DevOpsDays Tel Aviv 2018
 
carrow - Go bindings to Apache Arrow via C++-API
carrow - Go bindings to Apache Arrow via C++-APIcarrow - Go bindings to Apache Arrow via C++-API
carrow - Go bindings to Apache Arrow via C++-API
 
PyCon2022 - Building Python Extensions
PyCon2022 - Building Python ExtensionsPyCon2022 - Building Python Extensions
PyCon2022 - Building Python Extensions
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance Python
 
Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...
Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...
Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...
 
Breaking bad habits with GitLab CI
Breaking bad habits with GitLab CIBreaking bad habits with GitLab CI
Breaking bad habits with GitLab CI
 
Functional IoT: Hardware and Platform
Functional IoT: Hardware and PlatformFunctional IoT: Hardware and Platform
Functional IoT: Hardware and Platform
 
Breaking Bad Habits with GitLab CI
Breaking Bad Habits with GitLab CIBreaking Bad Habits with GitLab CI
Breaking Bad Habits with GitLab CI
 
Raspberry pi pico projects raspberry pi projects
Raspberry pi pico projects raspberry pi projectsRaspberry pi pico projects raspberry pi projects
Raspberry pi pico projects raspberry pi projects
 
Rust & Python : Python WA October meetup
Rust & Python : Python WA October meetupRust & Python : Python WA October meetup
Rust & Python : Python WA October meetup
 
Package Management via Spack on SJTU π Supercomputer
Package Management via Spack on SJTU π SupercomputerPackage Management via Spack on SJTU π Supercomputer
Package Management via Spack on SJTU π Supercomputer
 
Advanced View of Projects Raspberry Pi List - Raspberry PI Projects.pdf
Advanced View of Projects Raspberry Pi List - Raspberry PI Projects.pdfAdvanced View of Projects Raspberry Pi List - Raspberry PI Projects.pdf
Advanced View of Projects Raspberry Pi List - Raspberry PI Projects.pdf
 
Docker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamDocker to the Rescue of an Ops Team
Docker to the Rescue of an Ops Team
 
Docker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamDocker to the Rescue of an Ops Team
Docker to the Rescue of an Ops Team
 
Digital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingDigital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meeting
 
First python project
First python projectFirst python project
First python project
 
Advanced View of Projects Raspberry Pi List - Raspberry PI Projects.pdf
Advanced View of Projects Raspberry Pi List - Raspberry PI Projects.pdfAdvanced View of Projects Raspberry Pi List - Raspberry PI Projects.pdf
Advanced View of Projects Raspberry Pi List - Raspberry PI Projects.pdf
 
Frontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy PersonFrontend Performance: Beginner to Expert to Crazy Person
Frontend Performance: Beginner to Expert to Crazy Person
 
Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023
 

More from Alex Chistyakov

More from Alex Chistyakov (20)

My slides from DevOpsDays 2019
My slides from DevOpsDays 2019My slides from DevOpsDays 2019
My slides from DevOpsDays 2019
 
My slides from BMM №3 May 2019
My slides from BMM №3 May 2019My slides from BMM №3 May 2019
My slides from BMM №3 May 2019
 
My slides from DevOps-40 meetup Jun 2019
My slides from DevOps-40 meetup Jun 2019 My slides from DevOps-40 meetup Jun 2019
My slides from DevOps-40 meetup Jun 2019
 
My slides from SECR'2018
My slides from SECR'2018My slides from SECR'2018
My slides from SECR'2018
 
My slides from the first SPb SRE community meetup at DataArt
My slides from the first SPb SRE community meetup at DataArtMy slides from the first SPb SRE community meetup at DataArt
My slides from the first SPb SRE community meetup at DataArt
 
My slides from CC'2019
My slides from CC'2019My slides from CC'2019
My slides from CC'2019
 
My slides from BMM №4 Nov 2019
My slides from BMM №4 Nov 2019My slides from BMM №4 Nov 2019
My slides from BMM №4 Nov 2019
 
My slides from DevOps-40 meetup Oct 2019
My slides from DevOps-40 meetup Oct 2019My slides from DevOps-40 meetup Oct 2019
My slides from DevOps-40 meetup Oct 2019
 
My slides from DevOps-40 meetup Dec 2019
My slides from DevOps-40 meetup Dec 2019My slides from DevOps-40 meetup Dec 2019
My slides from DevOps-40 meetup Dec 2019
 
Configuration management and Kubernetes
Configuration management and KubernetesConfiguration management and Kubernetes
Configuration management and Kubernetes
 
Ansible and other stuff
Ansible and other stuffAnsible and other stuff
Ansible and other stuff
 
My talk at SPb SQA sub-meetup of ITGM
My talk at SPb SQA sub-meetup of ITGMMy talk at SPb SQA sub-meetup of ITGM
My talk at SPb SQA sub-meetup of ITGM
 
My talk at SECR 2017
My talk at SECR 2017My talk at SECR 2017
My talk at SECR 2017
 
On scaling teams
On scaling teamsOn scaling teams
On scaling teams
 
MariaDB workshop
MariaDB workshopMariaDB workshop
MariaDB workshop
 
Docker for JS people
Docker for JS peopleDocker for JS people
Docker for JS people
 
My talk on DevOps engineer's adventures in the Windows world at UWDC 2017
My talk on DevOps engineer's adventures in the Windows world at UWDC 2017My talk on DevOps engineer's adventures in the Windows world at UWDC 2017
My talk on DevOps engineer's adventures in the Windows world at UWDC 2017
 
My talk on GitHub open data at ITGM #10
 My talk on GitHub open data at ITGM #10 My talk on GitHub open data at ITGM #10
My talk on GitHub open data at ITGM #10
 
My talk on DevOps :) at Stachka 2017
My talk on DevOps :) at Stachka 2017My talk on DevOps :) at Stachka 2017
My talk on DevOps :) at Stachka 2017
 
My talk on programming languages at SPbLUG Mar 2017
My talk on programming languages at SPbLUG Mar 2017My talk on programming languages at SPbLUG Mar 2017
My talk on programming languages at SPbLUG Mar 2017
 

Recently uploaded

Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 

Python performance engineering in 2017

  • 1. Python performance engineering in 2017 Alex Chistyakov, an engineer @ some company
  • 2. Agenda - Is Python slow? - How to profile a Python program? - We are not going to talk about blockchain, sorry 2
  • 3. Is Python slow? - Definitely, because of GIL and lack of proper JIT 3
  • 4. Is Python slow? - Definitely, because of GIL and a lack of a proper JIT compiler 4
  • 5. Is Python slow? - Seriously, how do you define “to be slow”? 5
  • 6. Okay, let’s do our homework finally - Vagrant + https://github.com/alexclear/piterpy2017 6
  • 7. Okay, let’s do our homework finally - Vagrant + https://github.com/alexclear/piterpy2017 - 2-cores VirtualBox VM 7
  • 8. Okay, let’s do our homework finally - Vagrant + https://github.com/alexclear/piterpy2017 - 2-cores VirtualBox VM - Something called Sanic: https://github.com/channelcat/sanic because it’s 2017 and 2.x era should have ended years ago 8
  • 9. Okay, let’s do our homework finally - Vagrant + https://github.com/alexclear/piterpy2017 - 2-cores VirtualBox VM - Something called Sanic: https://github.com/channelcat/sanic because it’s 2017 and 2.x era should have ended years ago - A load testing tool called ab because we love classics 9
  • 10. What is a typical Python program? - https://goo.gl/Abz8LX (Please note that this link will produce different results in 5 years) - Something not too server-side (or a framework) - Something scientifical - Some utility 10
  • 11. What is a typical Python program? - https://goo.gl/Abz8LX (Please note that this link will produce different results in 5 years) - Something not too server-side - Something scientifical - Some utility - An async web application! 11
  • 12. A crash course in modern profiling - Collect stack samples at all costs 12
  • 13. A crash course in modern profiling - Collect stack samples at all costs - Convert collected samples to Brendan Gregg’s flamegraph.pl format 13
  • 14. A crash course in modern profiling - Collect stack samples at all costs - Convert collected samples to Brendan Gregg’s flamegraph.pl format - Create a flamegraph 14
  • 16. Collecting samples - Uber’s pyflame: https://github.com/uber/pyflame 16
  • 17. A bit of internal dark magic - pyflame uses ptrace(2) system call 17
  • 18. A bit of internal dark magic - pyflame uses ptrace(2) system call - It attaches to a running process and traverses its memory 18
  • 19. Limitations - Linux only - CPython only - Should have enough privileges - Can be slow (again, what is “to be slow”? I honestly have no idea) 19
  • 20. Enough on that, let’s get real - Starting the server: python3 ./sanic-app.py 1>/dev/null 2>/dev/null - (It does basically nothing, just “hello world” stuff) 20
  • 21. Enough on that, let’s get real - Stressing the server: ab -n 300000 -c 300 http://127.0.0.1:8000/ - Please note that using ab for real world simulations is totally insane, but this is exactly what we want now 21
  • 22. How slow is pyflame? - We run tests with and without pyflame 22
  • 24. Conclusions - Pyflame is surprisingly fast! - Python is not slow, it’s just drawn that way 24
  • 25. Questions, please? - alexclear@gmail.com - Skype, Telegram: demeliorator - Shameless advertising: http://t.me/lhommequipleure 25