-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-45653: Freeze encodings package modules #29788
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
Conversation
f34e711
to
53ff4eb
Compare
53ff4eb
to
16cab74
Compare
I am alright with continuing it but if you want, I can take it. I will close this in favor of your PR 😊 |
Oops, wrong PR 🤦 |
Do you have a clue about the test failures yet? (You know you can run tests locally right? Etc.) |
I am on Windows, and even in debug builds frozen modules are used which is kinda confusing because on Linux in debug mode frozen modules are not used. I know how to run tests but when I run test_embed on windows it skips it saying that _testembed.exe doesn't exists, even though it exists. I'll see if I can fix it. |
You are seeing the effect of https://bugs.python.org/issue45651. To force frozen modules on/off you can pass |
4c21f3d
to
f2ee158
Compare
@ericsnowcurrently Do you have any ideas to share on where to look for these failures? Apparently (deep)freezing part of a package is not fully supported yet. @kumaraditya303 I'll look into this later this week if we don't hear from Eric, but my hunch is that we need to add code (I don't know where yet) that ties the frozen package to the on-disk directory for the same package, so that PS. If you want your fix for test_embed incorporated, rebase on the new main branch. |
f2ee158
to
5f9e67f
Compare
Looks like test_embed fails on all platforms (and a few others fail on Windows only). It looks like you have your test_embed fix in here. Could you revert that change and push that to this PR to see if that fixes the macOS and Ubuntu tests? (I tried it on Windows and it does fix it, somehow. So maybe it's just wrong?) |
I have rebased PR and included the test_embed fix by which I am atleast able to run test_embed, earlier it was skipped moreover that change only affects windows cpython/Lib/test/test_embed.py Lines 64 to 69 in 4b97d97
|
Nevermind, reverting that just skips test_embed on Windows. The culprit must be that some way of setting the default encoding causes Python to fail, presumably because it can't find the encoding in the encodings package. I'd focus on finding the culprit here (hopefully you can figure out how to run just the failing command, outside the test harness). |
I can tell you that the test_embed failures seem to ultimately come from line 194-195 in Python/codecs.c::_PyCodec_Lookup, called from Objects/unicodeobject.c::init_stdio_encoding at line 15913 (!). (UPDATE: Via config_get_codec_name at line 15870.) |
The most notable thing to me is that 4 of the 5 failing tests are printing nothing to stdout. This means that I suspect
It should be something like
|
This it does, even when I pass
However the failing tests seem to be embedding Python (hence |
Good point. That's an important observation. If we cannot extrapolate the stdlib dir during runtime init then frozen modules will not have So, if that is the problem then: One possible fallback for runtime-init-could-not-find-stdlib-dir is to manually walk One thing to watch out for when walking Another possible solution is to disable the frozen FWIW, the matter of runtime init not finding the stdlib dir (and hence |
5f9e67f
to
6ee879b
Compare
Kumar, pleased don’t force push. Use merge instead of rebase; and add new commits as you change the code. It makes review easier, and we will squash at the end when we merge upstream. |
Okay, will always merge onwards :) |
Hey, you don't have to merge every commit on main! Also, you need a news item. Follow the instructions in the relevant test failure. |
There was a conflict with getpath.c hence I needed to merge main. |
Honestly I think this should work. I will close and reopen the issue so as to re-trigger the CI. |
...aand, we're back! |
887145b
to
b806d9d
Compare
b806d9d
to
3199a97
Compare
Hey @kumaraditya303, what are your plans for this PR? It seems it currently fails some tests and there's also the problem reported by @tiran in https://bugs.python.org/issue45653#msg408474. |
It is failing on the same embedding tests as earlier and I am busy currently so I'll investigate later on this as the tests are a bit tough to debug on this one. |
Okay, no worries! |
I wasn't able to fix this despite debugging it for months and the performance improvement is negligible on Linux. I close this PR. |
Sorry to hear it, but it sounds like it’s for the best. |
No worries, I don't usually leave things unfinished but the perf improvement from this if the current issue could be solved is not worth it so I decided to leave it. I may revisit this if I find something but I have some other more interesting thing TODO ;) |
Freezes encodings modules as suggested by @gvanrossum
https://bugs.python.org/issue45653