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

gh-112287: Speed up Tier 2 (uop) interpreter a little #112286

Merged
merged 25 commits into from
Nov 20, 2023

Conversation

gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Nov 20, 2023

This makes the Tier 2 interpreter a little faster.
I calculated by about 3%,
though I hesitate to claim an exact number.

This starts by doubling the trace size limit (to 512),
making it more likely that loops fit in a trace.

The rest of the approach is to only load
oparg and operand in cases that use them.
The code generator know when these are used.

For oparg, it will conditionally emit

oparg = CURRENT_OPARG();

at the top of the case block.
(The oparg variable may be referenced multiple times
by the instructions code block, so it must be in a variable.)

For operand, it will use CURRENT_OPERAND() directly
instead of referencing the operand variable,
which no longer exists.
(There is only one place where this will be used.)

@gvanrossum gvanrossum changed the title SPeed up Tier 2 (uop) interpreter abut 3% Speed up Tier 2 (uop) interpreter about 3% Nov 20, 2023
This prepares us for the JIT template, hopefully.
@gvanrossum gvanrossum changed the title Speed up Tier 2 (uop) interpreter about 3% gh-112287: Speed up Tier 2 (uop) interpreter about 3% Nov 20, 2023
@gvanrossum gvanrossum changed the title gh-112287: Speed up Tier 2 (uop) interpreter about 3% gh-112287: Speed up Tier 2 (uop) interpreter a little Nov 20, 2023
@gvanrossum gvanrossum marked this pull request as ready for review November 20, 2023 18:38
@gvanrossum
Copy link
Member Author

Based on off-line discussion I assume I can just merge this once the tests pass.

@gvanrossum gvanrossum merged commit 8deb8bc into python:main Nov 20, 2023
29 checks passed
@gvanrossum gvanrossum deleted the faster-uops branch November 20, 2023 19:25
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…12286)

This makes the Tier 2 interpreter a little faster.
I calculated by about 3%,
though I hesitate to claim an exact number.

This starts by doubling the trace size limit (to 512),
making it more likely that loops fit in a trace.

The rest of the approach is to only load
`oparg` and `operand` in cases that use them.
The code generator know when these are used.

For `oparg`, it will conditionally emit
```
oparg = CURRENT_OPARG();
```
at the top of the case block.
(The `oparg` variable may be referenced multiple times
by the instructions code block, so it must be in a variable.)

For `operand`, it will use `CURRENT_OPERAND()` directly
instead of referencing the `operand` variable,
which no longer exists.
(There is only one place where this will be used.)
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…12286)

This makes the Tier 2 interpreter a little faster.
I calculated by about 3%,
though I hesitate to claim an exact number.

This starts by doubling the trace size limit (to 512),
making it more likely that loops fit in a trace.

The rest of the approach is to only load
`oparg` and `operand` in cases that use them.
The code generator know when these are used.

For `oparg`, it will conditionally emit
```
oparg = CURRENT_OPARG();
```
at the top of the case block.
(The `oparg` variable may be referenced multiple times
by the instructions code block, so it must be in a variable.)

For `operand`, it will use `CURRENT_OPERAND()` directly
instead of referencing the `operand` variable,
which no longer exists.
(There is only one place where this will be used.)
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.

1 participant