8252141: Rename G1YoungRemSetSamplingThread to better reflect its purpose

Reviewed-by: kbarrett, tschatzl
This commit is contained in:
Stefan Johansson 2020-09-01 15:55:56 +02:00
parent 0d1aa3cbc8
commit 2c4fbbca23
7 changed files with 61 additions and 56 deletions

View File

@ -63,7 +63,7 @@
#include "gc/g1/g1ThreadLocalData.hpp"
#include "gc/g1/g1Trace.hpp"
#include "gc/g1/g1YCTypes.hpp"
#include "gc/g1/g1YoungRemSetSamplingThread.hpp"
#include "gc/g1/g1ServiceThread.hpp"
#include "gc/g1/g1VMOperations.hpp"
#include "gc/g1/heapRegion.inline.hpp"
#include "gc/g1/heapRegionRemSet.hpp"
@ -1419,7 +1419,7 @@ public:
G1CollectedHeap::G1CollectedHeap() :
CollectedHeap(),
_young_gen_sampling_thread(NULL),
_service_thread(NULL),
_workers(NULL),
_card_table(NULL),
_collection_pause_end(Ticks::now()),
@ -1556,10 +1556,10 @@ jint G1CollectedHeap::initialize_concurrent_refinement() {
return ecode;
}
jint G1CollectedHeap::initialize_young_gen_sampling_thread() {
_young_gen_sampling_thread = new G1YoungRemSetSamplingThread();
if (_young_gen_sampling_thread->osthread() == NULL) {
vm_shutdown_during_initialization("Could not create G1YoungRemSetSamplingThread");
jint G1CollectedHeap::initialize_service_thread() {
_service_thread = new G1ServiceThread();
if (_service_thread->osthread() == NULL) {
vm_shutdown_during_initialization("Could not create G1ServiceThread");
return JNI_ENOMEM;
}
return JNI_OK;
@ -1733,7 +1733,7 @@ jint G1CollectedHeap::initialize() {
return ecode;
}
ecode = initialize_young_gen_sampling_thread();
ecode = initialize_service_thread();
if (ecode != JNI_OK) {
return ecode;
}
@ -1779,7 +1779,7 @@ void G1CollectedHeap::stop() {
// do not continue to execute and access resources (e.g. logging)
// that are destroyed during shutdown.
_cr->stop();
_young_gen_sampling_thread->stop();
_service_thread->stop();
_cm_thread->stop();
if (G1StringDedup::is_enabled()) {
G1StringDedup::stop();
@ -2534,7 +2534,7 @@ void G1CollectedHeap::gc_threads_do(ThreadClosure* tc) const {
tc->do_thread(_cm_thread);
_cm->threads_do(tc);
_cr->threads_do(tc);
tc->do_thread(_young_gen_sampling_thread);
tc->do_thread(_service_thread);
if (G1StringDedup::is_enabled()) {
G1StringDedup::threads_do(tc);
}

View File

@ -80,7 +80,7 @@ class G1CollectionSet;
class G1Policy;
class G1HotCardCache;
class G1RemSet;
class G1YoungRemSetSamplingThread;
class G1ServiceThread;
class G1ConcurrentMark;
class G1ConcurrentMarkThread;
class G1ConcurrentRefine;
@ -154,7 +154,7 @@ class G1CollectedHeap : public CollectedHeap {
friend class G1CheckRegionAttrTableClosure;
private:
G1YoungRemSetSamplingThread* _young_gen_sampling_thread;
G1ServiceThread* _service_thread;
WorkGang* _workers;
G1CardTable* _card_table;
@ -547,7 +547,7 @@ private:
void verify_numa_regions(const char* desc);
public:
G1YoungRemSetSamplingThread* sampling_thread() const { return _young_gen_sampling_thread; }
G1ServiceThread* service_thread() const { return _service_thread; }
WorkGang* workers() const { return _workers; }
@ -968,7 +968,7 @@ public:
private:
jint initialize_concurrent_refinement();
jint initialize_young_gen_sampling_thread();
jint initialize_service_thread();
public:
// Initialize the G1CollectedHeap to have the initial and
// maximum sizes and remembered and barrier sets

View File

@ -30,7 +30,7 @@
#include "gc/g1/g1DirtyCardQueue.hpp"
#include "gc/g1/g1RemSet.hpp"
#include "gc/g1/g1RemSetSummary.hpp"
#include "gc/g1/g1YoungRemSetSamplingThread.hpp"
#include "gc/g1/g1ServiceThread.hpp"
#include "gc/g1/heapRegion.hpp"
#include "gc/g1/heapRegionRemSet.hpp"
#include "memory/allocation.inline.hpp"
@ -53,7 +53,7 @@ void G1RemSetSummary::update() {
g1h->concurrent_refine()->threads_do(&collector);
_num_coarsenings = HeapRegionRemSet::n_coarsenings();
set_sampling_thread_vtime(g1h->sampling_thread()->vtime_accum());
set_service_thread_vtime(g1h->service_thread()->vtime_accum());
}
void G1RemSetSummary::set_rs_thread_vtime(uint thread, double value) {
@ -72,7 +72,7 @@ G1RemSetSummary::G1RemSetSummary(bool should_update) :
_num_coarsenings(0),
_num_vtimes(G1ConcurrentRefine::max_num_threads()),
_rs_threads_vtimes(NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC)),
_sampling_thread_vtime(0.0f) {
_service_thread_vtime(0.0f) {
memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes);
@ -93,7 +93,7 @@ void G1RemSetSummary::set(G1RemSetSummary* other) {
memcpy(_rs_threads_vtimes, other->_rs_threads_vtimes, sizeof(double) * _num_vtimes);
set_sampling_thread_vtime(other->sampling_thread_vtime());
set_service_thread_vtime(other->service_thread_vtime());
}
void G1RemSetSummary::subtract_from(G1RemSetSummary* other) {
@ -106,7 +106,7 @@ void G1RemSetSummary::subtract_from(G1RemSetSummary* other) {
set_rs_thread_vtime(i, other->rs_thread_vtime(i) - rs_thread_vtime(i));
}
_sampling_thread_vtime = other->sampling_thread_vtime() - _sampling_thread_vtime;
_service_thread_vtime = other->service_thread_vtime() - _service_thread_vtime;
}
class RegionTypeCounter {
@ -327,8 +327,8 @@ void G1RemSetSummary::print_on(outputStream* out) {
out->print(" %5.2f", rs_thread_vtime(i));
}
out->cr();
out->print_cr(" Concurrent sampling threads times (s)");
out->print_cr(" %5.2f", sampling_thread_vtime());
out->print_cr(" Service thread time (s)");
out->print_cr(" %5.2f", service_thread_vtime());
HRRSStatsIter blk;
G1CollectedHeap::heap()->heap_region_iterate(&blk);

View File

@ -38,11 +38,11 @@ class G1RemSetSummary {
size_t _num_vtimes;
double* _rs_threads_vtimes;
double _sampling_thread_vtime;
double _service_thread_vtime;
void set_rs_thread_vtime(uint thread, double value);
void set_sampling_thread_vtime(double value) {
_sampling_thread_vtime = value;
void set_service_thread_vtime(double value) {
_service_thread_vtime = value;
}
// update this summary with current data from various places
@ -62,8 +62,8 @@ public:
double rs_thread_vtime(uint thread) const;
double sampling_thread_vtime() const {
return _sampling_thread_vtime;
double service_thread_vtime() const {
return _service_thread_vtime;
}
size_t num_coarsenings() const {

View File

@ -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
@ -28,26 +28,27 @@
#include "gc/g1/g1ConcurrentMark.inline.hpp"
#include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
#include "gc/g1/g1Policy.hpp"
#include "gc/g1/g1YoungRemSetSamplingThread.hpp"
#include "gc/g1/g1ServiceThread.hpp"
#include "gc/g1/heapRegion.inline.hpp"
#include "gc/g1/heapRegionRemSet.hpp"
#include "gc/shared/suspendibleThreadSet.hpp"
#include "memory/universe.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/os.hpp"
G1YoungRemSetSamplingThread::G1YoungRemSetSamplingThread() :
G1ServiceThread::G1ServiceThread() :
ConcurrentGCThread(),
_monitor(Mutex::nonleaf,
"G1YoungRemSetSamplingThread monitor",
"G1ServiceThread monitor",
true,
Monitor::_safepoint_check_never),
_last_periodic_gc_attempt_s(os::elapsedTime()),
_vtime_accum(0) {
set_name("G1 Young RemSet Sampling");
set_name("G1 Service");
create_and_start();
}
void G1YoungRemSetSamplingThread::sleep_before_next_cycle() {
void G1ServiceThread::sleep_before_next_cycle() {
MonitorLocker ml(&_monitor, Mutex::_no_safepoint_check_flag);
if (!should_terminate()) {
uintx waitms = G1ConcRefinementServiceIntervalMillis;
@ -55,7 +56,7 @@ void G1YoungRemSetSamplingThread::sleep_before_next_cycle() {
}
}
bool G1YoungRemSetSamplingThread::should_start_periodic_gc() {
bool G1ServiceThread::should_start_periodic_gc() {
G1CollectedHeap* g1h = G1CollectedHeap::heap();
// If we are currently in a concurrent mark we are going to uncommit memory soon.
if (g1h->concurrent_mark()->cm_thread()->during_cycle()) {
@ -83,7 +84,7 @@ bool G1YoungRemSetSamplingThread::should_start_periodic_gc() {
return true;
}
void G1YoungRemSetSamplingThread::check_for_periodic_gc(){
void G1ServiceThread::check_for_periodic_gc(){
// If disabled, just return.
if (G1PeriodicGCInterval == 0) {
return;
@ -99,7 +100,7 @@ void G1YoungRemSetSamplingThread::check_for_periodic_gc(){
}
}
void G1YoungRemSetSamplingThread::run_service() {
void G1ServiceThread::run_service() {
double vtime_start = os::elapsedVTime();
while (!should_terminate()) {
@ -117,7 +118,7 @@ void G1YoungRemSetSamplingThread::run_service() {
}
}
void G1YoungRemSetSamplingThread::stop_service() {
void G1ServiceThread::stop_service() {
MutexLocker x(&_monitor, Mutex::_no_safepoint_check_flag);
_monitor.notify();
}
@ -154,7 +155,7 @@ public:
size_t sampled_rs_length() const { return _sampled_rs_length; }
};
void G1YoungRemSetSamplingThread::sample_young_list_rs_length() {
void G1ServiceThread::sample_young_list_rs_length() {
SuspendibleThreadSetJoiner sts;
G1CollectedHeap* g1h = G1CollectedHeap::heap();
G1Policy* policy = g1h->policy();

View File

@ -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
@ -22,24 +22,17 @@
*
*/
#ifndef SHARE_GC_G1_G1YOUNGREMSETSAMPLINGTHREAD_HPP
#define SHARE_GC_G1_G1YOUNGREMSETSAMPLINGTHREAD_HPP
#ifndef SHARE_GC_G1_G1SERVICETHREAD_HPP
#define SHARE_GC_G1_G1SERVICETHREAD_HPP
#include "gc/shared/concurrentGCThread.hpp"
#include "runtime/mutex.hpp"
// The G1YoungRemSetSamplingThread is used to re-assess the validity of
// the prediction for the remembered set lengths of the young generation.
//
// At the end of the GC G1 determines the length of the young gen based on
// how much time the next GC can take, and when the next GC may occur
// according to the MMU.
//
// The assumption is that a significant part of the GC is spent on scanning
// the remembered sets (and many other components), so this thread constantly
// reevaluates the prediction for the remembered set scanning costs, and potentially
// G1Policy resizes the young gen. This may do a premature GC or even
// increase the young gen size to keep pause time length goal.
class G1YoungRemSetSamplingThread: public ConcurrentGCThread {
// The G1ServiceThread is used to periodically do a number of different tasks:
// - re-assess the validity of the prediction for the
// remembered set lengths of the young generation.
// - check if a periodic GC should be scheduled.
class G1ServiceThread: public ConcurrentGCThread {
private:
Monitor _monitor;
@ -47,6 +40,17 @@ private:
double _vtime_accum; // Accumulated virtual time.
// Sample the current length of remembered sets for young.
//
// At the end of the GC G1 determines the length of the young gen based on
// how much time the next GC can take, and when the next GC may occur
// according to the MMU.
//
// The assumption is that a significant part of the GC is spent on scanning
// the remembered sets (and many other components), so this thread constantly
// reevaluates the prediction for the remembered set scanning costs, and potentially
// G1Policy resizes the young gen. This may do a premature GC or even
// increase the young gen size to keep pause time length goal.
void sample_young_list_rs_length();
void run_service();
@ -59,8 +63,8 @@ private:
bool should_start_periodic_gc();
public:
G1YoungRemSetSamplingThread();
G1ServiceThread();
double vtime_accum() { return _vtime_accum; }
};
#endif // SHARE_GC_G1_G1YOUNGREMSETSAMPLINGTHREAD_HPP
#endif // SHARE_GC_G1_G1SERVICETHREAD_HPP

View File

@ -131,8 +131,8 @@
range(0, max_intx) \
\
product(uintx, G1ConcRefinementServiceIntervalMillis, 300, \
"The last concurrent refinement thread wakes up every " \
"specified number of milliseconds to do miscellaneous work.") \
"The G1 service thread wakes up every specified number of " \
"milliseconds to do miscellaneous work.") \
range(0, max_jint) \
\
product(size_t, G1ConcRefinementThresholdStep, 2, \