Skip to content

Commit

Permalink
Thread final/non-final Release Caches
Browse files Browse the repository at this point in the history
threadFinalReleaseCaches method is generalized to be used in a middle of
a Scavenger cycle, when we do not want to flush Copy Cache Remainders,
since they can be re-used later.

Additional parameter is introduced to control, if we want to be final
release (when remainders are abandoned) or not.

At all existing call sites we set the parameter to true and we used to
abandon them always, what makes this a non-functional change. Future
users will set the parameter to false when needed.

Signed-off-by: Aleksandar Micic <amicic@ca.ibm.com>
  • Loading branch information
amicic committed Apr 4, 2019
1 parent 7837021 commit ec3fe21
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions gc/base/standard/EnvironmentStandard.cpp
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2018 IBM Corp. and others
* Copyright (c) 1991, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -99,7 +99,7 @@ MM_EnvironmentStandard::flushGCCaches()
if (getExtensions()->concurrentScavenger) {
if (MUTATOR_THREAD == getThreadType()) {
if (NULL != getExtensions()->scavenger) {
getExtensions()->scavenger->threadFinalReleaseCaches(this);
getExtensions()->scavenger->threadReleaseCaches(this, true);
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions gc/base/standard/Scavenger.cpp
Expand Up @@ -4804,7 +4804,7 @@ MM_Scavenger::mutatorSetupForGC(MM_EnvironmentBase *envBase)
}

void
MM_Scavenger::threadFinalReleaseCaches(MM_EnvironmentBase *envBase)
MM_Scavenger::threadReleaseCaches(MM_EnvironmentBase *envBase, bool final)
{
MM_EnvironmentStandard *env = MM_EnvironmentStandard::getEnvironment(envBase);

Expand Down Expand Up @@ -4849,8 +4849,13 @@ MM_Scavenger::threadFinalReleaseCaches(MM_EnvironmentBase *envBase)
env->_tenureCopyScanCache = NULL;
}

abandonSurvivorTLHRemainder(env);
abandonTenureTLHRemainder(env, true);
if (final) {
/* If it's an intermediate release (for example mutator threads releasing VM access in a middle of Concurrent Scavenger cycle,
* keep copy cache remainders around (do not abandon yet), to be reused if the threads re-acquires VM access during the same CS cycle.
*/
abandonSurvivorTLHRemainder(env);
abandonTenureTLHRemainder(env, true);
}
}
}

Expand Down Expand Up @@ -4949,7 +4954,7 @@ MM_Scavenger::workThreadProcessRoots(MM_EnvironmentStandard *env)
* This is important to do only for GC threads that will not be used in concurrent phase, but at this point
* we don't know which threads Scheduler will not use, so we do it for every thread.
*/
threadFinalReleaseCaches(env);
threadReleaseCaches(env, true);

mergeThreadGCStats(env);
}
Expand All @@ -4970,7 +4975,7 @@ MM_Scavenger::workThreadScan(MM_EnvironmentStandard *env)
* Most of the time, STW phase will have a superset of GC threads, so they could just resume the work on their own caches,
* but this is not 100% guarantied (the control of what threads are inolved is in Dispatcher's domain).
*/
threadFinalReleaseCaches(env);
threadReleaseCaches(env, true);

mergeThreadGCStats(env);
}
Expand Down
6 changes: 3 additions & 3 deletions gc/base/standard/Scavenger.hpp
Expand Up @@ -624,10 +624,10 @@ class MM_Scavenger : public MM_Collector
/* methods used by either mutator or GC threads */
/**
* All open copy caches (even if not full) are pushed onto scan queue. Unused memory is abondoned.
* @param env Invoking thread. Could be master thread on behalf on mutator threads (threadEnvironment) for which copy caches are to be released, or could be mutator or GC thread itself.
* @param threadEnvironment Thread for which copy caches are to be released. Could be either GC or mutator thread.
* @param env Invoking thread, for which copy caches are to be released. Could be either GC or mutator thread.
* @param final If true (typically at the end of a cycle), abandon TLH remainders, too. Otherwise keep them for possible future copy cache refresh.
*/
void threadFinalReleaseCaches(MM_EnvironmentBase *env);
void threadReleaseCaches(MM_EnvironmentBase *env, bool final);

/**
* trigger STW phase (either start or end) of a Concurrent Scavenger Cycle
Expand Down

0 comments on commit ec3fe21

Please sign in to comment.