-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix: db-shootout benchmark. #3570
Conversation
Hello jovanstevanovic, thanks for contributing a PR to our project! We use the Oracle Contributor Agreement to make the copyright of contributions clear. We don't have a record of you having signed this yet, based on your email address jovan -(dot)- stevanovic1 -(at)- outlook -(dot)- com. You can sign it at that link. If you think you've already signed it, please comment below and we'll check. |
@@ -58,6 +58,7 @@ | |||
internalCallerFilter.addOrGetChildren("com.sun.nio.zipfs.**", RuleNode.Inclusion.Exclude); | |||
internalCallerFilter.addOrGetChildren("java.io.**", RuleNode.Inclusion.Exclude); | |||
internalCallerFilter.addOrGetChildren("java.lang.**", RuleNode.Inclusion.Exclude); | |||
internalCallerFilter.addOrGetChildren("java.lang.ClassLoader$NativeLibrary", RuleNode.Inclusion.Include); |
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.
Comment why.
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.
Done.
@@ -218,7 +218,7 @@ private static Object replaceAccessControlContext(Object obj) { | |||
@NeverInline("Starting a stack walk in the caller frame") | |||
protected Class<?>[] getClassContext() { | |||
final Pointer startSP = readCallerStackPointer(); | |||
return StackTraceUtils.getClassContext(1, startSP); | |||
return StackTraceUtils.getClassContext(0, startSP); |
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.
Why? Or why it was?
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.
One of the reasons this benchmark didn't work was that stacktrace was not equal to the one on java, and it was not equal because we are skipping the first frame. (https://github.com/java-native-access/jna/blob/d367f0220be55b5638b3d324473ef0a7e654d83c/src/com/sun/jna/Native.java#L1516 in this line of code benchmark is accessing caller class and it was shifted by one in NI)
assertSame(StackTraceTests.class, classes[0]); | ||
assertTrue(classes.length > 1); | ||
assertSame(StackTraceTests.class, classes[1]); | ||
assertTrue(classes.length > 2); |
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.
Is this the same as in Java now?
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.
Now it's the same. It can be simply tested by starting db-shootout
benchmark (command is in PR 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.
We need to run these JUnit tests on the HotSpot VM too as part of the gate runs.
Also testing more cases would be good.
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 created a small reproducer for this problem here: https://github.com/jovanstevanovic/DBShootoutException, to confirm the exact same behavior of my changes on both hotspot and ni.
Agree, we should expand this test.
be1ff5f
to
7101152
Compare
@@ -123,7 +124,8 @@ public static boolean shouldShowFrame(FrameInfoQueryResult frameInfo, boolean sh | |||
|
|||
if (!showReflectFrames && ((clazz == java.lang.reflect.Method.class && "invoke".equals(frameInfo.getSourceMethodName())) || | |||
(clazz == java.lang.reflect.Constructor.class && "newInstance".equals(frameInfo.getSourceMethodName())) || | |||
(clazz == java.lang.Class.class && "newInstance".equals(frameInfo.getSourceMethodName())))) { | |||
(clazz == java.lang.Class.class && "newInstance".equals(frameInfo.getSourceMethodName())) || | |||
(clazz == ClassInitializationInfo.class))) { |
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.
No, I don't think we can do it that way. What are the failing cases here? What does ClassInitializationInfo
have to do with reflection?
What you probably want is to annotate ClassInitializationInfo
with InternalVMMethod
, so that our internal class initialization logic is ignored in most stack walk. But that needs careful testing.
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.
Yes, that is what I'm trying to achieve, to ignore ClassInitializationInfo
during stack walk. I'll try with InternalVMMethod
annotation.
assertSame(StackTraceTests.class, classes[0]); | ||
assertTrue(classes.length > 1); | ||
assertSame(StackTraceTests.class, classes[1]); | ||
assertTrue(classes.length > 2); |
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.
We need to run these JUnit tests on the HotSpot VM too as part of the gate runs.
Also testing more cases would be good.
898251b
to
3059c86
Compare
3059c86
to
a1cbf43
Compare
Stacktraces:
After solving a problem with loading native library, the next problem occurred:
Command to reproduce (benchmark):
mx --env ni-ce benchmark renaissance-native-image:db-shootout -- --jvm=native-image --jvm-config=default-ce
Link to simple reproducer:
https://github.com/jovanstevanovic/DBShootoutException