-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-45020: Add -X frozen_modules=[on|off] to explicitly control use of frozen modules. #28320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-45020: Add -X frozen_modules=[on|off] to explicitly control use of frozen modules. #28320
Conversation
…Py_IsInstalled()).
Yeah, since we no longer consider whether it's installed, there are three basic build modes that may be relevant:
Your assumption seems to be that we recommend developers use (1), and only release managers use (3), when actually building a release. But my assumption (and my workflow) is that usually (2) works just fine for most purposes. And it's the default for a reason, right? In particular people who are only editing Python code (like Steven D'Aprano or Ethan Furman, both core devs who never touch C code) have no reason to use (1) or (3), so they likely use (2). They do a checkout, run Developers working on the freezing code (or something that affects freezing, like marshal) can turn on
I have to admit I don't understand this code very well, I've never worked with it before, and I don't know what constraints it has. The thought of dropping specific Possibly my hangup is that I don't know what the purpose of |
All that makes sense. I'll go ahead with the switch, though I'll probably still tackle the PGO check in a separate PR. The only downside is that folks using an installed python without |
I suppose it's a question of whether or not using
At first I added a function just to initialize
Don't stress too much. The runtime initialization code is among the most complex in the repo, even after all the work Nick and Victor have done to clean it up. |
Okay, I still vote to get rid of the bool infrastructure and just use ints. I've been writing C code using ints as flags most of my life. :-) Regarding the other thing, I guess this bit of code at line 2200 in initconfig.c is most mystifying to me:
It seems to say that if we're installing importlib but we're not computing the path configuration, don't initialize use_frozen_modules? It almost seems to be simpler to remove the call to
|
Thanks for clarifying. Yeah, that's harder to following than it needs to be. That code is partly a holdover from earlier when I was depending on the results of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting pretty close...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits left only. After this let me look at it once more from a holistic POV, but I think it's good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found one unused function. Otherwise LG. Congrats!
Thanks for all the helpful reviewing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anchors away!
) Doing this provides significant performance gains for runtime startup (~15% with all the imported modules frozen). We don't yet freeze all the imported modules because there are a few hiccups in the build systems we need to sort out first. (See bpo-45186 and bpo-45188.) Note that in PR GH-28320 we added a command-line flag (-X frozen_modules=[on|off]) that allows users to opt out of (or into) using frozen modules. The default is still "off" but we will change it to "on" as soon as we can do it in a way that does not cause contributors pain. https://bugs.python.org/issue45020
Currently we freeze several modules into the runtime. For each of these modules it is essential to bootstrapping the runtime that they be frozen. Any other stdlib module that we later freeze into the runtime is not essential. We can just as well import from the .py file.
This PR lets users explicitly choose which should be used, with the new "-X frozen_modules=[on|off]" CLI flag. The default is "on" for non-debug builds and "off" for debug builds. The latter is for the benefit of CPython contributors, so source changes they make are used immediately without having to run
make regen-frozen
. FWIW, we may try making the default logic a little more sophisticated for CPython contributors, but switching based on--with-pydebug
should be enough at first.(FYI, these changes come from gh-28107. @gvanrossum already reviewed them there.)
https://bugs.python.org/issue45020