-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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-43693: Eliminate unused "fast locals". #26587
bpo-43693: Eliminate unused "fast locals". #26587
Conversation
🤖 New build scheduled with the buildbot fleet by @ericsnowcurrently for commit 4acf0254591d1e6bcc526cb7b111faaeaf0dd1a0 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
4acf025
to
1d20538
Compare
🤖 New build scheduled with the buildbot fleet by @ericsnowcurrently for commit 1d2053878ed6a02ebc5ad727a095255bad29b679 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
FYI, the "test-with-buildbots" run shows failures on two of the Windows 10 buildbots. (The refleaks buildbot issue is unrelated.) The failures are consistent in test_clinic, test_peg_generator, and test_tools, and are all founded in
These definitely seem related to this PR so I'm going to investigate. (I'll debug the issue as soon as I have VS and the cpython repo set up on my Windows laptop.) |
So far I haven't been able to reproduce the failures showing up on those two buildbots. I was able to build on Windows and run the tests but got no failures. |
Same here. |
Hmm, I'm pretty sure the problem is that I forgot to bump the .pyc magic number, though I would have expected more failures. Perhaps buildbots clear all the cached .pyc files except in the Tools directory? |
That sounds like a very good theory.
…On Wed, Jun 9, 2021 at 11:52 AM Eric Snow ***@***.***> wrote:
Hmm, I'm pretty sure the problem is that I forgot to bump the .pyc magic
number, though I would have expected more failures. Perhaps buildbots clear
all the cached .pyc files *except* in the Tools directory?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#26587 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAWCWMQJKR5EMZ6PFSN24QDTR6Z6NANCNFSM46IUPKLA>
.
--
--Guido van Rossum (python.org/~guido)
|
1f0fdce
to
92f62e7
Compare
Yep, it looks like on Windows we only delete .pyc files under Lib/ (before running the tests). See PCbuild/rt.bat. |
Perhaps we should not delete any pic files, just to expose this kind of bug? At least in some test runs? Else this might have gone through... |
Yeah, I think you're right. |
🤖 New build scheduled with the buildbot fleet by @ericsnowcurrently for commit 92f62e7b85088b6250adbaf70a0e3e56e4c1f0c3 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
Those two buildbots are happy with this PR now. 😄 |
I've just had a play with this: >>> def test(arg=0, escapes_arg=1):
... local = 2
... escapes = 3
... another_local = 4
... def inner():
... return escapes, escapes_arg
...
>>> dis.dis(test)
It looks like variables are still being shuffled around. I would expect this:
What is the point of _varname_from_oparg? >>> for i, name in enumerate(test.__code__.co_varnames):
... assert name == test.__code__._varname_from_oparg(i) What would be more useful is a method to get the kind of the variable. |
Yeah, I noticed that too. Currently in compile.c (in |
I was exposing
Mostly, I don't care about the specific name. I was trying to avoid something like
That's what @gvanrossum was talking about yesterday. We could add |
FYI, neither of those two issues relates to this PR. 😄 They were introduced in my previous PRs. |
I’m waiting for,this to land. Mark, are there any specific things you need to see changed? |
Yes, we shouldn't be shuffling around the variables. The order of the variables in In 3.10 all cells came after all other locals. Inefficient, but predictable. Currently they are in no clear order, which is likely to be error prone. It also suggests to me that something is wrong in the compiler; |
Actually, it looks like cell variables only appear in
We want to treat all cells the same, regardless of whether they are a parameter or not. |
@markshannon, I see what you mean now. I'm not opposed to putting cells in their "natural" position. I looked at doing that when I first started working on all this. However, at the time I didn't see any easy way to do so. It would require changes in the compiler and symtable code that I wasn't sure were worth making at the time. I do agree that we can look at doing so later. |
92f62e7
to
b5ef8e1
Compare
FYI, I plan on merging this first thing in the morning (my morning anyway). |
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.
A few changes needed. Specifically _PyFrame_OpAlreadyRan()
should be removed.
When you're done making the requested changes, leave the comment: |
(I should just add that I had always assumed that a "regular" variable could never be a cell. But the existence of the |
🤖 New build scheduled with the buildbot fleet by @ericsnowcurrently for commit bdb12a7 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
Currently, if an arg value escapes (into the closure for an inner function) we end up allocating two indices in the fast locals even though only one gets used. Additionally, using the lower index would be better in some cases, such as with no-arg `super()`. To address this, we update the compiler to fix the offsets so each variable only gets one "fast local". As a consequence, now some cell offsets are interspersed with the locals (only when an arg escapes to an inner function). https://bugs.python.org/issue43693
Currently, if an arg value escapes (into the closure for an inner function) we end up allocating two indices in the fast locals even though only one gets used. To address this, we update the compiler to fix the offsets so each variable only gets one "fast local". As a consequence, now some cell offsets are interspersed with the locals (only when an arg escapes to an inner function).
https://bugs.python.org/issue43693