-
Notifications
You must be signed in to change notification settings - Fork 176
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
Micro-optimize P6opaque's get_attribute() #1884
Micro-optimize P6opaque's get_attribute() #1884
Conversation
Huh, no CI? |
"Workflow runs completed with no jobs" ?? @patrickbkr @timo ?? |
sorry my fault for the commit i accidentally pushed to the main branch yesterday |
Also, here's a little bit of logging of what happens during a CORE.c compile (8 is obj, 4 is int64, and 7 is str).
I believe a lot of the calls to |
I know the jit can devirtualize these in some instances, but since I don't have the jit on this hardware, I'm now wondering if spesh can be made to do anything. |
Instead of checking `attr_st` inside each case of the `switch(kind)`, have an if/else for attr_st with a switch in each branch.
f04d3c1
to
a7dcba0
Compare
spesh can turn getattr_* into different kinds of sp_get* instructions, which don't require jit compilation to give a nice speedup. we could look at spesh logs to find places where the getattr_* remains in the "After" result to see if we spot anything that sticks out that we could optimize better? there's also the case of getattr with a string for the attribute name, in which case spesh can't do anything if the attribute name isn't known at spesh time, though in theory we could have strings that have been seen logged and code-gen a string comparison and "specialized" branch with an optimized getattr variant. Would need to do some measurements to see what the opportunities are Edit: From a quick look at like 0.1% of the spesh log from core.c.setting compilation we're very often not sure what the type is of the object we're getting the attribute from. Maybe the thing above with the name not being known is a very small portion and we mostly have the name but aren't sure about the type. Also, in the spesh log we can't see which of the cases we don't optimize run often or rarely, so we would also want to count them from the actual run |
I have a 1.6gb spesh log of compiling CORE.c. There are ~2.3k getattr_* remaining in the 'After:' of >300 functions. Here's a random example from 'MATCH':
|
The count of the types of getattr:
|
Is this PR good to go as is? |
I think so. I believe it'll also generate slightly faster code on x86, but we could always merge now and I'll confirm that when I have access to my desktop again in a couple days. |
Instead of checking
attr_st
inside each case of theswitch(kind)
, have an if/else for attr_st with a switch in each branch.On this laptop, it seemed to reduce the instructions and time for compiling CORE.d and CORE.e (I didn't try CORE.c since that would have taken way too long under valgrind). I don't have access to my x86 desktop right now, and since this optimization seems like it will very likely be compiler-dependent, maybe @timo you could test it?