<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Perf on Shai Asher</title><link>https://slow-is-smooth.io/tags/perf/</link><description>Recent content in Perf on Shai Asher</description><generator>Hugo</generator><language>en-gb</language><lastBuildDate>Sun, 16 Feb 2020 09:00:00 +0200</lastBuildDate><atom:link href="https://slow-is-smooth.io/tags/perf/index.xml" rel="self" type="application/rss+xml"/><item><title>Profiling Below the Bytecode</title><link>https://slow-is-smooth.io/blog/profiling-below-the-bytecode/</link><pubDate>Sun, 16 Feb 2020 09:00:00 +0200</pubDate><guid>https://slow-is-smooth.io/blog/profiling-below-the-bytecode/</guid><description>&lt;p&gt;A Python 3.8 program that splits strings, adds up their lengths and writes JSON takes 4.5 seconds.&#10;&lt;code&gt;cProfile&lt;/code&gt; says 3.1 of them are in &lt;code&gt;str.split&lt;/code&gt;. &lt;code&gt;py-spy&lt;/code&gt; says two thirds of the samples are in the list&#10;comprehension that calls it. &lt;code&gt;perf&lt;/code&gt;, the Linux profiler, says a third of the time is in a C function&#10;called &lt;code&gt;collect&lt;/code&gt;, and another quarter in functions it calls, and it doesn&amp;rsquo;t name a single Python&#10;function. All three are right about what they measure, and only one of them found the real problem:&#10;the cycle collector from Part 4, walking three million lists that will never be garbage. With the&#10;collector turned off, the same program runs in 1.9 seconds.&lt;/p&gt;</description></item></channel></rss>