Skip to content

Commit

Permalink
Merge pull request #7433 from pshipton/revert-7414-cmdline-subincr
Browse files Browse the repository at this point in the history
Revert "Add Xgc options for suballocator heap size and quick allocation"
  • Loading branch information
jdmpapin authored Aug 2, 2024
2 parents 21d60a7 + 452de54 commit 9ccff3c
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 113 deletions.
4 changes: 2 additions & 2 deletions fvtest/porttest/omrmemTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ extern PortTestEnvironment *portTestEnv;
#endif

#if defined(OMR_ENV_DATA64)
/* This macro corresponds to SUBALLOCATOR_INCREMENT_SIZE defined in omrgcconsts.h. */
#define HEAP_SIZE_BYTES (8 * 1024 * 1024)
/* this macro corresponds to the one defined in omrmem32helpers */
#define HEAP_SIZE_BYTES 8*1024*1024
#endif

#define COMPLETE_LARGE_REGION 1
Expand Down
4 changes: 0 additions & 4 deletions gc/base/GCExtensionsBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,6 @@ class MM_GCExtensionsBase : public MM_BaseVirtual {
bool scavengerAlignHotFields; /**< True if the scavenger is to check the hot field description for an object in order to better cache align it when tenuring (enabled with the -Xgc:hotAlignment option) */
uintptr_t suballocatorInitialSize; /**< the initial chunk size in bytes for the J9Heap suballocator (enabled with the -Xgc:suballocatorInitialSize option) */
uintptr_t suballocatorCommitSize; /**< the commit size in bytes for the J9Heap suballocator (enabled with the -Xgc:suballocatorCommitSize option) */
uintptr_t suballocatorIncrementSize; /**< the increment size in bytes for the J9Heap suballocator (enabled with the -Xgc:suballocatorIncrementSize option) */
bool suballocatorQuickAlloc; /**< use OMRPORT_VMEM_ALLOC_QUICK for the J9Heap suballocator (disabled with the -Xgc:suballocatorQuickAllocDisable option) */

#if defined(OMR_GC_COMPRESSED_POINTERS)
bool shouldAllowShiftingCompression; /**< temporary option to enable compressed reference scaling by shifting pointers */
Expand Down Expand Up @@ -1872,8 +1870,6 @@ class MM_GCExtensionsBase : public MM_BaseVirtual {
, scavengerAlignHotFields(true) /* VM Design 1774: hot field alignment is on by default */
, suballocatorInitialSize(SUBALLOCATOR_INITIAL_SIZE) /* default for J9Heap suballocator initial size is 200 MB */
, suballocatorCommitSize(SUBALLOCATOR_COMMIT_SIZE) /* default for J9Heap suballocator commit size is 50 MB */
, suballocatorIncrementSize(SUBALLOCATOR_INCREMENT_SIZE) /* default for J9Heap suballocator commit size is 8 MB or 256 MB for AIX */
, suballocatorQuickAlloc(true) /* use mmap-based allocation by default for the J9Heap suballoctor */
#if defined(OMR_GC_COMPRESSED_POINTERS)
, shouldAllowShiftingCompression(true) /* VM Design 1810: shifting compression enabled, by default, for compressed refs */
, shouldForceSpecifiedShiftingCompression(0)
Expand Down
6 changes: 0 additions & 6 deletions gc/base/MemoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,6 @@ MM_MemoryManager::createVirtualMemoryForHeap(MM_EnvironmentBase *env, MM_MemoryH
/* Set the commit size for the sub allocator. This needs to be completed before the call to omrmem_ensure_capacity32 */
omrport_control(OMRPORT_CTLDATA_ALLOCATE32_COMMIT_SIZE, extensions->suballocatorCommitSize);

/* Set the increment size for the sub allocator. This needs to be completed before the call to omrmem_ensure_capacity32 */
omrport_control(OMRPORT_CTLDATA_ALLOCATE32_INCREMENT_SIZE, extensions->suballocatorIncrementSize);

/* Set if the sub allocator should use ALLOC_QUICK. This needs to be completed before the call to omrmem_ensure_capacity32 */
omrport_control(OMRPORT_CTLDATA_ALLOCATE32_QUICK_ALLOC, extensions->suballocatorQuickAlloc ? 1 : 0);

if (!shouldHeapBeAllocatedFirst) {
if (OMRPORT_ENSURE_CAPACITY_FAILED == omrmem_ensure_capacity32(extensions->suballocatorInitialSize)) {
extensions->heapInitializationFailureReason = MM_GCExtensionsBase::HEAP_INITIALIZATION_FAILURE_REASON_CAN_NOT_ALLOCATE_LOW_MEMORY_RESERVE;
Expand Down
19 changes: 4 additions & 15 deletions include_core/omrgcconsts.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,26 +555,15 @@ typedef enum {
#define PREFERRED_HEAP_BASE 0x0
#endif

#define SUBALLOCATOR_INITIAL_SIZE (200 * 1024 * 1024)
#define SUBALLOCATOR_COMMIT_SIZE (50 * 1024 * 1024)
#define SUBALLOCATOR_INITIAL_SIZE (200*1024*1024)
#define SUBALLOCATOR_COMMIT_SIZE (50*1024*1024)
#if defined(AIXPPC)
/* virtual memory is assigned in segment of 256M, so grab the entire segment */
#define SUBALLOCATOR_ALIGNMENT (256 * 1024 * 1024)
#define SUBALLOCATOR_ALIGNMENT (256*1024*1024)
#else /* defined(AIXPPC) */
#define SUBALLOCATOR_ALIGNMENT (8 * 1024 * 1024)
#define SUBALLOCATOR_ALIGNMENT (8*1024*1024)
#endif /* defined(AIXPPC) */

/* VMDESIGN 1761 The size of a suballocation heap.
* See VMDESIGN 1761 for the rationale behind the selection of this size.
* We use a 8MB heap to give us more room in case an application loads a larger amount of classes than usual.
* For testing purposes, this value is mirrored in port library test. If we tune this value, we should also adjust it in omrmemTest.cpp
*/
#if defined(AIXPPC) && defined(OMR_GC_COMPRESSED_POINTERS)
#define SUBALLOCATOR_INCREMENT_SIZE (256 * 1024 * 1024)
#else /* defined(AIXPPC) && defined(OMR_GC_COMPRESSED_POINTERS) */
#define SUBALLOCATOR_INCREMENT_SIZE (8 * 1024 * 1024)
#endif /* defined(AIXPPC) && defined(OMR_GC_COMPRESSED_POINTERS) */

#define MAXIMUM_HEAP_SIZE_RECOMMENDED_FOR_COMPRESSEDREFS ((U_64)57 * 1024 * 1024 * 1024)
#define MAXIMUM_HEAP_SIZE_RECOMMENDED_FOR_3BIT_SHIFT_COMPRESSEDREFS ((U_64)25 * 1024 * 1024 * 1024)

Expand Down
6 changes: 0 additions & 6 deletions include_core/omrport.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,6 @@ typedef struct J9ProcessorInfos {
#define OMRPORT_CTLDATA_MEM_CATEGORIES_SET "MEM_CATEGORIES_SET"
#define OMRPORT_CTLDATA_AIX_PROC_ATTR "AIX_PROC_ATTR"
#define OMRPORT_CTLDATA_ALLOCATE32_COMMIT_SIZE "ALLOCATE32_COMMIT_SIZE"
#define OMRPORT_CTLDATA_ALLOCATE32_INCREMENT_SIZE "ALLOCATE32_INCREMENT_SIZE"
#define OMRPORT_CTLDATA_ALLOCATE32_QUICK_ALLOC "ALLOCATE32_QUICK_ALLOC"
#define OMRPORT_CTLDATA_NOSUBALLOC32BITMEM "NOSUBALLOC32BITMEM"
#define OMRPORT_CTLDATA_VMEM_ADVISE_OS_ONFREE "VMEM_ADVISE_OS_ONFREE"
#define OMRPORT_CTLDATA_VECTOR_REGS_SUPPORT_ON "VECTOR_REGS_SUPPORT_ON"
Expand Down Expand Up @@ -2485,10 +2483,6 @@ typedef struct OMRPortLibrary {
int32_t (*port_startup_library)(struct OMRPortLibrary *portLibrary) ;
/** see @ref omrport.c::omrport_create_library "omrport_create_library"*/
int32_t (*port_create_library)(struct OMRPortLibrary *portLibrary, uintptr_t size) ;
#if defined(OMR_ENV_DATA64)
/** see @ref omrport.c::omrport_copy_suballocator_heap_globals "omrport_copy_suballocator_heap_globals" */
void (*port_copy_suballocator_heap_globals)(struct OMRPortLibrary *destPortLibrary, struct OMRPortLibrary *srcPortLibrary) ;
#endif /* defined(OMR_ENV_DATA64) */
/** see @ref omrsyslog.c::omrsyslog_write "omrsyslog_write"*/
uintptr_t (*syslog_write)(struct OMRPortLibrary *portLibrary, uintptr_t flags, const char *message) ;
/** see @ref omrintrospect.c::omrintrospect_startup "omrintrospect_startup"*/
Expand Down
49 changes: 24 additions & 25 deletions port/common/omrmem32helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,26 @@ static void *reserveAndCommitRegion(struct OMRPortLibrary *portLibrary, uintptr_
#define VMEM_MODE_COMMIT OMRPORT_VMEM_MEMORY_MODE_READ | OMRPORT_VMEM_MEMORY_MODE_WRITE | OMRPORT_VMEM_MEMORY_MODE_COMMIT
#define VMEM_MODE_WITHOUT_COMMIT OMRPORT_VMEM_MEMORY_MODE_READ | OMRPORT_VMEM_MEMORY_MODE_WRITE

#define MEM32_LIMIT ((uintptr_t)0XFFFFFFFFU)
struct {
uintptr_t base;
uintptr_t limit;
} regions[] = {
{0x0, MEM32_LIMIT}
{0x0, 0xFFFFFFFF}
};

#define MEM32_LIMIT 0XFFFFFFFF

/* VMDESIGN 1761 The size of a suballocation heap.
* See VMDESIGN 1761 for the rationale behind the selection of this size.
* We use a 8MB heap to give us more room in case an application loads a larger amount of classes than usual.
* For testing purposes, this value is mirrored in port library test. If we tune this value, we should also adjust it in omrmemTest.cpp
*/
#if defined(AIXPPC) && defined(OMR_GC_COMPRESSED_POINTERS)
/* virtual memory is allocated in 256M segments on AIX, so grab the whole segment */
#define HEAP_SIZE_BYTES (256 * 1024 * 1024)
#else
#define HEAP_SIZE_BYTES (8 * 1024 * 1024)
#endif
/* Creates any of the resources required to use allocate_memory32
*
* Note: Any resources created here need to be cleaned up in shutdown_memory32_using_vmem
Expand All @@ -60,8 +72,6 @@ startup_memory32(struct OMRPortLibrary *portLibrary)
PPG_mem_mem32_subAllocHeapMem32.subCommitHeapWrapper = NULL;
PPG_mem_mem32_subAllocHeapMem32.suballocator_initialSize = 0;
PPG_mem_mem32_subAllocHeapMem32.suballocator_commitSize = 0;
PPG_mem_mem32_subAllocHeapMem32.suballocator_incrementSize = 0;
PPG_mem_mem32_subAllocHeapMem32.suballocator_quickAlloc = TRUE;

/* initialize the monitor in subAllocHeap32 */
if (0 != omrthread_monitor_init(&(PPG_mem_mem32_subAllocHeapMem32.monitor), 0)) {
Expand Down Expand Up @@ -428,26 +438,15 @@ allocate_memory32(struct OMRPortLibrary *portLibrary, uintptr_t byteAmount, cons
#endif
omrthread_monitor_enter(PPG_mem_mem32_subAllocHeapMem32.monitor);

/* Check if byteAmount is larger than PPG_mem_mem32_subAllocHeapMem32.suballocator_incrementSize.
/* Check if byteAmount is larger than HEAP_SIZE_BYTES.
* The majority of size requests will typically be much smaller.
*/
returnPtr = iterateHeapsAndSubAllocate(portLibrary, byteAmount);
if (NULL == returnPtr) {
if (byteAmount >= PPG_mem_mem32_subAllocHeapMem32.suballocator_incrementSize) {
returnPtr = allocateLargeRegion(
portLibrary,
byteAmount,
callSite,
0);
if (byteAmount >= HEAP_SIZE_BYTES) {
returnPtr = allocateLargeRegion(portLibrary, byteAmount, callSite, 0);
} else {
/* For 64-bit Linux, use the OMRPORT_VMEM_ALLOC_QUICK flag if it has not been disabled. */
uintptr_t vmemAllocOptions = PPG_mem_mem32_subAllocHeapMem32.suballocator_quickAlloc ? OMRPORT_VMEM_ALLOC_QUICK : 0;
returnPtr = allocateRegion(
portLibrary,
PPG_mem_mem32_subAllocHeapMem32.suballocator_incrementSize,
byteAmount,
callSite,
vmemAllocOptions);
returnPtr = allocateRegion(portLibrary, HEAP_SIZE_BYTES, byteAmount, callSite, 0);
}
}

Expand All @@ -467,11 +466,11 @@ ensure_capacity32(struct OMRPortLibrary *portLibrary, uintptr_t byteAmount)
J9HeapWrapper *heapWrapperCursor = NULL;
uintptr_t returnValue = OMRPORT_ENSURE_CAPACITY_FAILED;
#if defined(OMR_ENV_DATA64)
/* For 64-bit OS, use the OMRPORT_VMEM_ALLOC_QUICK flag during startup. */
/* For 64 bit os, use flag OMRPORT_VMEM_ALLOC_QUICK as it is in the startup period. */
uintptr_t vmemAllocOptions = OMRPORT_VMEM_ALLOC_QUICK;
#else /* defined(OMR_ENV_DATA64) */
#else
uintptr_t vmemAllocOptions = 0;
#endif /* defined(OMR_ENV_DATA64) */
#endif

Trc_PRT_mem_ensure_capacity32_Entry(byteAmount);

Expand All @@ -482,9 +481,9 @@ ensure_capacity32(struct OMRPortLibrary *portLibrary, uintptr_t byteAmount)
}
#endif

/* Ensured byte amount should be at least PPG_mem_mem32_subAllocHeapMem32.suballocator_incrementSize large. */
if (byteAmount < PPG_mem_mem32_subAllocHeapMem32.suballocator_incrementSize) {
byteAmount = PPG_mem_mem32_subAllocHeapMem32.suballocator_incrementSize;
/* Ensured byte amount should be at least HEAP_SIZE_BYTES large */
if (byteAmount < HEAP_SIZE_BYTES) {
byteAmount = HEAP_SIZE_BYTES;
}

omrthread_monitor_enter(PPG_mem_mem32_subAllocHeapMem32.monitor);
Expand Down
2 changes: 0 additions & 2 deletions port/common/omrmem32struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ typedef struct J9SubAllocateHeapMem32 {
J9HeapWrapper *subCommitHeapWrapper;
uintptr_t suballocator_initialSize;
uintptr_t suballocator_commitSize;
uintptr_t suballocator_incrementSize;
BOOLEAN suballocator_quickAlloc;
} J9SubAllocateHeapMem32;

#endif /* omrmem32struct_h */
25 changes: 0 additions & 25 deletions port/common/omrport.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,6 @@ static OMRPortLibrary MainPortLibraryTable = {
omrport_init_library, /* port_init_library */
omrport_startup_library, /* port_startup_library */
omrport_create_library, /* port_create_library */
#if defined(OMR_ENV_DATA64)
omrport_copy_suballocator_heap_globals, /* port_copy_suballocator_heap_globals */
#endif /* defined(OMR_ENV_DATA64) */
omrsyslog_write, /* syslog_write */
omrintrospect_startup, /* introspect_startup */
omrintrospect_shutdown, /* introspect_shutdown */
Expand Down Expand Up @@ -592,28 +589,6 @@ omrport_create_library(struct OMRPortLibrary *portLibrary, uintptr_t size)
return 0;
}

#if defined(OMR_ENV_DATA64)
/**
* Copy the subAllocHeapMem32 values from a source OMRPortLibrary to a destination OMRPortLibrary.
*
* This is a helper for ensuring memCheckPortLib picks up the subAllocHeapMem32 default and/or -Xgc
* specified values.
*
* @param[in,out] destPortLibrary The port library to copy the port globals to.
* @param[in,out] sourcePortLibrary The port library to copy the port globals from.
*
*/
void
omrport_copy_suballocator_heap_globals(struct OMRPortLibrary *destPortLibrary, struct OMRPortLibrary *srcPortLibrary)
{
J9SubAllocateHeapMem32 subAllocGlobals = srcPortLibrary->portGlobals->platformGlobals.subAllocHeapMem32;
omrport_control(destPortLibrary, OMRPORT_CTLDATA_ALLOCATE32_COMMIT_SIZE, subAllocGlobals.suballocator_commitSize);
omrport_control(destPortLibrary, OMRPORT_CTLDATA_ALLOCATE32_INCREMENT_SIZE, subAllocGlobals.suballocator_incrementSize);
omrport_control(destPortLibrary, OMRPORT_CTLDATA_ALLOCATE32_QUICK_ALLOC, subAllocGlobals.suballocator_quickAlloc ? 1 : 0);
return;
}
#endif /* defined(OMR_ENV_DATA64) */

/**
* PortLibrary startup.
*
Expand Down
27 changes: 3 additions & 24 deletions port/common/omrportcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ omrport_control(struct OMRPortLibrary *portLibrary, const char *key, uintptr_t v
return 0;
}
#if defined(OMR_ENV_DATA64)
if (0 == strcmp(OMRPORT_CTLDATA_ALLOCATE32_COMMIT_SIZE, key)) {
if (!strcmp(OMRPORT_CTLDATA_ALLOCATE32_COMMIT_SIZE, key)) {
if (0 != value) {
/* CommitSize is immutable. It can only be set once. */
if (0 == PPG_mem_mem32_subAllocHeapMem32.suballocator_commitSize) {
/* Round up the commit size to the page size and set it to global variable. */
/* Round up the commit size to the page size and set it to global variable */
uintptr_t pageSize = portLibrary->vmem_supported_page_sizes(portLibrary)[0];
uintptr_t roundedCommitSize = pageSize * (value / pageSize);
if (roundedCommitSize < value) {
Expand All @@ -72,29 +72,8 @@ omrport_control(struct OMRPortLibrary *portLibrary, const char *key, uintptr_t v
return (int32_t)PPG_mem_mem32_subAllocHeapMem32.suballocator_commitSize;
}
return 0;
} else if (0 == strcmp(OMRPORT_CTLDATA_ALLOCATE32_INCREMENT_SIZE, key)) {
if (0 != value) {
/* IncrementSize is immutable. It can only be set once. */
if (0 == PPG_mem_mem32_subAllocHeapMem32.suballocator_incrementSize) {
/* Round up the increment size to the page size and set it to global variable. */
uintptr_t pageSize = portLibrary->vmem_supported_page_sizes(portLibrary)[0];
uintptr_t roundedIncrementSize = pageSize * (value / pageSize);
if (roundedIncrementSize < value) {
roundedIncrementSize += pageSize;
}
PPG_mem_mem32_subAllocHeapMem32.suballocator_incrementSize = roundedIncrementSize;
} else {
return 1;
}
} else {
return (int32_t)PPG_mem_mem32_subAllocHeapMem32.suballocator_incrementSize;
}
return 0;
} else if (0 == strcmp(OMRPORT_CTLDATA_ALLOCATE32_QUICK_ALLOC, key)) {
PPG_mem_mem32_subAllocHeapMem32.suballocator_quickAlloc = (0 != value) ? TRUE : FALSE;
return 0;
}
#endif /* defined(OMR_ENV_DATA64) */
#endif

#if defined(OMR_RAS_TDF_TRACE)
if (!strcmp(OMRPORT_CTLDATA_TRACE_START, key) && value) {
Expand Down
4 changes: 0 additions & 4 deletions port/omrportpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -931,10 +931,6 @@ extern J9_CFUNC int32_t
omrport_startup_library(struct OMRPortLibrary *portLibrary);
extern J9_CFUNC int32_t
omrport_create_library(struct OMRPortLibrary *portLibrary, uintptr_t size);
#if defined(OMR_ENV_DATA64)
extern J9_CFUNC void
omrport_copy_suballocator_heap_globals(struct OMRPortLibrary *destPortLibrary, struct OMRPortLibrary *srcPortLibrary);
#endif /* defined(OMR_ENV_DATA64) */

/* J9Syslog */
extern J9_CFUNC uintptr_t
Expand Down

0 comments on commit 9ccff3c

Please sign in to comment.