X Tutup
The Wayback Machine - https://web.archive.org/web/20221223152413/https://github.com/python/cpython/pull/25276
Skip to content
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

bpo-43760: Speed up check for tracing in interpreter dispatch #25276

Merged
merged 6 commits into from Apr 13, 2021

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Apr 8, 2021

The code to check if tracing is active occurs once per opcode in the interpreter and is executed in the order of 100 million times per second. It needs to be as efficient as possible. It cannot be kept in a register as it needs to be modified outside of the interpreter, so on the C stack is the fastest possible location for it.

This PR keeps use_tracing in the C frame of the current interpreter making the check for tracing as fast as possible.

Doing so complicates access to use_tracing from other code and requires us to be careful about maintaining stack discipline.
For anything less performance critical than use_tracing this probably wouldn't be worth it, but as use_tracing is so performance critical it is worth it.

https://bugs.python.org/issue43760

@markshannon markshannon added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 8, 2021
@bedevere-bot
Copy link

bedevere-bot commented Apr 8, 2021

🤖 New build scheduled with the buildbot fleet by @markshannon for commit 5ba8650 🤖

If you want to schedule another build, you need to add the "🔨 test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 8, 2021
@markshannon markshannon requested a review from gvanrossum Apr 9, 2021
@markshannon markshannon merged commit 9e7b207 into python:master Apr 13, 2021
11 checks passed
@bedevere-bot
Copy link

bedevere-bot commented Apr 13, 2021

@markshannon: Please replace # with GH- in the commit message next time. Thanks!

@markshannon markshannon deleted the faster-tracing-test branch Apr 14, 2021
tacaswell added a commit to tacaswell/greenlet that referenced this pull request Apr 30, 2021
kreathon pushed a commit to kreathon/cpython that referenced this pull request May 2, 2021
…#25276)

* Remove redundant tracing_possible field from interpreter state.

* Move 'use_tracing' from tstate onto C stack, for fastest possible checking in dispatch logic.

* Add comments stressing the importance stack discipline when dealing with CFrames.

* Add NEWS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants
X Tutup