8207765: HeapMonitorStatIntervalTest.java fails with ZGC
Add a calculation of array sizes before test to satisfy ZGC support Reviewed-by: amenkov, sspitsyn
This commit is contained in:
parent
4805473049
commit
a6ff367b24
@ -81,7 +81,6 @@ runtime/CompressedOops/UseCompressedOops.java 8079353 generic-all
|
|||||||
|
|
||||||
serviceability/sa/TestRevPtrsForInvokeDynamic.java 8191270 generic-all
|
serviceability/sa/TestRevPtrsForInvokeDynamic.java 8191270 generic-all
|
||||||
serviceability/sa/sadebugd/SADebugDTest.java 8163805 generic-all
|
serviceability/sa/sadebugd/SADebugDTest.java 8163805 generic-all
|
||||||
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatRateTest.java 8207765 generic-all
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
|
@ -102,13 +102,45 @@ public class HeapMonitor {
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static double averageOneElementSize;
|
||||||
|
private static native double getAverageSize();
|
||||||
|
|
||||||
|
// Calculate the size of a 1-element array in order to assess average sampling interval
|
||||||
|
// via the HeapMonitorStatIntervalTest. This is needed because various GCs could add
|
||||||
|
// extra memory to arrays.
|
||||||
|
// This is done by allocating a 1-element array and then looking in the heap monitoring
|
||||||
|
// samples for the average size of objects collected.
|
||||||
|
public static void calculateAverageOneElementSize() {
|
||||||
|
enableSamplingEvents();
|
||||||
|
// Assume a size of 24 for the average size.
|
||||||
|
averageOneElementSize = 24;
|
||||||
|
|
||||||
|
// Call allocateSize once, this allocates the internal array for the iterations.
|
||||||
|
int totalSize = 10 * 1024 * 1024;
|
||||||
|
allocateSize(totalSize);
|
||||||
|
|
||||||
|
// Reset the storage and now really track the size of the elements.
|
||||||
|
resetEventStorage();
|
||||||
|
allocateSize(totalSize);
|
||||||
|
disableSamplingEvents();
|
||||||
|
|
||||||
|
// Get the actual average size.
|
||||||
|
averageOneElementSize = getAverageSize();
|
||||||
|
if (averageOneElementSize == 0) {
|
||||||
|
throw new RuntimeException("Could not calculate the average size of a 1-element array.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int allocateSize(int totalSize) {
|
public static int allocateSize(int totalSize) {
|
||||||
|
if (averageOneElementSize == 0) {
|
||||||
|
throw new RuntimeException("Average size of a 1-element array was not calculated.");
|
||||||
|
}
|
||||||
|
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
|
|
||||||
// Let us assume that a 1-element array is 24 bytes.
|
int iterations = (int) (totalSize / averageOneElementSize);
|
||||||
int iterations = totalSize / 24;
|
|
||||||
|
|
||||||
if (arrays == null) {
|
if (arrays == null || arrays.length < iterations) {
|
||||||
arrays = new int[iterations][];
|
arrays = new int[iterations][];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,9 +33,6 @@ package MyPackage;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class HeapMonitorStatIntervalTest {
|
public class HeapMonitorStatIntervalTest {
|
||||||
|
|
||||||
private native static double getAverageInterval();
|
|
||||||
|
|
||||||
private static boolean testIntervalOnce(int interval, boolean throwIfFailure) {
|
private static boolean testIntervalOnce(int interval, boolean throwIfFailure) {
|
||||||
HeapMonitor.resetEventStorage();
|
HeapMonitor.resetEventStorage();
|
||||||
HeapMonitor.setSamplingInterval(interval);
|
HeapMonitor.setSamplingInterval(interval);
|
||||||
@ -84,6 +81,8 @@ public class HeapMonitorStatIntervalTest {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int[] tab = {1024, 8192};
|
int[] tab = {1024, 8192};
|
||||||
|
|
||||||
|
HeapMonitor.calculateAverageOneElementSize();
|
||||||
|
|
||||||
for (int intervalIdx = 0; intervalIdx < tab.length; intervalIdx++) {
|
for (int intervalIdx = 0; intervalIdx < tab.length; intervalIdx++) {
|
||||||
testInterval(tab[intervalIdx]);
|
testInterval(tab[intervalIdx]);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#define PRINT_OUT 1
|
#define PRINT_OUT 0
|
||||||
|
|
||||||
static jvmtiEnv *jvmti = NULL;
|
static jvmtiEnv *jvmti = NULL;
|
||||||
static jvmtiEnv *second_jvmti = NULL;
|
static jvmtiEnv *second_jvmti = NULL;
|
||||||
@ -369,7 +369,7 @@ static int event_storage_get_count(EventStorage* storage) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double event_storage_get_average_interval(EventStorage* storage) {
|
static double event_storage_get_average_size(EventStorage* storage) {
|
||||||
double accumulation = 0;
|
double accumulation = 0;
|
||||||
int max_size;
|
int max_size;
|
||||||
int i;
|
int i;
|
||||||
@ -974,8 +974,8 @@ Java_MyPackage_HeapMonitorIllegalArgumentTest_testIllegalArgument(JNIEnv *env,
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jdouble JNICALL
|
JNIEXPORT jdouble JNICALL
|
||||||
Java_MyPackage_HeapMonitorStatIntervalTest_getAverageInterval(JNIEnv *env, jclass cls) {
|
Java_MyPackage_HeapMonitor_getAverageSize(JNIEnv *env, jclass cls) {
|
||||||
return event_storage_get_average_interval(&global_event_storage);
|
return event_storage_get_average_size(&global_event_storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct sThreadsFound {
|
typedef struct sThreadsFound {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user