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. On linux, use VMEM_ALLOC_QUICK by default for allocateRegion in
   allocate_memory32
2. On linux, 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#7190
Signed-off-by: Nathan Henderson <[email protected]>
  • Loading branch information
ThanHenderson committed Jul 21, 2024
1 parent 31badae commit 79b65b7
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 2 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
22 changes: 22 additions & 0 deletions runtime/gc_modron_startup/mmparseXgc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,28 @@ 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;
}

#if defined(LINUX)
/* 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;
}
#endif /* defined(LINUX) */

/* 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
2 changes: 2 additions & 0 deletions runtime/oti/j9port.h
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,8 @@ typedef struct J9CacheInfoQuery {
#define J9PORT_CTLDATA_MEM_CATEGORIES_SET OMRPORT_CTLDATA_MEM_CATEGORIES_SET
#define J9PORT_CTLDATA_AIX_PROC_ATTR OMRPORT_CTLDATA_AIX_PROC_ATTR
#define J9PORT_CTLDATA_ALLOCATE32_COMMIT_SIZE OMRPORT_CTLDATA_ALLOCATE32_COMMIT_SIZE
#define J9PORT_CTLDATA_ALLOCATE32_INCREMENT_SIZE OMRPORT_CTLDATA_ALLOCATE32_INCREMENT_SIZE
#define J9PORT_CTLDATA_ALLOCATE32_QUICK_ALLOC OMRPORT_CTLDATA_ALLOCATE32_QUICK_ALLOC
#define J9PORT_CTLDATA_NOSUBALLOC32BITMEM OMRPORT_CTLDATA_NOSUBALLOC32BITMEM
#define J9PORT_CTLDATA_VMEM_ADVISE_OS_ONFREE OMRPORT_CTLDATA_VMEM_ADVISE_OS_ONFREE
#define J9PORT_CTLDATA_VECTOR_REGS_SUPPORT_ON OMRPORT_CTLDATA_VECTOR_REGS_SUPPORT_ON
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<!--
Copyright IBM Corp. and others 2024
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
distribution and is available at https://www.eclipse.org/legal/epl-2.0/
or the Apache License, Version 2.0 which accompanies this distribution and
is available at https://www.apache.org/licenses/LICENSE-2.0.
This Source Code may also be made available under the following
Secondary Licenses when the conditions for such availability set
forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
General Public License, version 2 with the GNU Classpath
Exception [1] and GNU General Public License, version 2 with the
OpenJDK Assembly Exception [2].
[1] https://www.gnu.org/software/classpath/license.html
[2] https://openjdk.org/legal/assembly-exception.html
SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
-->

<!DOCTYPE suite SYSTEM "cmdlinetester.dtd">

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

<!-- The following test is for compressedrefs linux platforms because
-Xgc:suballocatorQuickAllocDisable option are defined only for compressedrefs and linux. -->

<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>

</suite>

28 changes: 26 additions & 2 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. -->
Because -Xgc:suballocatorInitialSize=, -Xgc:suballocatorCommitSize=, and
-Xgc:suballocatorIncrementSize= options are defined only for compressedrefs. -->

<test id="-Xgc:suballocatorInitialSize=100m">
<command>$EXE$ -Xgc:suballocatorInitialSize=100m -version</command>
Expand All @@ -48,6 +49,16 @@
<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:suballocatorCommitSize=300m">
<command>$EXE$ -Xgc:suballocatorCommitSize=300m -version</command>
Expand Down Expand Up @@ -88,6 +99,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
23 changes: 23 additions & 0 deletions test/functional/cmdLineTests/gcsuballoctests/playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,27 @@
<impl>ibm</impl>
</impls>
</test>
<test>
<testCaseName>cmdLineTester_gcsuballocquickalloctest</testCaseName>
<variations>
<variation>Mode610</variation>
</variations>
<command>$(ADD_JVM_LIB_DIR_TO_LIBPATH) \
$(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -DJVM_TEST_ROOT=$(Q)$(JVM_TEST_ROOT)$(Q) -DRESJAR=$(CMDLINETESTER_RESJAR) \
-DEXE=$(SQ)$(JAVA_COMMAND) $(JVM_OPTIONS)$(SQ) -jar $(CMDLINETESTER_JAR) -config $(Q)$(TEST_RESROOT)$(D)gcsuballocquickalloctest.xml$(Q) \
-explainExcludes -xids all,$(PLATFORM),$(VARIATION) -plats all,$(PLATFORM),$(VARIATION) \
-xlist $(Q)$(TEST_RESROOT)$(D)gcsuballoctests_excludes.xml$(Q) -nonZeroExitWhenError; \
${TEST_STATUS}</command>
<platformRequirements>os.linux</platformRequirements>
<levels>
<level>sanity</level>
</levels>
<groups>
<group>functional</group>
</groups>
<impls>
<impl>openj9</impl>
<impl>ibm</impl>
</impls>
</test>
</playlist>

0 comments on commit 79b65b7

Please sign in to comment.