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
8257692: Using both heap and native segments can degrade performance #413
8257692: Using both heap and native segments can degrade performance #413
Conversation
Add support for profiling of methods in MemoryAccess
|
Webrevs
|
src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/Utils.java
Outdated
Show resolved
Hide resolved
@mcimadamore This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been no new commits pushed to the
|
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.
Glad you all managed to resolve this.
It would be nice to mark the classes that have special profiling characteristics, otherwise it's easy to forgot or be unaware of the implications. Perhaps comments on each are sufficient. An annotation would be nice but is more work.
@PaulSandoz FWIW, I also looked into using an annotation to drive the profiling, instead of the special casing based on the name, but the problem is that we can't see the annotations of an unresolved method, so would have to resolve everything in the interpreter just to check for annotations. The current mechanism is solely based on the symbolic reference found in the caller's bytecode. |
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.
Looks good.
/integrate |
@mcimadamore Pushed as commit e367491. |
This patch fixes a problem with type profile pollution when segments of different kinds are used on the same memory access var handle, or on the same
MemoryAccess
static method.In principle, argument profiling should kick in for VarHandles and MethodHandles, and that should be enough at least to avoid pollution when using var handles directly. In reality, this is not the case; as Vlad discovered after relatively intense debugging session (thanks!), the VarHandle implementation code has to cast the incoming segment to the
MemorySegmentProxy
internal interface. This creates problems for C2, as concrete segment implementations have two interface types:MemorySegment
and the internalMemorySegmentProxy
class. Side casts from one to the other are not supported well, and can cause loss of type profiling infomation.To solve this problem we realized, in hindisght, that
MemorySegmentProxy
didn't really needed to be an interface and that it could easily be converted to an abstract class. Alone this solves 50% of the issues, since that makes direct var handle access robust to pollution issues. The remaining problems (using accessors inMemoryAccess
class) can be addressed the usual way, by adding argument type profiling for the methods in that class (similarly to what we've done forScopedMemoryAccess
).Here are some numbers before the patch:
As you can see there is quite a big difference between unsafe access and all the other modes. Here are the results after the patch:
That is, the situation is back to normal. Thanks to @JornVernee and @iwanowww for the help!
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/panama-foreign pull/413/head:pull/413
$ git checkout pull/413