From b28a92dfe80b59242d288c5f9cba0ad41d826d1a Mon Sep 17 00:00:00 2001 From: Nathan Henderson Date: Thu, 27 Jun 2024 13:05:31 -0700 Subject: [PATCH] Add Xgc options for suballocator heap size and quick allocation 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: https://github.com/eclipse/omr/issues/7190 Signed-off-by: Nathan Henderson --- runtime/exelib/common/memcheck.c | 1 + runtime/gc_modron_startup/mmparseXgc.cpp | 20 +++++++++ .../gcsuballoctests/gcsuballoctests.xml | 42 +++++++++++++++++-- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/runtime/exelib/common/memcheck.c b/runtime/exelib/common/memcheck.c index a283272eb44..06508d79a71 100644 --- a/runtime/exelib/common/memcheck.c +++ b/runtime/exelib/common/memcheck.c @@ -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); } diff --git a/runtime/gc_modron_startup/mmparseXgc.cpp b/runtime/gc_modron_startup/mmparseXgc.cpp index f2c23c20765..66c4679a557 100644 --- a/runtime/gc_modron_startup/mmparseXgc.cpp +++ b/runtime/gc_modron_startup/mmparseXgc.cpp @@ -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 */ diff --git a/test/functional/cmdLineTests/gcsuballoctests/gcsuballoctests.xml b/test/functional/cmdLineTests/gcsuballoctests/gcsuballoctests.xml index 021de939d76..0c550177ce2 100644 --- a/test/functional/cmdLineTests/gcsuballoctests/gcsuballoctests.xml +++ b/test/functional/cmdLineTests/gcsuballoctests/gcsuballoctests.xml @@ -24,10 +24,11 @@ - + - + $EXE$ -Xgc:suballocatorInitialSize=100m -version @@ -48,7 +49,27 @@ JVMDUMP006I Processing dump event - + + + $EXE$ -Xgc:suballocatorIncrementSize=16m -version + version + (Semeru|OpenJDK|Java\(TM\) SE) Runtime + Exception + Error + JVMDUMP006I + Processing dump event + + + + $EXE$ -Xgc:suballocatorQuickAllocDisable -version + version + (Semeru|OpenJDK|Java\(TM\) SE) Runtime + Exception + Error + JVMDUMP006I + Processing dump event + + $EXE$ -Xgc:suballocatorCommitSize=300m -version @@ -88,6 +109,19 @@ Processing dump event + + $EXE$ -Xgc:suballocatorIncrementSize=0 -version + + JVMJ9GC036E + + JVMJ9VM015W + Could not create the Java Virtual Machine. + version + (Semeru|OpenJDK|Java\(TM\) SE) Runtime + JVMDUMP006I + Processing dump event + + $EXE$ -Xgc:suballocatorCommitSize=512m -Xgc:suballocatorInitialSize=256m -version