-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-115168: Add pystats counter for invalidated executors #115169
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
gh-115168: Add pystats counter for invalidated executors #115169
Conversation
Does this count executors that are invalidated during interpreter shutdown, or have we turned off stats by then? |
Good call out. In the "normal" case where the user has turned on pystats directly, it would include the invalidations at shutdown, which are really teardowns, not invalidations. In the context of pyperformance and how we run benchmarks in our infrastructure, which turns pystats on/off around the benchmarking code, teardowns would be excluded from the number. (So the numbers I shared here should be correct). I suppose the better option would be to count these one layer up where we know why the executors are being invalidated. |
I've updated this to be more precise about when something is an invalidation vs. just a deallocation. |
Python/optimizer.c
Outdated
@@ -1161,7 +1164,21 @@ _Py_Executors_InvalidateAll(PyInterpreterState *interp) | ||
exec->vm_data.valid = false; | ||
exec->vm_data.linked = false; | ||
exec = next; | ||
OPT_STAT_INC(executors_invalidated); |
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.
We still want stats for this, as it can be called when the builtins are modified, or other rare events.
Maybe add a flag parameter to distinguish between shutdown and actual invalidation?
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.
My approach was to move the counters to the callers, rather than a flag (but a flag is fine too if you prefer). In either case, it looks like I missed _PyInterpreterState_SetEvalFrameFunc
: This counter should also be incremented there.
c5de632
to
db58a2f
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.
Looks good, thanks.
@markshannon: This has had the merge conflicts fixed and is ready to merge. |
Counting when executors are invalidated seems like a useful statistic to have (see this discussion).