8209894: ZGC: Cap number of GC workers based on heap size

Reviewed-by: ehelin, tschatzl
This commit is contained in:
Per Lidén 2018-08-28 09:06:23 +02:00
parent 370abe471f
commit 12c27777c8
2 changed files with 19 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -22,14 +22,27 @@
*/
#include "precompiled.hpp"
#include "gc/z/zGlobals.hpp"
#include "gc/z/zTask.hpp"
#include "gc/z/zWorkers.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/safepoint.hpp"
uint ZWorkers::calculate_ncpus(double share_in_percent) {
return ceil(os::initial_active_processor_count() * share_in_percent / 100.0);
static uint calculate_nworkers_based_on_ncpus(double cpu_share_in_percent) {
return ceil(os::initial_active_processor_count() * cpu_share_in_percent / 100.0);
}
static uint calculate_nworkers_based_on_heap_size(double reserve_share_in_percent) {
const int nworkers = ((MaxHeapSize * (reserve_share_in_percent / 100.0)) - ZPageSizeMedium) / ZPageSizeSmall;
return MAX2(nworkers, 1);
}
static uint calculate_nworkers(double cpu_share_in_percent) {
// Cap number of workers so that we never use more than 10% of the max heap
// for the reserve. This is useful when using small heaps on large machines.
return MIN2(calculate_nworkers_based_on_ncpus(cpu_share_in_percent),
calculate_nworkers_based_on_heap_size(10.0));
}
uint ZWorkers::calculate_nparallel() {
@ -38,7 +51,7 @@ uint ZWorkers::calculate_nparallel() {
// close to the number of processors tends to lead to over-provisioning and
// scheduling latency issues. Using 60% of the active processors appears to
// be a fairly good balance.
return calculate_ncpus(60.0);
return calculate_nworkers(60.0);
}
uint ZWorkers::calculate_nconcurrent() {
@ -48,7 +61,7 @@ uint ZWorkers::calculate_nconcurrent() {
// throughput, while using too few threads will prolong the GC-cycle and
// we then risk being out-run by the application. Using 12.5% of the active
// processors appears to be a fairly good balance.
return calculate_ncpus(12.5);
return calculate_nworkers(12.5);
}
class ZWorkersWarmupTask : public ZTask {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -34,8 +34,6 @@ private:
bool _boost;
WorkGang _workers;
static uint calculate_ncpus(double share_in_percent);
void run(ZTask* task, uint nworkers);
public: