-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-44032: Move data stack to thread from FrameObject. #26076
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
…ocals + frees + cells.
… and slow implementation.
…y use most of the time.
470b206
to
d9936c3
Compare
d9936c3
to
2c14939
Compare
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.
Overall, looks good and the value of this change seems pretty clear. 🙂
I'll probably take a second pass before approving. I mostly follow the change, but mapping the old code to the new conceptually isn't easy. The old code was fairly straight-forward to follow. The new code isn't quite so easy. It may help to have a bit more explanation somewhere of how the threadstate-based stack operates, including relative to frames.
@@ -40,8 +40,8 @@ struct PyCodeObject { | |||
PyObject *co_name; /* unicode (name, for reference) */ | |||
PyObject *co_linetable; /* string (encoding addr<->lineno mapping) See | |||
Objects/lnotab_notes.txt for details. */ | |||
int co_nlocalsplus; /* Number of locals + free + cell variables */ |
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.
FWIW, I've been calling this co_nfastlocals
in my branches.
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.
But it isn't all "fast" locals, as there are cells as well. Admittedly, co_nlocalsplus
isn't a great name either.
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.
"fastlocals" is what we already call them in ceval.c.
When you're done making the requested changes, leave the comment: |
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.
LGTM
After some offline discussion it makes sense now. We would still benefit from some explanation in the code though.
🤖 New build scheduled with the buildbot fleet by @markshannon for commit c5ccb7d 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
The failure was a timeout on test_multiprocessing_fork one of the refleak buildbots. |
{ | ||
assert(f->f_own_locals_memory == 0); | ||
assert(f->f_stackdepth == 0); | ||
int size = frame_nslots(f); |
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.
@markshannon, this gives a compiler error because frame_nslots() returns a Py_ssize_t.
Move local, cell and free variables, plus the evaluation stack to the thread.
Cuts down the size of frames to under 100 bytes, and enables further optimizations of Python-to-Python calls.
https://bugs.python.org/issue44032