# HG changeset patch # User tschatzl # Date 1509974718 -3600 # Node ID 4925ee84b4acc4c86800258fb8b6592cf2545bc2 # Parent a77a7d3bc4f6759773260097d4ee201746a5d8f0 8140255: Move the management of G1YoungRemSetSamplingThread from G1ConcurrentRefine Reviewed-by: sjohanss, sangheki diff -r a77a7d3bc4f6 -r 4925ee84b4ac src/hotspot/share/gc/g1/g1CollectedHeap.cpp --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Mon Nov 06 14:24:31 2017 +0100 +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Mon Nov 06 14:25:18 2017 +0100 @@ -54,6 +54,7 @@ #include "gc/g1/g1SerialFullCollector.hpp" #include "gc/g1/g1StringDedup.hpp" #include "gc/g1/g1YCTypes.hpp" +#include "gc/g1/g1YoungRemSetSamplingThread.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" #include "gc/g1/heapRegionSet.inline.hpp" @@ -1541,6 +1542,7 @@ G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* collector_policy) : CollectedHeap(), + _young_gen_sampling_thread(NULL), _collector_policy(collector_policy), _gc_timer_stw(new (ResourceObj::C_HEAP, mtGC) STWGCTimer()), _gc_tracer_stw(new (ResourceObj::C_HEAP, mtGC) G1NewTracer()), @@ -1637,6 +1639,15 @@ 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"); + return JNI_ENOMEM; + } + return JNI_OK; +} + jint G1CollectedHeap::initialize() { CollectedHeap::pre_initialize(); os::enable_vtime(); @@ -1789,6 +1800,11 @@ return ecode; } + ecode = initialize_young_gen_sampling_thread(); + if (ecode != JNI_OK) { + return ecode; + } + JavaThread::dirty_card_queue_set().initialize(DirtyCardQ_CBL_mon, DirtyCardQ_FL_lock, (int)concurrent_refine()->yellow_zone(), @@ -1837,6 +1853,7 @@ // do not continue to execute and access resources (e.g. logging) // that are destroyed during shutdown. _cr->stop(); + _young_gen_sampling_thread->stop(); _cmThread->stop(); if (G1StringDedup::is_enabled()) { G1StringDedup::stop(); @@ -2436,7 +2453,8 @@ _cmThread->print_on(st); st->cr(); _cm->print_worker_threads_on(st); - _cr->print_worker_threads_on(st); // also prints the sample thread + _cr->print_threads_on(st); + _young_gen_sampling_thread->print_on(st); if (G1StringDedup::is_enabled()) { G1StringDedup::print_worker_threads_on(st); } @@ -2446,7 +2464,8 @@ workers()->threads_do(tc); tc->do_thread(_cmThread); _cm->threads_do(tc); - _cr->threads_do(tc); // also iterates over the sample thread + _cr->threads_do(tc); + tc->do_thread(_young_gen_sampling_thread); if (G1StringDedup::is_enabled()) { G1StringDedup::threads_do(tc); } diff -r a77a7d3bc4f6 -r 4925ee84b4ac src/hotspot/share/gc/g1/g1CollectedHeap.hpp --- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp Mon Nov 06 14:24:31 2017 +0100 +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp Mon Nov 06 14:25:18 2017 +0100 @@ -73,6 +73,7 @@ class G1Policy; class G1HotCardCache; class G1RemSet; +class G1YoungRemSetSamplingThread; class HeapRegionRemSetIterator; class G1ConcurrentMark; class ConcurrentMarkThread; @@ -142,6 +143,8 @@ friend class G1CheckCSetFastTableClosure; private: + G1YoungRemSetSamplingThread* _young_gen_sampling_thread; + WorkGang* _workers; G1CollectorPolicy* _collector_policy; @@ -553,6 +556,8 @@ // during GC into global variables. void merge_per_thread_state_info(G1ParScanThreadStateSet* per_thread_states); public: + G1YoungRemSetSamplingThread* sampling_thread() const { return _young_gen_sampling_thread; } + WorkGang* workers() const { return _workers; } G1Allocator* allocator() { @@ -959,6 +964,7 @@ private: jint initialize_concurrent_refinement(); + jint initialize_young_gen_sampling_thread(); public: // Initialize the G1CollectedHeap to have the initial and // maximum sizes and remembered and barrier sets diff -r a77a7d3bc4f6 -r 4925ee84b4ac src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp --- a/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp Mon Nov 06 14:24:31 2017 +0100 +++ b/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp Mon Nov 06 14:25:18 2017 +0100 @@ -25,7 +25,6 @@ #include "precompiled.hpp" #include "gc/g1/g1ConcurrentRefine.hpp" #include "gc/g1/g1ConcurrentRefineThread.hpp" -#include "gc/g1/g1YoungRemSetSamplingThread.hpp" #include "logging/log.hpp" #include "runtime/java.hpp" #include "runtime/thread.hpp" @@ -117,7 +116,6 @@ size_t red_zone, size_t min_yellow_zone_size) : _threads(NULL), - _sample_thread(NULL), _n_worker_threads(thread_num()), _green_zone(green_zone), _yellow_zone(yellow_zone), @@ -224,13 +222,6 @@ next = t; } - cr->_sample_thread = new G1YoungRemSetSamplingThread(); - if (cr->_sample_thread->osthread() == NULL) { - *ecode = JNI_ENOMEM; - vm_shutdown_during_initialization("Could not create G1YoungRemSetSamplingThread"); - return NULL; - } - *ecode = JNI_OK; return cr; } @@ -239,7 +230,6 @@ for (uint i = 0; i < _n_worker_threads; i++) { _threads[i]->stop(); } - _sample_thread->stop(); } void G1ConcurrentRefine::update_thread_thresholds() { @@ -255,16 +245,9 @@ delete _threads[i]; } FREE_C_HEAP_ARRAY(G1ConcurrentRefineThread*, _threads); - - delete _sample_thread; } void G1ConcurrentRefine::threads_do(ThreadClosure *tc) { - worker_threads_do(tc); - tc->do_thread(_sample_thread); -} - -void G1ConcurrentRefine::worker_threads_do(ThreadClosure * tc) { for (uint i = 0; i < _n_worker_threads; i++) { tc->do_thread(_threads[i]); } @@ -274,13 +257,11 @@ return G1ConcRefinementThreads; } -void G1ConcurrentRefine::print_worker_threads_on(outputStream* st) const { +void G1ConcurrentRefine::print_threads_on(outputStream* st) const { for (uint i = 0; i < _n_worker_threads; ++i) { _threads[i]->print_on(st); st->cr(); } - _sample_thread->print_on(st); - st->cr(); } static size_t calc_new_green_zone(size_t green, diff -r a77a7d3bc4f6 -r 4925ee84b4ac src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp --- a/src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp Mon Nov 06 14:24:31 2017 +0100 +++ b/src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp Mon Nov 06 14:25:18 2017 +0100 @@ -31,13 +31,10 @@ // Forward decl class CardTableEntryClosure; class G1ConcurrentRefineThread; -class G1YoungRemSetSamplingThread; class outputStream; class ThreadClosure; class G1ConcurrentRefine : public CHeapObj { - G1YoungRemSetSamplingThread* _sample_thread; - G1ConcurrentRefineThread** _threads; uint _n_worker_threads; /* @@ -86,18 +83,12 @@ void adjust(double update_rs_time, size_t update_rs_processed_buffers, double goal_ms); - // Iterate over all concurrent refinement threads + // Iterate over all concurrent refinement threads applying the given closure. void threads_do(ThreadClosure *tc); - // Iterate over all worker refinement threads - void worker_threads_do(ThreadClosure * tc); - - // The RS sampling thread has nothing to do with refinement, but is here for now. - G1YoungRemSetSamplingThread * sampling_thread() const { return _sample_thread; } - static uint thread_num(); - void print_worker_threads_on(outputStream* st) const; + void print_threads_on(outputStream* st) const; size_t green_zone() const { return _green_zone; } size_t yellow_zone() const { return _yellow_zone; } diff -r a77a7d3bc4f6 -r 4925ee84b4ac src/hotspot/share/gc/g1/g1RemSetSummary.cpp --- a/src/hotspot/share/gc/g1/g1RemSetSummary.cpp Mon Nov 06 14:24:31 2017 +0100 +++ b/src/hotspot/share/gc/g1/g1RemSetSummary.cpp Mon Nov 06 14:25:18 2017 +0100 @@ -59,12 +59,13 @@ _num_coarsenings = HeapRegionRemSet::n_coarsenings(); - G1ConcurrentRefine * cr = G1CollectedHeap::heap()->concurrent_refine(); + G1CollectedHeap* g1h = G1CollectedHeap::heap(); + G1ConcurrentRefine* cg1r = g1h->concurrent_refine(); if (_rs_threads_vtimes != NULL) { GetRSThreadVTimeClosure p(this); - cr->worker_threads_do(&p); + cg1r->threads_do(&p); } - set_sampling_thread_vtime(cr->sampling_thread()->vtime_accum()); + set_sampling_thread_vtime(g1h->sampling_thread()->vtime_accum()); } void G1RemSetSummary::set_rs_thread_vtime(uint thread, double value) {