Skip to content

gh-134584: Decref elimination for float ops in the JIT #134588

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented May 23, 2025

The key idea is to remove decref of inputs of common operations in the JIT, if they are deemed to be borrowed/using borrowed refcounts. We rely on the base interpreter's static analysis to determine if things are borrowed.

For the float operations, these can't be generated using the cases generator, because they use the FromDoubleConsumeFloat things which are not DECREF_INPUT.

For the other list/tuple stuff, or anything that use DECREF_INPUTs, we can automatically generate the instruction variants by not emitting the decref at all. However, I left that out of this PR as this is the initial proof of concept

JIT without these optimizations:
nbody: Mean +- std dev: 106 ms +- 3 ms

JIT with decref optimizations (this branch at 7f90d0cf7357b2b703110c685311fbac5f317ac1):
nbody: Mean +- std dev: 98.1 ms +- 2.5 ms

interpreter (no JIT):
nbody: Mean +- std dev: 90.2 ms +- 0.9 ms

Roughly a 7.5% speedup on nbody just from these optimizations alone!

It's still slower than the normal interpreter on my system, but it's a good start.

I removed the list ops at ad03b1e to make the PR easier to review, we can add them back in later for the speed boost!

@Fidget-Spinner Fidget-Spinner changed the title Decref elimination floats gh-134584: Decref elimination for float ops in the JIT May 23, 2025
@Fidget-Spinner
Copy link
Member Author

@tomasr8 @brandtbucher 7.5% speedup in nbody on the JIT in this PR 👀. I removed some of the optimizations in this PR to make things easier to review, and also to split up work later!

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

Successfully merging this pull request may close these issues.

1 participant