Skip to content

Commit

Permalink
Increase max TLH for non-batch clear platforms
Browse files Browse the repository at this point in the history
For non-batch TLH clear platform (currently only those based on X h/w)
the maximum size is increased to 1MB (from 128K default set by OMR).
This allows better scaling on high allocating/high CPU count
configurations.

Batch clearing platforms stays at 128K max, since clearing too much in a
batch may flush useful data from CPU data caches.

Signed-off-by: Aleksandar Micic <[email protected]>
  • Loading branch information
Aleksandar Micic authored and Aleksandar Micic committed Jul 30, 2024
1 parent d776a4a commit 4c2f109
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions runtime/gc_base/GCExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ MM_GCExtensions::initialize(MM_EnvironmentBase *env)
getJavaVM()->jniArrayCacheMaxSize = J9_GC_JNI_ARRAY_CACHE_SIZE;
#endif /* J9VM_GC_JNI_ARRAY_CACHE */

/* We increase default max TLH size from OMR default value to allow non-batch clear TLH platforms to benefit from it.
* Platforms that use batch clearing (see batchClearTLH) will override later this with a smaller value */
tlhMaximumSize = J9_MAXIMUM_TLH_SIZE;

#if defined(J9VM_GC_THREAD_LOCAL_HEAP)
getJavaVM()->gcInfo.tlhThreshold = J9_GC_TLH_THRESHOLD;
getJavaVM()->gcInfo.tlhSize = J9_GC_TLH_SIZE;
Expand Down
9 changes: 9 additions & 0 deletions runtime/gc_base/GCExtensions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class MM_IdleGCManager;
#define MINIMUM_SURVIVOR_MINIMUM_FREESIZE 512
#define MINIMUM_SURVIVOR_THRESHOLD 512


#define J9_MAXIMUM_TLH_SIZE (1024 * 1024)
#if defined(J9VM_GC_BATCH_CLEAR_TLH)
#define J9_MAXIMUM_TLH_SIZE_BATCH_CLEAR (128 * 1024)
#endif /* defined(J9VM_GC_BATCH_CLEAR_TLH) */

/**
* @todo Provide class documentation
* @ingroup GC_Base
Expand Down Expand Up @@ -193,6 +199,8 @@ class MM_GCExtensions : public MM_GCExtensionsBase {

UserSpecifiedParameters userSpecifiedParameters; /**< A collection of user-speicifed parameters */

bool tlhMaximumSizeSpecified; /**< true, if tlhMaximumSize specified by a command line option */

bool dynamicHeapAdjustmentForRestore; /**< If set to true, the default heuristic-calculated softmx is prioritized over the user-specified values. */
/**
* Values for com.ibm.oti.vm.VM.J9_JIT_STRING_DEDUP_POLICY
Expand Down Expand Up @@ -417,6 +425,7 @@ class MM_GCExtensions : public MM_GCExtensionsBase {
, objectListFragmentCount(0)
, numaCommonThreadClassNamePatterns(NULL)
, userSpecifiedParameters()
, tlhMaximumSizeSpecified(false)
, dynamicHeapAdjustmentForRestore(false)
, stringDedupPolicy(J9_JIT_STRING_DEDUP_POLICY_UNDEFINED)
, _asyncCallbackKey(-1)
Expand Down
11 changes: 10 additions & 1 deletion runtime/gc_modron_startup/mmhelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@ extern void initializeVerboseFunctionTableWithDummies(J9MemoryManagerVerboseInte
void
allocateZeroedTLHPages(J9JavaVM *javaVM, UDATA flag)
{
MM_GCExtensions::getExtensions(javaVM)->batchClearTLH = (flag != 0) ? 1 : 0;
MM_GCExtensions *ext = MM_GCExtensions::getExtensions(javaVM);

ext->batchClearTLH = (flag != 0) ? 1 : 0;

/* For batch clearing limit maximum size (since clearing too much may flush useful data from CPU data caches).
* Apply the limit only if user did not specify another value.
*/
if (ext->batchClearTLH && !ext->tlhMaximumSizeSpecified) {
ext->tlhMaximumSize = OMR_MIN(J9_MAXIMUM_TLH_SIZE_BATCH_CLEAR, ext->tlhMaximumSize);
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions runtime/gc_modron_startup/mmparseXgc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ j9gc_initialize_parse_gc_colon(J9JavaVM *javaVM, char **scan_start)
if(!scan_udata_helper(javaVM, scan_start, &extensions->tlhMaximumSize, "tlhMaximumSize=")) {
goto _error;
}
extensions->tlhMaximumSizeSpecified = true;
goto _exit;
}
if(try_scan(scan_start, "tlhIncrementSize=")) {
Expand Down

0 comments on commit 4c2f109

Please sign in to comment.