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. |
Sorry, something went wrong.
4acf025 to
1d20538
Compare
June 8, 2021 22:11
|
🤖 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. |
Sorry, something went wrong.
|
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.) |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
Same here. |
Sorry, something went wrong.
|
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? |
Sorry, something went wrong.
|
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)
|
Sorry, something went wrong.
1f0fdce to
92f62e7
Compare
June 9, 2021 19:01
|
Yep, it looks like on Windows we only delete .pyc files under Lib/ (before running the tests). See PCbuild/rt.bat. |
Sorry, something went wrong.
|
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... |
Sorry, something went wrong.
|
Yeah, I think you're right. |
Sorry, something went wrong.
|
🤖 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. |
Sorry, something went wrong.
|
Those two buildbots are happy with this PR now. 😄 |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
Yeah, I noticed that too. Currently in compile.c (in |
Sorry, something went wrong.
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 |
Sorry, something went wrong.
|
FYI, neither of those two issues relates to this PR. 😄 They were introduced in my previous PRs. |
Sorry, something went wrong.
|
I’m waiting for,this to land. Mark, are there any specific things you need to see changed? |
Sorry, something went wrong.
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; |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
@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. |
Sorry, something went wrong.
92f62e7 to
b5ef8e1
Compare
June 14, 2021 17:28
|
FYI, I plan on merging this first thing in the morning (my morning anyway). |
Sorry, something went wrong.
markshannon
left a comment
There was a problem hiding this comment.
A few changes needed. Specifically _PyFrame_OpAlreadyRan() should be removed.
Sorry, something went wrong.
|
When you're done making the requested changes, leave the comment: |
Sorry, something went wrong.
|
(I should just add that I had always assumed that a "regular" variable could never be a cell. But the existence of the |
Sorry, something went wrong.
|
🤖 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. |
Sorry, something went wrong.
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