Skip to content

Instantly share code, notes, and snippets.

@nascheme
Created September 9, 2017 23:04
Show Gist options
  • Save nascheme/c74d2d9425201426a18df7ff65e52545 to your computer and use it in GitHub Desktop.
Save nascheme/c74d2d9425201426a18df7ff65e52545 to your computer and use it in GitHub Desktop.
CPython dev sprint 2017: Startup speedup: profiling startup time
See:
https://public.etherpad-mozilla.org/p/cpython-dev-sprint-2017
- background: https://lwn.net/Articles/730915/
- profiling of import
- DTrace probes for module import start/done
https://github.com/nascheme/cpython/tree/dtrace-module-import
https://gist.github.com/nascheme/c1cece36a3369926ee93cecc3d024179
https://gist.github.com/nascheme/0bff5c49bb6b518f5ce23a9aea27f14b
- Findings: importlib is slow (written in Python) but is already well optimized
and no low hanging fruit there
- marshal.load looked expensive but compile with gcc -O fixed that
- some modules are slow, os -> _collections_abc, could do more things lazily
(e.g. _Environ)
- trial program not too bad, about 18 ms on my MacBook
- further work: lazy loading of modules supported by AST (hard work to do by hand), lazy loading of module parts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment