Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-45256: Remove the usage of the C stack in Python to Python calls#28488
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
pablogsal commented Sep 21, 2021 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading. Please reload this page.
bedevere-bot commented Sep 21, 2021
🤖 New build scheduled with the buildbot fleet by @pablogsal for commit b4149b6d80bc85c73104ca0f98ee3754cf5d485c 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
Uh oh!
There was an error while loading. Please reload this page.
b4149b6 to 415273dCompare
markshannon left a 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.
Looking good. A few minor issues.
Uh oh!
There was an error while loading. Please reload this page.
Python/ceval.c Outdated
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.
nargsf and vector_nargs below are only used in asserts.
I think all the asserts and assignments to nargsf and vector_nargs could be replaced with assert(nargs == 0 || args != NULL);
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.
Op ha
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
bedevere-bot commented Sep 21, 2021
When you're done making the requested changes, leave the comment: |
pablogsal commented Sep 21, 2021
@markshannon Damn, unfortunately something is going on with Windows: Apparently that is a |
pablogsal commented Sep 21, 2021
@markshannon Oh, I found the source of the Windows failure: it was an existing bug in the That was challenging to find indeed! |
bedevere-bot commented Sep 21, 2021
🤖 New build scheduled with the buildbot fleet by @pablogsal for commit 50276ad8813bfd0bb0455d0e699e2ee301071f00 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
Fidget-Spinner left a 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.
This is really cool. I just have a few comments on readability. No idea why ASAN is failing tbh.
One other concern I have is that this slows down non-python function calls very slightly (with the two additional checks). I highly doubt it's measurable on pyperformance though.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Python/ceval.c Outdated
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.
Note to self, no need to pop frame here because it's done on eval frame exit at exit_eval_frame.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
pablogsal commented Sep 21, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I cannot reproduce the ASAN bug. :( |
98fced8 to 21b7d29CompareFidget-Spinner commented Sep 21, 2021
There're refleaks but I can't pinpoint where :( |
Ths commit inlines calls to Python functions in the eval loop and steals all the arguments in the call from the caller for performance.
21b7d29 to e1091e0Comparebedevere-bot commented Sep 29, 2021
🤖 New build scheduled with the buildbot fleet by @pablogsal for commit 0ddc46e25e4885562f7d1e962b9b30eea2b0283d 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
markshannon commented Sep 29, 2021
I hadn't realized the docs were so sparse. Probably best to do it in another PR. |
pablogsal commented Sep 29, 2021
@markshannon what do you think of 0ddc46e for now? I dislike this approach (is correct, but is difficult to reason about if you don't have the full picture in mind). Should we do the refactor now, should we do a smaller refactor or should we just do some celanup of 0ddc46e ? |
markshannon commented Sep 30, 2021
Just do the minimal cleanup of 0ddc46e that you are happy with for now. |
bedevere-bot commented Oct 7, 2021
🤖 New build scheduled with the buildbot fleet by @pablogsal for commit 1de88f6 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
pablogsal commented Oct 7, 2021
@markshannon I had to fix some merge conflicts and I have done the cleanup. I am building again with the buildbot fleet but this should be ready for a first version. |
bedevere-bot commented Oct 7, 2021
🤖 New build scheduled with the buildbot fleet by @pablogsal for commit f313e8c 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
Fidget-Spinner left a 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.
The C changes LGTM. Some minor formatting nits at https://github.com/python/cpython/pull/28488/files#r717573235 and below.
Huge disclaimer: I am not a Python-GDB expert! It would be better to have someone else reviewing those changes.
| PyObject*function=PEEK(oparg+1); | ||
| if (Py_TYPE(function) ==&PyFunction_Type){ | ||
| PyCodeObject*code= (PyCodeObject*)PyFunction_GET_CODE(function); | ||
| PyObject*locals=code->co_flags&CO_OPTIMIZED ? NULL : PyFunction_GET_GLOBALS(function); |
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.
The code from here onwards has waay more than 80 characters.
pablogsal commented Oct 7, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@Fidget-Spinner Thanks for the review! I am not going to push anything new until the buildbots pass to not restart the long refleak builds yet again. I will fix the formatting issues in a new PR unless @markshannon wants to change something fundamental (I also plan to rename the |
Fidget-Spinner commented Oct 7, 2021
I was just about to mention that. Good call! |
| // *valid* arguments (i.e. the ones that fit into the frame). | ||
| PyCodeObject*co= (PyCodeObject*)con->fc_code; | ||
| constPy_ssize_ttotal_args=co->co_argcount+co->co_kwonlyargcount; | ||
| for (Py_ssize_ti=0; i<Py_MIN(argcount, total_args); i++){ |
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.
GHA is warning:
comparison of integer expressions of different signedness: ‘Py_ssize_t’{aka ‘long int’} and ‘long unsigned int’ [-Wsign-compare and
'>': signed/unsigned mismatch [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj] | for (Py_ssize_ti=0; i<Py_MIN(argcount, total_args); i++){ | |
| for (size_ti=0; i<Py_MIN(argcount, (size_t)total_args); i++){ |
pablogsal commented Oct 9, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Cleanups happening here: #28836 @markshannon After that is merged, I will create a PR to address the counter to convert it to a "entry frame" flag. |
vstinner commented Oct 11, 2021
This is really cool, nice work @pablogsal ;-) |
https://bugs.python.org/issue45256