User:Ajak/Portage Performance
Portage performance notes
I've noticed some odd things with regard to Portage performance. I'm documenting them here so I have a public way to reference them.
Note that different baseline timings between different hyperfine runs aren't relevant, such timings are highly variable based on the state of the system at the time. A quicker dependency calculation might mean that the world update is clean, for example, while a longer emerge run might mean there's many things to update. It's worth exploring exactly where that time might be lost as an indication of what dependency tree state might trigger longer runtimes. For timing comparisons between emerge runs on the same system state, this should not matter much.
cpython vs pypy
mgorny has noticed that pypy3 is much faster for dependency calculations (for him). In his blog post, he notes that many people were not able to reproduce his results. I surmise that much of this is due to few people realizing that USE=native-extensions
drastically affects pypy performance. With that flag on, Portage compiles C extensions, while pypy.org's performance page notes, "Any C extension module recompiled with PyPy takes a very large hit in performance. PyPy supports C extension modules solely to provide basic functionality."
Once I turn that flag off, I can indeed produce a similar speedup:
$ hyperfine --style basic -w 1 "EPYTHON=pypy3 emerge -pvuDN @world" "EPYTHON=python3.10 emerge -pvuDN @world"
Benchmark 1: EPYTHON=pypy3 emerge -pvuDN @world
Time (mean ± σ): 49.942 s ± 3.306 s [User: 48.188 s, System: 1.048 s]
Range (min … max): 43.447 s … 52.857 s 10 runs
Benchmark 2: EPYTHON=python3.10 emerge -pvuDN @world
Time (mean ± σ): 139.752 s ± 7.345 s [User: 137.742 s, System: 1.033 s]
Range (min … max): 133.728 s … 154.691 s 10 runs
Summary
'EPYTHON=pypy3 emerge -pvuDN @world' ran
2.80 ± 0.24 times faster than 'EPYTHON=python3.10 emerge -pvuDN @world'
However, even with this change, some people still report no significant change between cpython and pypy.
Anecdotally, I've noticed that package merges are much slower with pypy3 (as opposed to just dependency calculations as above). I haven't found a package with which I can reproducibly demonstrate the performance difference.
python3.10 vs python3.11
Over the recent months, it's been asked many times whether the upstream speedups with python3.11 do anything substantial with Portage. I don't think so:
$ hyperfine --style basic -w 1 "EPYTHON=python3.10 emerge -pvuDN @world" "EPYTHON=python3.11 emerge -pvuDN @world"
Benchmark 1: EPYTHON=python3.10 emerge -pvuDN @world
Time (mean ± σ): 231.185 s ± 0.944 s [User: 229.495 s, System: 1.353 s]
Range (min … max): 228.863 s … 232.148 s 10 runs
Benchmark 2: EPYTHON=python3.11 emerge -pvuDN @world
Time (mean ± σ): 236.257 s ± 0.433 s [User: 234.335 s, System: 1.533 s]
Range (min … max): 235.435 s … 236.707 s 10 runs
Summary
'EPYTHON=python3.10 emerge -pvuDN @world' ran
1.02 ± 0.00 times faster than 'EPYTHON=python3.11 emerge -pvuDN @world'
Comparing runtime of Github Actions CI for python3.10 vs python3.11 paints a similar picture, even if not a proper benchmark.