It was realized during PyCon that since we are freezing importlib we could now consider freezing all the modules to cut out having to stat or read them from disk. So for day 1 of the sprints I I decided to hack up a proof-of-concept to see what kind of performance gain it would get.
Freezing everything except encodings.__init__, os, and _sysconfigdata, it speeds up startup by 11% compared to default. Compared to 2.7 it shaves 14% from the slowdown (27% slower vs. 41% slower). The full results are at the end of the email. Now the question is whether the maintenance cost of having to rebuild Python for a select number of stdlib modules is enough to warrant putting in the effort to make this work. My guess is the best approach would be adding a Lib/_frozen directory where any modules that we treat like this would be kept to act as a reminder that you need to rebuild for them (I would probably move importlib/_boostrap.py as well to make this consistent). Thoughts? -------------------------------------- default vs the freezing: ### normal_startup ### Min: 0.524812 -> 0.473339: 1.11x faster Avg: 0.534403 -> 0.481245: 1.11x faster Significant (t=61.80) Stddev: 0.00466 -> 0.00391: 1.1909x smaller ### startup_nosite ### Min: 0.307359 -> 0.291939: 1.05x faster Avg: 0.317667 -> 0.300156: 1.06x faster Significant (t=26.29) Stddev: 0.00543 -> 0.00385: 1.4099x smaller --------- 2.7 vs the freezing: ### normal_startup ### Min: 0.367571 -> 0.465264: 1.27x slower Avg: 0.374404 -> 0.476662: 1.27x slower Significant (t=-90.26) Stddev: 0.00313 -> 0.00738: 2.3603x larger ### startup_nosite ### Min: 0.164510 -> 0.290544: 1.77x slower Avg: 0.169833 -> 0.301109: 1.77x slower Significant (t=-286.30) Stddev: 0.00211 -> 0.00407: 1.9310x larger --------- As a baseline, 2.7 vs default: ### normal_startup ### Min: 0.368916 -> 0.521758: 1.41x slower Avg: 0.376784 -> 0.531883: 1.41x slower Significant (t=-172.82) Stddev: 0.00423 -> 0.00474: 1.1207x larger ### startup_nosite ### Min: 0.165156 -> 0.309090: 1.87x slower Avg: 0.171516 -> 0.319004: 1.86x slower Significant (t=-283.45) Stddev: 0.00334 -> 0.00399: 1.1948x larger
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com