FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-36616: optimize handling of thread state in function call code by jdemeyer · Pull Request #12839 · python/cpython · GitHub

/ cpython Public

bpo-36616: optimize handling of thread state in function call code - #12839

Closed
jdemeyer wants to merge 1 commit into
python:masterfrom
jdemeyer:bpo36616
Closed

bpo-36616: optimize handling of thread state in function call code#12839
jdemeyer wants to merge 1 commit into
python:masterfrom
jdemeyer:bpo36616

Conversation

jdemeyer commented Apr 15, 2019
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor

Thanks to @markshannon for the idea.

This does various micro-optimizations for function calls in the bytecode interpreter to give a small increase in performance.

https://bugs.python.org/issue36616

jdemeyer changed the title Optimize handling of thread state in function call code bpo-36616: optimize handling of thread state in function call code Apr 15, 2019

scoder left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'd say, why not, but would also like to see at least some timings.

Comment thread Python/ceval.c
PyObject **sp, *res;
sp = stack_pointer;
res = call_function(&sp, oparg, NULL);
stack_pointer = sp;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

These stack pointer assignments look a bit like someone left them for documentation purposes, trying to make it clear what is allowed/supposed to happen with the pointer that is passed down.
I''m not saying that it's wrong to remove these assignments, just that Chesterton's Fence might apply.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Those strange redirections were added because somebody wanted to use

register PyObject **stack_pointer;

and it's illegal to take the address of a register variable. But the register keyword is obsolete, compilers are now much more clever than they were before. Also, call_function() should be inlined and then the pointer isn't even a real pointer.

Copy link
Copy Markdown
Contributor Author

I did some more extensive benchmarks today and I'm no longer convinced that this actually improves anything. In any case, the gain would be very close to the measurement error and not significant.

Parts of this could still make sense as a "clean up" patch, for example the strange assignment of stack_pointer around call_function(). But I don't want to fight that battle, so I'll just close this.

Copy link
Copy Markdown
Member

See also my PR #12934.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL