-
Notifications
You must be signed in to change notification settings - Fork 52
Closed
Labels
Description
During runtime startup we import a bunch of modules, particularly if the site module is used (without -S). Any of these that aren't frozen/linked incur a substantial IO overhead. We already freeze importlib and link a number of builtin modules. The idea here is that we freeze/link the rest.
To do:
- re-run a large number of times times to stabilize the results
- make sure I've frozen all the relevant modules
- make sure all startup extension modules are built-in
-
re-run the comparison on the benchmarking machine(I'm comfortable with the results I'm seeing locally.) - create a BPO issue and an upstream PR
- move generated .h files to a new "Python/frozen" directory (like we do for argument clinic)
- detect if dev build without accessing filesystem
- add
-X frozen-modules=[on|off](defaulting to "off") - sort out Windows
- stop tracking frozen .h files in the repo (auto-regen them in the Windows build process)
- freeze
os,site, andcodecsblocked by bpo-45186 (or maybe just by removing the .h files)- bpo-45020: Freeze os, site, and codecs. python/cpython#28398
- remember the stdlib dir in getpath.c (bpo-45211)
- set
__file__(and__path__) on frozen [stdlib] modules - (partially?) freeze
encodingspackage (bpo-45653)blocked by noise added to "make" output (see comment)- ? only include common encodings? (partial pkg would need proper
__path__bpo-21736) - bpo-45653: partially freeze encodings package python/cpython#29331
- default to "on"
blocked by bpo-45211- "off" if actually running out of the source tree
- ?
"off" if Py_DEBUG - ?
always "on" if not a PGO build, even if running out of the source tree - ? emit a warning if running out of the source tree
- change
-X frozen_modulesto-X frozen_stdliband "use_frozen" in import.c (see gh-28633) - default to "off" on Windows when running in source tree (bpo-45651)
- do no freeze
os.path(bpo-45272) - make sure Tools/freeze is still working properly (bpo-45096, bpo-45395, ...)
- add a devguide entry about frozen stdlib modules (python/devguide#756)
- double-check performance improvement
- test test test #117
after:
- freeze stdlib modules imported during
./python -m ...(bpo-45654) - freeze argparse (and dependencies) (bpo-45660)
- ? freeze other commonly used modules (bpo-45661)
- ? do not freeze platform-specific modules when not applicable (bpo-45273)
- ? move away from a linear search in
find_frozen()(see bpo-45213)- for now a comment noting the concern (and a reference to the issue) is sufficient
- improve errors related to frozen modules (bpo-45379)
- ? add a build option to specify the default for "-X frozen_modules"
- ? record any default derived from the build options (and set of
PyConfig - Makefile cleanup
- ? use a common make recipe for freezing modules
- less generated code in
Makefile.pre.inand simplifiesTools/scripts/freeze_modules.pya little - bpo-45020: Use a common recipe for freezing modules. python/cpython#28583
- less generated code in
- ? do not rebuild frozen.o if no frozen modules were actually rebuilt
- ? make "make all" less noisy (dot per file
- ? use a common make recipe for freezing modules
- use
_imp.frozen_module_names()inTools/scripts/generate_stdlib_module_names.py(bpo-45189) - update Tools/freeze to depend on Toos/scripts/freeze_modules.py? (bpo-45096)
- ? support more of the FileLoader API on the frozen loader?
investigate:
- create a flamegraph for "after"
- figure out where all the unexpected syscalls are coming from (e.g. 25 stats, down from 80)
- get a clear picture of where the other syscalls come from (e.g. "rt_sigaction", "mmap")
related:
- inconsistent marshal output (https://bugs.python.org/issue45186 and https://bugs.python.org/issue34093)
- missing documentation for
ModuleSpec.loader_state(https://bugs.python.org/issue45364)
Candidate solutions to the editing-stdlib-.py-files problem, from bpo-45020:
- use a command-line flag to opt-out of frozen modules?
- use a build flag to opt out (e.g. a configure flag or a new Py_NO_FROZEN or even Py_DEBUG)?
- ignore frozen modules if it's a dev build?
- (note: importlib._bootstrap and importlib._bootstrap_external must always be frozen, regardless of a flag)
- accommodate users of an installed Python that sometimes edit stdlib modules while debugging code?
- always emit a warning if a frozen module is ignored (in favor of the source module)?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done