You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Get rid of conditional inputs and outputs for instructions in bytecodes.c #128914
We should remove the conditional stack effects in instruction definitions in bytecodes.c
Conditional stack effects already complicate code generation and that is only going to get worse with top-of-stack caching and other interpreter/JIT optimizations.
There were two reasons for having conditional stack effects:
Ease of porting the old ceval code to bytecodes.c
Performance
Reason 1 no longer applies. Instructions are much more regular now and it isn't that much work to remove the remaining conditional stack effects.
That leaves performance. I experimentally removed the conditional stack effects for LOAD_GLOBAL and LOAD_ATTR which is the worse possible case for performance as it makes no attempt to mitigate the extra dispatch costs and possibly worse specialization.
The results are here
Overall we see a 0.8% slowdown. It seems that specialization is not significantly worse, but there is a large increase in PUSH_NULL following LOAD_GLOBAL that appears to responsible for the slowdown. An extra specialization should fix that.
It seems that #128918 caused a 2-3% slowdown on the free-threading build.
FWIW, I couldn't reproduce this on our infrastructure. I'm not claiming one is better or more reliable, only that the effect being noticed here might be more complicated...
Activity
picnixz commentedon Jan 17, 2025
(Tagging it as a
performancechange even though we would end up with a slowdown. However, this is still something that is performance-related)GH-128914: Remove conditional stack effects from `bytecodes.c` and th…
pythonGH-128914: Remove conditional stack effects from `bytecodes.c` …
Revert "pythonGH-128914: Remove conditional stack effects from `bytec…
Revert "pythonGH-128914: Remove conditional stack effects from `bytec…
Revert "GH-128914: Remove conditional stack effects from `bytecodes.c…
markshannon commentedon Jan 23, 2025
It seems that #128918 caused a 2-3% slowdown on the free-threading build.
mdboom commentedon Jan 23, 2025
FWIW, I couldn't reproduce this on our infrastructure. I'm not claiming one is better or more reliable, only that the effect being noticed here might be more complicated...
GH-128914: Remove all but one conditional stack effects (GH-129226)
markshannon commentedon Jan 28, 2025
Latest implementation has no adverse impact on performance.