-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-107674: Improve performance of sys.settrace
#114986
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
Merged
markshannon
merged 10 commits into
python:main
from
gaogaotiantian:sys-settrace-optimize
Feb 28, 2024
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6e53f53
Improve performance of sys.settrace
gaogaotiantian a42d7c8
📜🤖 Added by blurb_it.
blurb-it[bot] d5b1dec
Do not instrument code when tracing
gaogaotiantian 2a1eefb
Reduce extra branch and save some operations
gaogaotiantian cb09c55
Change the comment to assertion
gaogaotiantian 410a07a
Merge branch 'main' into sys-settrace-optimize
gaogaotiantian 74d3375
Add missing instr change
gaogaotiantian 47ff554
Do not deopt RESUME_CHECK if it's tracing
gaogaotiantian 79f43b9
Regen executor_cases
gaogaotiantian 0c72ada
Clean up bytecode code
gaogaotiantian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Core and Builtins/2024-02-04-07-45-29.gh-issue-107674.q8mCmi.rst
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Improved the performance of :func:`sys.settrace` significantly |
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Because
RESUME
converts itself toRESUME_CHECK
, this shouldn't matter in terms of performance, so maybe keep it simple?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.
Ah I remembered why I did not set this instr to
RESUME_CHECK
whentracing != 0
- it will convert this instr toRESUME_CHECK
butRESUME_CHECK
will be deopted as the version does not add up.For your question - the key is to stop the code from being instrumented, removing this check will still result in an instrumented code, and instrumented code is always slower.
However, we should probably check if the code is tracing and do not deopt
RESUME_CHECK
if so.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.
Another way to do this is to
DISPATCH()
in the instrument case, so we don't have to write the "normal" case twice. Is it frown upon to have multipleDISPATCH()
in one bytecode?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.
Multiple
DISPATCH()
s should be fine.