-
-
Couldn't load subscription status.
- Fork 47
perf: improve general performance #172
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
base: main
Are you sure you want to change the base?
perf: improve general performance #172
Conversation
d1eec34 to
abd3d1d
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #172 +/- ##
==========================================
- Coverage 95.43% 91.49% -3.94%
==========================================
Files 7 7
Lines 2147 2164 +17
Branches 481 489 +8
==========================================
- Hits 2049 1980 -69
- Misses 56 122 +66
- Partials 42 62 +20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Thanks for starting this, just one small question. Also you may need some convincing for Mypy to be happy with you without all the assertions.
| BITFLAG2_OPCODES = (_opcode.opmap["LOAD_SUPER_ATTR"],) if PY312 else () | ||
| BITFLAG2_OPCODES = {_opcode.opmap["LOAD_SUPER_ATTR"]} if PY312 else set() |
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.
Out of curiosity do you have a micro-benchmark for this. It is not obvious to me that for a single element a set is faster ?
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.
The core of the performance gains come from caching and avoiding some of the more expensive asserts. These small sets are more for type coherence than anything else. I have the feeling that all the branching that is done at runtime is also a main "offender" performance-wise. It would be great if sys.version_info checks could be done just once at compile time, possibly at the cost of copy-pasting the same code. I'll see if there are any other low-hanging fruits that we can pick
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.
In fact I've got a pretty decent improvement when turning HASJREL etc... into sets. I'll post some benchmarking notes in the description.
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.
I agree that I would love to have the equivalent of compile time specialization.
We try to use sets for quick lookups and cache the result of some repetitive operations to speed up some operations. We also remove a good deal of asserts embedded within the code that adde extra overhead.
abd3d1d to
7ac2792
Compare
We try to use sets for quick lookups and cache the result of some repetitive operations to speed up some operations. We also remove a good deal of asserts embedded within the code that adde extra overhead. Where appropriate, these should be replaced with actual tests.
The current change squeezes about 3/4% performance from a decompile/recompile loop.
Benchmarking
The following round-trip script has been used to benchmark the performance of the proposed changes
Baseline: 1.10 +/- 0.02
This PR: 1.03 +/- 0.02