Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8231668: Remove ForceDynamicNumberOfGCThreads
Reviewed-by: shade, tschatzl
  • Loading branch information
adityamandaleeka authored and shipilev committed Mar 13, 2020
1 parent 5a68ba1 commit 5ed80778bc22762d8e3b979b29571def6b2d83d5
@@ -862,9 +862,7 @@ class G1CMConcurrentMarkingTask : public AbstractGangTask {

uint G1ConcurrentMark::calc_active_marking_workers() {
uint result = 0;
if (!UseDynamicNumberOfGCThreads ||
(!FLAG_IS_DEFAULT(ConcGCThreads) &&
!ForceDynamicNumberOfGCThreads)) {
if (!UseDynamicNumberOfGCThreads || !FLAG_IS_DEFAULT(ConcGCThreads)) {
result = _max_concurrent_workers;
} else {
result =
@@ -187,10 +187,6 @@
"Inject thread creation failures for " \
"UseDynamicNumberOfGCThreads") \
\
diagnostic(bool, ForceDynamicNumberOfGCThreads, false, \
"Force dynamic selection of the number of " \
"parallel threads parallel gc will use to aid debugging") \
\
product(size_t, HeapSizePerGCThread, ScaleForWordSize(32*M), \
"Size of heap (bytes) per GC thread used in calculating the " \
"number of GC threads") \
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@@ -30,7 +30,6 @@
#include "runtime/os.inline.hpp"
#include "runtime/vm_version.hpp"

bool WorkerPolicy::_debug_perturbation = false;
uint WorkerPolicy::_parallel_worker_threads = 0;
bool WorkerPolicy::_parallel_worker_threads_initialized = false;

@@ -133,26 +132,6 @@ uint WorkerPolicy::calc_default_active_workers(uintx total_workers,
assert(new_active_workers >= min_workers, "Minimum workers not observed");
assert(new_active_workers <= total_workers, "Total workers not observed");

if (ForceDynamicNumberOfGCThreads) {
// Assume this is debugging and jiggle the number of GC threads.
if (new_active_workers == prev_active_workers) {
if (new_active_workers < total_workers) {
new_active_workers++;
} else if (new_active_workers > min_workers) {
new_active_workers--;
}
}
if (new_active_workers == total_workers) {
if (_debug_perturbation) {
new_active_workers = min_workers;
}
_debug_perturbation = !_debug_perturbation;
}
assert((new_active_workers <= ParallelGCThreads) &&
(new_active_workers >= min_workers),
"Jiggled active workers too much");
}

log_trace(gc, task)("WorkerPolicy::calc_default_active_workers() : "
"active_workers(): " UINTX_FORMAT " new_active_workers: " UINTX_FORMAT " "
"prev_active_workers: " UINTX_FORMAT "\n"
@@ -173,8 +152,7 @@ uint WorkerPolicy::calc_active_workers(uintx total_workers,
// number of workers to all the workers.

uint new_active_workers;
if (!UseDynamicNumberOfGCThreads ||
(!FLAG_IS_DEFAULT(ParallelGCThreads) && !ForceDynamicNumberOfGCThreads)) {
if (!UseDynamicNumberOfGCThreads || !FLAG_IS_DEFAULT(ParallelGCThreads)) {
new_active_workers = total_workers;
} else {
uintx min_workers = (total_workers == 1) ? 1 : 2;
@@ -190,8 +168,7 @@ uint WorkerPolicy::calc_active_workers(uintx total_workers,
uint WorkerPolicy::calc_active_conc_workers(uintx total_workers,
uintx active_workers,
uintx application_workers) {
if (!UseDynamicNumberOfGCThreads ||
(!FLAG_IS_DEFAULT(ConcGCThreads) && !ForceDynamicNumberOfGCThreads)) {
if (!UseDynamicNumberOfGCThreads || !FLAG_IS_DEFAULT(ConcGCThreads)) {
return ConcGCThreads;
} else {
uint no_of_gc_threads = calc_default_active_workers(total_workers,
@@ -2333,16 +2333,14 @@ void ShenandoahHeap::assert_gc_workers(uint nworkers) {
assert(nworkers > 0 && nworkers <= max_workers(), "Sanity");

if (ShenandoahSafepoint::is_at_shenandoah_safepoint()) {
if (UseDynamicNumberOfGCThreads ||
(FLAG_IS_DEFAULT(ParallelGCThreads) && ForceDynamicNumberOfGCThreads)) {
if (UseDynamicNumberOfGCThreads) {
assert(nworkers <= ParallelGCThreads, "Cannot use more than it has");
} else {
// Use ParallelGCThreads inside safepoints
assert(nworkers == ParallelGCThreads, "Use ParalleGCThreads within safepoints");
assert(nworkers == ParallelGCThreads, "Use ParallelGCThreads within safepoints");
}
} else {
if (UseDynamicNumberOfGCThreads ||
(FLAG_IS_DEFAULT(ConcGCThreads) && ForceDynamicNumberOfGCThreads)) {
if (UseDynamicNumberOfGCThreads) {
assert(nworkers <= ConcGCThreads, "Cannot use more than it has");
} else {
// Use ConcGCThreads outside safepoints
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@@ -70,21 +70,13 @@ private static void verifyDynamicNumberOfGCThreads(OutputAnalyzer output) {
}

private static void testDynamicNumberOfGCThreads(String gcFlag) throws Exception {
// UseDynamicNumberOfGCThreads and TraceDynamicGCThreads enabled
// UseDynamicNumberOfGCThreads enabled
String[] baseArgs = {"-XX:+UnlockExperimentalVMOptions", "-XX:+" + gcFlag, "-Xmx10M", "-XX:+UseDynamicNumberOfGCThreads", "-Xlog:gc+task=trace", GCTest.class.getName()};

// Base test with gc and +UseDynamicNumberOfGCThreads:
ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder(baseArgs);
verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));

// Ensure it also works on uniprocessors or if user specifies -XX:ParallelGCThreads=1:
String[] extraArgs = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+ForceDynamicNumberOfGCThreads", "-XX:ParallelGCThreads=1"};
String[] finalArgs = new String[baseArgs.length + extraArgs.length];
System.arraycopy(extraArgs, 0, finalArgs, 0, extraArgs.length);
System.arraycopy(baseArgs, 0, finalArgs, extraArgs.length, baseArgs.length);
pb_enabled = ProcessTools.createJavaProcessBuilder(finalArgs);
verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));

// Turn on parallel reference processing
String[] parRefProcArg = {"-XX:+ParallelRefProcEnabled", "-XX:-ShowMessageBoxOnError"};
String[] parRefArgs = new String[baseArgs.length + parRefProcArg.length];
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
* Copyright (c) 2017, 2020, Red Hat, Inc. 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
@@ -54,12 +54,6 @@
* TestGCThreadGroups
*
* @run main/othervm -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
* -XX:+UseShenandoahGC
* -XX:+ForceDynamicNumberOfGCThreads
* -Dtarget=1000
* TestGCThreadGroups
*
* @run main/othervm -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
* -XX:ConcGCThreads=2 -XX:ParallelGCThreads=4
* -Dtarget=1000

0 comments on commit 5ed8077

Please sign in to comment.