-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Split frame fields to reduce pre/post logic #4905
Conversation
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.
Already addressed my concerns offline. This is good stuff.
So, the basic premise here is that the only source of use of some of the frame fields comes from the ruby stdlib, and for the JRuby impls in Java, those can be annotated, and optimized around. Looks like this PR is asserting that this claim is true for the backref field. Are there any frame fields where that premise doesn't hold? |
i.e. can non-stdlib ruby methods directly (vs indirectly via use of stdlib methods) affect use of any of these frame fields? |
@subbuss Non-stdlib methods could only affect this if they were also defined in Java and annotated to access these fields. We do update the list of methods that might need frame fields as they are defined, so if a third-party lib has a JRuby extension and some methods that need frame, the list of "might need a frame" method names will get updated. However this is obviously timing-sensitive. I chatted with @enebo about ways to mitigate this risk. The main potential problem with this PR is the following scenario:
This requires a lot of things to align. The most likely way to have a method call that needs framing but doesn't get it is to alias one of the core methods. This is done rarely, since aliasing is usually used to wrap a method, and you can't wrap methods that access the caller's frame. The other way to trigger this problem is as you mentioned, a third-party library that is using our annotations. |
I see, so default in the absence of annotations is requiring the full frame? That default question comes from: can a pure ruby method have code that can affect use of any frame field? I suppose that only applies to the backref field since that is the only one you opt right now. |
@subbuss It is not possible for pure Ruby code to access the caller's frame unless it is passed a binding or closure (which can be turned into a binding). |
To clarify...a method can certainly have its own calls to |
Ah, right. I forgot that detail .. been a while. :) Didn't look at the code closely, but the idea lgtm. |
Also cleaned up concurrent access to these structures.
One of the primary perf hits in JRuby comes from methods that need a method frame to store data for downstream calls. An example: because there's one
[]
method in the system that needs to write the "backref" frame field, any method that calls[]
on any type needs to have "backref" storage available.Unfortunately, there's problems with how we manage this now:
This PR starts the process of splitting frame push/pop logic to be more fine-grained, allowing for initializing only the parts of the frame we need.
At the moment, this PR does the following:
In experiments, for a method that contains a call to
[]
but otherwise does nothing, 30 million calls (in JIT) improve from 0.33s down to 0.08s or so, around 4x faster by removing unnecessary frame overhead.