-
Notifications
You must be signed in to change notification settings - Fork 51
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
Reduce the overhead of tracing, profiling and quickening checks for calls. #112
Comments
python/cpython#29575 is prep for this. |
I took a stab at implementing this; not sure yet if I haven't made a silly mistake (as I don't have an intuitive understanding of the whole compilation/evaluation machinery at this point, and need to play with this thing a little bit more to see if the changes in quickening are actually working as I expect them to.) Changes can be seen in my personal fork. (NB: There are a few commits that aren't strictly related to this change, but they're just cleaning some stuff up.) One of the things that are missing at this point is avoiding evaluating the |
Cool to see this. The issue with setting |
Should we assign this issue to @lpereira and move it to her column on the project board? |
We now have a Instrumentation should be precise and quick if we want tracing and profiling to perform well. |
Good point. This would keep the semantics the same, right? |
Deferring the remainder of this issue (eliminating overhead of tracing, when not tracing) until 3.12a0 (which is only a month way now). There are two issues that will need a bit of wider discussion:
|
I suppose you need to crawl the stack to find them all. But do you need to do anything for generators that are currently suspended (i.e. waiting for Would it be crazy to do the patchup for regular functions upon returning rather than at the time |
Not crazy at all, but I couldn't make it efficient as it requires a check in too many places. |
What's re-entrant code in this context? Generators? |
Any function can be re-entrant. I think it should be possible to make it work just marking certain instructions as "pending instrumentation", but it there are too many corner cases for me to be confident that it would be correct. |
Got it. So then I ask again, what about suspended generators? They're not on any stack IIUC. |
Suspended generators aren't on any stack, so we ignore them. |
Okay, I guess I don't understand the reason we need to "instrument all code objects currently being executed when changing the profiling or tracing function." Probably because I haven't thought enough about the requirements that lead to the implementation. I'll come back when I've had time to think about that. |
I'm postponing this until PEP 669 has been accepted or rejected. |
PEP 669 has been accepted, so instrumentation will be implemented as part of that PEP. |
When entering a Python function we need to check for tracing/profiling and check to see if the function needs to be quickened.
We should be able to eliminate these checks for calls in most cases by:
START_FUNCTION
instruction which does the above checks.START_FUNCTION
to aNOP
.f_lasti
to 0 not -1, thus skipping the entry sequence entirely.When exiting a function, we still need to check for tracing and profiling. This can be eliminated by adding a
RETURN_VALUE_QUICK
bytecode that skips the checks.The text was updated successfully, but these errors were encountered: