jvm-hotspot

unexplained 10%+ performance boost from simply adding a method argument (slimmer jit code)

泄露秘密 提交于 2021-02-17 19:13:07
问题 (note: proper answer must go beyond reproduction). After millions of invocations, quicksort1 is definitely faster than quicksort2, which have identical code aside from this 1 extra arg. The code is at the end of the post. Spoiler: I also found the jit code is fatter by 224 bytes even if it should be actually simpler (like the byte code size tells; see very last update below). Even after trying to factor out this effect with some microbenchmark harness (JMH), the performance difference is

unexplained 10%+ performance boost from simply adding a method argument (slimmer jit code)

[亡魂溺海] 提交于 2021-02-17 19:07:25
问题 (note: proper answer must go beyond reproduction). After millions of invocations, quicksort1 is definitely faster than quicksort2, which have identical code aside from this 1 extra arg. The code is at the end of the post. Spoiler: I also found the jit code is fatter by 224 bytes even if it should be actually simpler (like the byte code size tells; see very last update below). Even after trying to factor out this effect with some microbenchmark harness (JMH), the performance difference is

unexplained 10%+ performance boost from simply adding a method argument (slimmer jit code)

喜你入骨 提交于 2021-02-17 19:07:14
问题 (note: proper answer must go beyond reproduction). After millions of invocations, quicksort1 is definitely faster than quicksort2, which have identical code aside from this 1 extra arg. The code is at the end of the post. Spoiler: I also found the jit code is fatter by 224 bytes even if it should be actually simpler (like the byte code size tells; see very last update below). Even after trying to factor out this effect with some microbenchmark harness (JMH), the performance difference is

Oop gets corrupted when using in another JNI function

 ̄綄美尐妖づ 提交于 2021-02-05 08:55:28
问题 The question is can we cache jclass and jmethodID across different JNI methods invocation? I faced some strange behavior when trying to create an object of some specific class with cached jclass and jmethodID from another JNI method invocation. Here is a simple example: public class Main { static { System.loadLibrary("test-crash"); } public static void main(String args[]) throws InterruptedException { Thread.sleep(20000); doAnotherAction(doSomeAction()); } private static native long

Why does Unsafe.fullFence() not ensuring visibility in my example?

北城以北 提交于 2021-02-05 07:09:47
问题 I am trying to dive deep into volatile keyword in Java and setup 2 testing environments. I believe both of them are with x86_64 and use hotspot. Java version: 1.8.0_232 CPU: AMD Ryzen 7 8Core Java version: 1.8.0_231 CPU: Intel I7 Code is here: import java.lang.reflect.Field; import sun.misc.Unsafe; public class Test { private boolean flag = true; //left non-volatile intentionally private volatile int dummyVolatile = 1; public static void main(String[] args) throws Exception { Test t = new

Why does Unsafe.fullFence() not ensuring visibility in my example?

橙三吉。 提交于 2021-02-05 07:03:09
问题 I am trying to dive deep into volatile keyword in Java and setup 2 testing environments. I believe both of them are with x86_64 and use hotspot. Java version: 1.8.0_232 CPU: AMD Ryzen 7 8Core Java version: 1.8.0_231 CPU: Intel I7 Code is here: import java.lang.reflect.Field; import sun.misc.Unsafe; public class Test { private boolean flag = true; //left non-volatile intentionally private volatile int dummyVolatile = 1; public static void main(String[] args) throws Exception { Test t = new

-XX:+StressLCM, -XX:+StressGCM Options for JVM

≯℡__Kan透↙ 提交于 2021-02-04 17:14:05
问题 While playing with some jcstress code, I noticed two parameters that are very new to me: StressLCM and StressGCM . The very first thing to do for me was searching for these in the source code itself and while I have found some things, it is still unclear what they actually do. I was really hoping to see some comments in the source code that would shed some light, but no luck. I also found the bug description where these have been added, but the explanation made no sense for me: Randomize