RFR: 8177968: Add GC stress test TestGCLocker

Per Liden per.liden at oracle.com
Wed Apr 12 05:53:12 UTC 2017


Hi Erik,

On 2017-04-07 17:48, Erik Helin wrote:
> Hi all,
>
> this patch adds the stress test "TestGCLocker". The test repeatedly
> calls GCLocker::lock_critical/unlock_critical (via the JNI functions
> GetPrimitiveArrayCritical/ReleasePrimitiveArrayCritical) while
> concurrently filling up the old gen. Thea idea is to stress the GCLocker
> implementation by quickly entering/leaving critical JNI sections while
> simultaneously allocating objects to fill up the heap in order to
> provoke a GC.
>
> Enhancement:
> https://bugs.openjdk.java.net/browse/JDK-8177968
>
> Patch:
> http://cr.openjdk.java.net/~ehelin/8177968/00/

I did some test runs and it seems that this test provokes the wanted 
situation in only ~20% of the GC. Being a stress test, I'd like to 
propose that we remove the sleep() calls to have it provoke the 
situation ~100% of the GCs.

--- a/test/gc/stress/gclocker/TestGCLocker.java
+++ b/test/gc/stress/gclocker/TestGCLocker.java
@@ -162,7 +153,6 @@

          while (!shouldExit()) {
              load();
-            ThreadUtils.sleep(100);
          }
      }
  }
@@ -175,7 +165,6 @@
          byte[] array = new byte[1024 * 1024];
          while (!shouldExit()) {
              fillWithRandomValues(array);
-            ThreadUtils.sleep(10);
          }
      }
  }


Also, I think the filler function doesn't do what it says as it only 
writes to the first byte. Simple fix:

--- a/test/gc/stress/gclocker/libTestGCLocker.c
+++ b/test/gc/stress/gclocker/libTestGCLocker.c
@@ -29,7 +29,7 @@
    jbyte* p = (*env)->GetPrimitiveArrayCritical(env, arr, NULL);
    jsize i;
    for (i = 0; i < size; i++) {
-      *p = i % 128;
+    p[i] = i % 128;
    }
    (*env)->ReleasePrimitiveArrayCritical(env, arr, p, 0);
  }


cheers,
Per

>
> Testing:
> - JPRT (to ensure libTestGCLocker.c compiles on all platforms)
> - make run-test TEST=hotspot/test/gc/stress/gclocker
>
> Thanks,
> Erik



More information about the hotspot-gc-dev mailing list