Skip to content

Commit

Permalink
Introduce gcThreadsCountSpecified flag
Browse files Browse the repository at this point in the history
This flag is to be used along existing gcThreadCountForced. Specified
flag will be used to distinguish between GC thread count calculated by
default or specified by a command line option. Forced flag
will to be used for a subset of options that force a fixed number of
threads.

Currently Forced is used as Specified, but we need both to distinguish
among 3 posibilities, specifically in Java: default, Xgcthreads and
Xgcmaxthreads.

Changes that will make that behavior effective will follow up later,
once downstream projects properly adjust command line parsing and
setting these flags.

Signed-off-by: Aleksandar Micic <Aleksandar_Micic@ca.ibm.com>
  • Loading branch information
root authored and Aleksandar Micic committed Dec 15, 2023
1 parent 5943f0e commit 260408f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions gc/base/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,14 @@ MM_Configuration::initializeGCThreadCount(MM_EnvironmentBase* env)
{
MM_GCExtensionsBase* extensions = env->getExtensions();

/* to be checked against gcThreadCountSpecified, once downstream projects properly set it */
if (!extensions->gcThreadCountForced) {
extensions->gcThreadCount = supportedGCThreadCount(env);
extensions->gcThreadCount = defaultGCThreadCount(env);
}
}

uintptr_t
MM_Configuration::supportedGCThreadCount(MM_EnvironmentBase* env)
MM_Configuration::defaultGCThreadCount(MM_EnvironmentBase* env)
{
OMRPORT_ACCESS_FROM_OMRPORT(env->getPortLibrary());
uintptr_t threadCount = omrsysinfo_get_number_CPUs_by_type(OMRPORT_CPU_TARGET);
Expand Down
4 changes: 2 additions & 2 deletions gc/base/Configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ class MM_Configuration : public MM_BaseVirtual

virtual void kill(MM_EnvironmentBase* env);

/* Number of GC threads supported based on hardware and dispatcher's max. */
virtual uintptr_t supportedGCThreadCount(MM_EnvironmentBase* env);
/* Default number of GC threads based on h/w, os and container limits */
virtual uintptr_t defaultGCThreadCount(MM_EnvironmentBase* env);

/**
* Sets the number of gc threads
Expand Down
7 changes: 4 additions & 3 deletions gc/base/GCExtensionsBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,9 @@ class MM_GCExtensionsBase : public MM_BaseVirtual {
#endif /* defined(OMR_GC_BATCH_CLEAR_TLH) */
omrthread_monitor_t gcStatsMutex;
uintptr_t gcThreadCount; /**< Initial number of GC threads - chosen default or specified in java options*/
bool gcThreadCountForced; /**< true if number of GC threads is specified in java options. Currently we have a few ways to do this:
-Xgcthreads -Xthreads= (RT only) -XthreadCount= */
uintptr_t dispatcherHybridNotifyThreadBound; /** Bound for determining hybrid notification type (Individual notifies for count < MIN(bound, maxThreads/2), otherwise notify_all) */
bool gcThreadCountSpecified; /**< true if number of GC threads is specified in command line options. */
bool gcThreadCountForced; /**< true if user forced a fixed number of GC threads. Default is false, but a command line option could set it if not wanting adaptive threading */
uintptr_t dispatcherHybridNotifyThreadBound; /**< Bound for determining hybrid notification type (Individual notifies for count < MIN(bound, maxThreads/2), otherwise notify_all) */

#if defined(OMR_GC_MODRON_SCAVENGER) || defined(OMR_GC_VLHGC)
enum ScavengerScanOrdering {
Expand Down Expand Up @@ -1657,6 +1657,7 @@ class MM_GCExtensionsBase : public MM_BaseVirtual {
, batchClearTLH(0)
#endif /* defined(OMR_GC_BATCH_CLEAR_TLH) */
, gcThreadCount(0)
, gcThreadCountSpecified(false)
, gcThreadCountForced(false)
, dispatcherHybridNotifyThreadBound(16)
#if defined(OMR_GC_MODRON_SCAVENGER) || defined(OMR_GC_VLHGC)
Expand Down
4 changes: 2 additions & 2 deletions gc/base/ParallelDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ MM_ParallelDispatcher::adjustThreadCount(uintptr_t maxThreadCount)
{
uintptr_t toReturn = maxThreadCount;

/* Did user specify number of gc threads? */
/* Did user force a fixed number of gc threads? */
if (!_extensions->gcThreadCountForced) {
/* No ...Use a sensible number of threads for current heap size. Using too many
* can lead to unacceptable pause times due to insufficient parallelism. Additionally,
Expand Down Expand Up @@ -733,7 +733,7 @@ MM_ParallelDispatcher::expandThreadPool(MM_EnvironmentBase *env)

Trc_MM_ParallelDispatcher_expandThreadPool_params(
newThreadCount, _poolMaxCapacity,
_extensions->configuration->supportedGCThreadCount(env), preExpandThreadCount);
_extensions->configuration->defaultGCThreadCount(env), preExpandThreadCount);

result = reinitializeThreadPool(env, newThreadCount);

Expand Down
2 changes: 1 addition & 1 deletion gc/base/j9mm.tdf
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ TraceEntry=Trc_MM_DoFixHeapForCompact_Entry Overhead=1 Level=1 Template="Trc_MM_
TraceExit=Trc_MM_DoFixHeapForCompact_Exit Overhead=1 Level=1 Template="Trc_MM_DoFixHeapForCompact Exit after fixing up %zu objects"

TraceEntry=Trc_MM_ParallelDispatcher_expandThreadPool_Entry noEnv Overhead=1 Level=1 Group=dispatcher Template="expandThreadPool Entry"
TraceEvent=Trc_MM_ParallelDispatcher_expandThreadPool_params noEnv Overhead=1 Level=1 Group=dispatcher Template="expandThreadPool_params: newThreadCount: %zu, _threadCountMaximumAtCheckpointStartup: %zu, supportedGCThreadCount: %zu, preExpandThreadCount: %zu"
TraceEvent=Trc_MM_ParallelDispatcher_expandThreadPool_params noEnv Overhead=1 Level=1 Group=dispatcher Template="expandThreadPool_params: newThreadCount: %zu, _threadCountMaximumAtCheckpointStartup: %zu, defaultGCThreadCount: %zu, preExpandThreadCount: %zu"
TraceExit=Trc_MM_ParallelDispatcher_expandThreadPool_Exit noEnv Overhead=1 Level=1 Group=dispatcher Template="expandThreadPool Exit: preExpandThreadCount: %zu, gcThreadCount: %zu, _threadShutdownCount: %zu"

TraceEntry=Trc_MM_ParallelDispatcher_contractThreadPool_Entry noEnv Overhead=1 Level=1 Group=dispatcher Template="contractThreadPool Entry: gcThreadCount: %zu, requested newThreadCount: %zu"
Expand Down

0 comments on commit 260408f

Please sign in to comment.