mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
Select number of GC threads dynamically based on heap usage and number of Java threads Reviewed-by: johnc, ysr, jcoomes
This commit is contained in:
parent
098ed89645
commit
15070123fa
39 changed files with 1523 additions and 231 deletions
|
@ -4244,9 +4244,11 @@ void CMSConcMarkingTask::coordinator_yield() {
|
|||
|
||||
bool CMSCollector::do_marking_mt(bool asynch) {
|
||||
assert(ConcGCThreads > 0 && conc_workers() != NULL, "precondition");
|
||||
// In the future this would be determined ergonomically, based
|
||||
// on #cpu's, # active mutator threads (and load), and mutation rate.
|
||||
int num_workers = ConcGCThreads;
|
||||
int num_workers = AdaptiveSizePolicy::calc_active_conc_workers(
|
||||
conc_workers()->total_workers(),
|
||||
conc_workers()->active_workers(),
|
||||
Threads::number_of_non_daemon_threads());
|
||||
conc_workers()->set_active_workers(num_workers);
|
||||
|
||||
CompactibleFreeListSpace* cms_space = _cmsGen->cmsSpace();
|
||||
CompactibleFreeListSpace* perm_space = _permGen->cmsSpace();
|
||||
|
@ -5062,6 +5064,8 @@ class CMSParRemarkTask: public AbstractGangTask {
|
|||
ParallelTaskTerminator _term;
|
||||
|
||||
public:
|
||||
// A value of 0 passed to n_workers will cause the number of
|
||||
// workers to be taken from the active workers in the work gang.
|
||||
CMSParRemarkTask(CMSCollector* collector,
|
||||
CompactibleFreeListSpace* cms_space,
|
||||
CompactibleFreeListSpace* perm_space,
|
||||
|
@ -5544,7 +5548,15 @@ void CMSCollector::do_remark_parallel() {
|
|||
GenCollectedHeap* gch = GenCollectedHeap::heap();
|
||||
FlexibleWorkGang* workers = gch->workers();
|
||||
assert(workers != NULL, "Need parallel worker threads.");
|
||||
int n_workers = workers->total_workers();
|
||||
// Choose to use the number of GC workers most recently set
|
||||
// into "active_workers". If active_workers is not set, set it
|
||||
// to ParallelGCThreads.
|
||||
int n_workers = workers->active_workers();
|
||||
if (n_workers == 0) {
|
||||
assert(n_workers > 0, "Should have been set during scavenge");
|
||||
n_workers = ParallelGCThreads;
|
||||
workers->set_active_workers(n_workers);
|
||||
}
|
||||
CompactibleFreeListSpace* cms_space = _cmsGen->cmsSpace();
|
||||
CompactibleFreeListSpace* perm_space = _permGen->cmsSpace();
|
||||
|
||||
|
@ -5884,8 +5896,17 @@ void CMSCollector::refProcessingWork(bool asynch, bool clear_all_soft_refs) {
|
|||
// and a different number of discovered lists may have Ref objects.
|
||||
// That is OK as long as the Reference lists are balanced (see
|
||||
// balance_all_queues() and balance_queues()).
|
||||
|
||||
rp->set_active_mt_degree(ParallelGCThreads);
|
||||
GenCollectedHeap* gch = GenCollectedHeap::heap();
|
||||
int active_workers = ParallelGCThreads;
|
||||
FlexibleWorkGang* workers = gch->workers();
|
||||
if (workers != NULL) {
|
||||
active_workers = workers->active_workers();
|
||||
// The expectation is that active_workers will have already
|
||||
// been set to a reasonable value. If it has not been set,
|
||||
// investigate.
|
||||
assert(active_workers > 0, "Should have been set during scavenge");
|
||||
}
|
||||
rp->set_active_mt_degree(active_workers);
|
||||
CMSRefProcTaskExecutor task_executor(*this);
|
||||
rp->process_discovered_references(&_is_alive_closure,
|
||||
&cmsKeepAliveClosure,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue