-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Add BRANCH_TAKEN and BRANCH_NOT_TAKEN events to sys.monitoring #122548
Comments
The interactions between So, here's the updated proposal:
This is still fully backwards compatible, and will allow us to implement |
If I try to just use the old
|
Fixed. |
Ah, sorry about that! Ironically, that's what I intended by reporting it here -- but it was the code in #122564 that I saw that on. |
Since monitoring shouldn't impact performance when not used, we don't want to restrict the bytecode compiler in its optimizations, or how it lays out code. With that in mind, I think we need to drop the "taken"/"not taken" labels and use something like "left" and "right". In the code: if cond:
x
y It could be surprising if the branch from I therefore proposed renaming |
Ok! I've modified my code, so as far as I'm concerned, you can remove the taken/not_taken names. |
Continuing from #122564 (comment) and #122564 (comment)
Maybe first we should decide: from the user's point of view, does line 1 have two possible destinations (line 2 and line 3) or does it not? Should line 1 be considered a branch for the purposes of branch coverage? If we can't map the collected data back to a user-understandable interpretation, then we haven't finished the feature. Can you help me puzzle through this? I'd like to get efficient branch coverage measurement. So far, we seem to be talking about different things (byte codes vs lines) and we aren't meeting in the middle. |
Correct magic number comment
|
(Moved here from #128445 (comment)) Two more examples of branch event surprises. run_sysmon.py is used to see the sys.monitoring events. These are using commit cbe6c7c from PR #128445. ifdebug.pyfor value in [True, False]:
if value:
if __debug__:
x = 4
else:
x = 6 Disassembled:
Events:
The starred line is a BRANCH event from a NOT_TAKEN instruction. 1176_async.pyimport asyncio
async def async_gen():
yield 4
async def async_test():
async for i in async_gen():
print(i + 8)
asyncio.run(async_test()) Disassembled:
Events:
Here there are no BRANCH events at all. I would expect some for the |
Correct magic number comment
Feature or enhancement
Proposal:
Proposal:
BRANCH_TAKEN
andBRANCH_NOT_TAKEN
events tosys.monitoring
BRANCH
event (as it will be redundant)BRANCH
events implicitly monitors both theBRANCH_TAKEN
andBRANCH_NOT_TAKEN
eventsBRANCH_TAKEN
event will implicitly disable the matchingBRANCH
event, but only for the taken branchBRANCH_NOT_TAKEN
event will implicitly disable the matchingBRANCH
event, but only for the not-taken branchBRANCH
event will implicitly disable the both the matchingBRANCH_TAKEN
andBRANCH_NOT_TAKEN
eventsThis is fully backwards compatible.
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
Discussion which also links to prior discussions.
Linked PRs
Tasks
match
cases showing incorrectly #123044None
#123048for
loop not showing correctly #123050FOR_ITER
is poor asDISABLE
doesn't remove the instrumentation. #128375NOT_TAKEN
instructions need to be added after optimization #128533async for
#128534The text was updated successfully, but these errors were encountered: