Skip to content

Commit

Permalink
Add Xgc options for suballocator heap size and quick allocation
Browse files Browse the repository at this point in the history
1. Use VMEM_ALLOC_QUICK by default for allocateRegion in
   allocate_memory32
2. Adds -Xgc:suballocatorQuickAllocDisable option that
   disables the default VMEM_ALLOC_QUICK
3. Adds -Xgc:suballocatorIncrementSize option that replaces the
   HEAP_SIZE_BYTES macro and controls the heap increment size
4. Adds sanity.functional tests

Addresses: eclipse-omr/omr#7190
Signed-off-by: Nathan Henderson <[email protected]>
  • Loading branch information
ThanHenderson committed Jul 23, 2024
1 parent 31badae commit b28a92d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
1 change: 1 addition & 0 deletions runtime/exelib/common/memcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ static void *memoryCheck_allocate_memory32(OMRPortLibrary *portLib, UDATA byteAm
memCheckPortLib->tty_printf( memCheckPortLib, "allocate_memory32(%d)\n", byteAmount);
#endif

portLib->port_copy_suballocator_heap_globals(memCheckPortLib, portLib);
return memoryCheck_wrapper_allocate_memory(memCheckPortLib, byteAmount, "allocate_memory", globalAllocator32,
J9_MEMCHECK_DATA_PADDING_VALUE, J9_MEMCHECK_DATA_FILL_VALUE, J9_MEMCHECK_DATA_FREED_VALUE, callSite, category);
}
Expand Down
20 changes: 20 additions & 0 deletions runtime/gc_modron_startup/mmparseXgc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,26 @@ gcParseXgcArguments(J9JavaVM *vm, char *optArg)
continue;
}

/* Check if there is a request a suballocator reservation increment size. */
if (try_scan(&scan_start, "suballocatorIncrementSize=")) {
if (!scan_udata_memory_size_helper(vm, &scan_start, &extensions->suballocatorIncrementSize, "suballocatorIncrementSize=")) {
returnValue = JNI_EINVAL;
break;
}
if (0 == extensions->suballocatorIncrementSize) {
j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_VALUE_MUST_BE_ABOVE, "-Xgc:suballocatorIncrementSize=", (UDATA)0);
returnValue = JNI_EINVAL;
break;
}
continue;
}

/* Check if there is a request to disable the mmap-based allocation for the suballocator (linux only). */
if (try_scan(&scan_start, "suballocatorQuickAllocDisable")) {
extensions->suballocatorQuickAlloc = false;
continue;
}

/* for testing and service reasons, split heaps is currently restricted to Win32 only */
#if defined(J9VM_GC_GENERATIONAL) && (defined(WIN32) && !defined(WIN64))
/* see if we are supposed to enable split heaps */
Expand Down
42 changes: 38 additions & 4 deletions test/functional/cmdLineTests/gcsuballoctests/gcsuballoctests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@

<!DOCTYPE suite SYSTEM "cmdlinetester.dtd">

<suite id="J9 GC Tests" timeout="60">
<suite id="J9 GC Suballocator Tests" timeout="60">

<!-- Following tests are for compressedrefs platforms.
Because -Xgc:suballocatorInitialSize= and -Xgc:suballocatorCommitSize= options are defined only for compressedrefs. -->
<!-- Following tests are for compressedrefs platforms because -Xgc:suballocatorInitialSize=,
-Xgc:suballocatorCommitSize=, -Xgc:suballocatorIncrementSize=, and
-Xgc:suballocatorQuickAllocDisable options are defined only for compressedrefs. -->

<test id="-Xgc:suballocatorInitialSize=100m">
<command>$EXE$ -Xgc:suballocatorInitialSize=100m -version</command>
Expand All @@ -48,7 +49,27 @@
<output regex="no" type="failure">JVMDUMP006I</output>
<output regex="no" type="failure">Processing dump event</output>
</test>


<test id="-Xgc:suballocatorIncrementSize=100m">
<command>$EXE$ -Xgc:suballocatorIncrementSize=16m -version</command>
<output regex="no" type="success">version</output>
<output regex="yes" caseSensitive="yes" javaUtilPattern="yes" type="required">(Semeru|OpenJDK|Java\(TM\) SE) Runtime</output>
<output regex="no" type="failure">Exception</output>
<output regex="no" type="failure">Error</output>
<output regex="no" type="failure">JVMDUMP006I</output>
<output regex="no" type="failure">Processing dump event</output>
</test>

<test id="-Xgc:suballocatorQuickAllocDisable">
<command>$EXE$ -Xgc:suballocatorQuickAllocDisable -version</command>
<output regex="no" type="success">version</output>
<output regex="yes" caseSensitive="yes" javaUtilPattern="yes" type="required">(Semeru|OpenJDK|Java\(TM\) SE) Runtime</output>
<output regex="no" type="failure">Exception</output>
<output regex="no" type="failure">Error</output>
<output regex="no" type="failure">JVMDUMP006I</output>
<output regex="no" type="failure">Processing dump event</output>
</test>

<test id="-Xgc:suballocatorCommitSize=300m">
<command>$EXE$ -Xgc:suballocatorCommitSize=300m -version</command>
<!-- JVMJ9GC057E -Xgc:suballocatorCommitSize= must be no greater than -Xgc:suballocatorInitialSize= -->
Expand Down Expand Up @@ -88,6 +109,19 @@
<output regex="no" type="failure">Processing dump event</output>
</test>

<test id="-Xgc:suballocatorIncrementSize=0">
<command>$EXE$ -Xgc:suballocatorIncrementSize=0 -version</command>
<!-- JVMJ9GC036E -Xgc:suballocatorIncrementSize= value must be above 0 -->
<output regex="no" type="success">JVMJ9GC036E</output>
<!-- JVMJ9VM015W Initialization error for library j9gc26(2): Failed to initialize -->
<output regex="no" type="required">JVMJ9VM015W</output>
<output regex="no" caseSensitive="no" type="required">Could not create the Java Virtual Machine.</output>
<output regex="no" type="failure">version</output>
<output regex="yes" caseSensitive="yes" javaUtilPattern="yes" type="failure">(Semeru|OpenJDK|Java\(TM\) SE) Runtime</output>
<output regex="no" type="failure">JVMDUMP006I</output>
<output regex="no" type="failure">Processing dump event</output>
</test>

<test id="-Xgc:suballocatorCommitSize=512m Xgc:suballocatorInitialSize=256m">
<command>$EXE$ -Xgc:suballocatorCommitSize=512m -Xgc:suballocatorInitialSize=256m -version</command>
<!-- JVMJ9GC057E -Xgc:suballocatorCommitSize= must be no greater than -Xgc:suballocatorInitialSize= -->
Expand Down

0 comments on commit b28a92d

Please sign in to comment.