8133043: Clean up code related to termination stats printing

Reformat termination stats related code to make it look more similar to existing code.

Reviewed-by: jwilhelm, jmasa
This commit is contained in:
Thomas Schatzl 2015-08-06 15:49:52 +02:00
parent 6e3ffb1aae
commit 183850cec4
3 changed files with 17 additions and 24 deletions

View File

@ -4449,9 +4449,6 @@ protected:
ParallelTaskTerminator _terminator; ParallelTaskTerminator _terminator;
uint _n_workers; uint _n_workers;
Mutex _stats_lock;
Mutex* stats_lock() { return &_stats_lock; }
public: public:
G1ParTask(G1CollectedHeap* g1h, RefToScanQueueSet *task_queues, G1RootProcessor* root_processor, uint n_workers) G1ParTask(G1CollectedHeap* g1h, RefToScanQueueSet *task_queues, G1RootProcessor* root_processor, uint n_workers)
: AbstractGangTask("G1 collection"), : AbstractGangTask("G1 collection"),
@ -4459,8 +4456,7 @@ public:
_queues(task_queues), _queues(task_queues),
_root_processor(root_processor), _root_processor(root_processor),
_terminator(n_workers, _queues), _terminator(n_workers, _queues),
_n_workers(n_workers), _n_workers(n_workers)
_stats_lock(Mutex::leaf, "parallel G1 stats lock", true)
{} {}
RefToScanQueueSet* queues() { return _queues; } RefToScanQueueSet* queues() { return _queues; }
@ -4587,8 +4583,8 @@ public:
_g1h->update_surviving_young_words(pss.surviving_young_words()+1); _g1h->update_surviving_young_words(pss.surviving_young_words()+1);
if (PrintTerminationStats) { if (PrintTerminationStats) {
MutexLocker x(stats_lock()); MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
pss.print_termination_stats(worker_id); pss.print_termination_stats();
} }
assert(pss.queue_is_empty(), "should be empty"); assert(pss.queue_is_empty(), "should be empty");
@ -5504,7 +5500,9 @@ void G1CollectedHeap::evacuate_collection_set(EvacuationInfo& evacuation_info) {
} }
// The individual threads will set their evac-failure closures. // The individual threads will set their evac-failure closures.
if (PrintTerminationStats) G1ParScanThreadState::print_termination_stats_hdr(); if (PrintTerminationStats) {
G1ParScanThreadState::print_termination_stats_hdr();
}
workers()->run_task(&g1_par_task); workers()->run_task(&g1_par_task);
end_par_time_sec = os::elapsedTime(); end_par_time_sec = os::elapsedTime();

View File

@ -76,32 +76,24 @@ G1ParScanThreadState::~G1ParScanThreadState() {
FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base); FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base);
} }
void void G1ParScanThreadState::print_termination_stats_hdr(outputStream* const st) {
G1ParScanThreadState::print_termination_stats_hdr(outputStream* const st)
{
st->print_raw_cr("GC Termination Stats"); st->print_raw_cr("GC Termination Stats");
st->print_raw_cr(" elapsed --strong roots-- -------termination-------" st->print_raw_cr(" elapsed --strong roots-- -------termination------- ------waste (KiB)------");
" ------waste (KiB)------"); st->print_raw_cr("thr ms ms % ms % attempts total alloc undo");
st->print_raw_cr("thr ms ms % ms % attempts" st->print_raw_cr("--- --------- --------- ------ --------- ------ -------- ------- ------- -------");
" total alloc undo");
st->print_raw_cr("--- --------- --------- ------ --------- ------ --------"
" ------- ------- -------");
} }
void void G1ParScanThreadState::print_termination_stats(outputStream* const st) const {
G1ParScanThreadState::print_termination_stats(int i,
outputStream* const st) const
{
const double elapsed_ms = elapsed_time() * 1000.0; const double elapsed_ms = elapsed_time() * 1000.0;
const double s_roots_ms = strong_roots_time() * 1000.0; const double s_roots_ms = strong_roots_time() * 1000.0;
const double term_ms = term_time() * 1000.0; const double term_ms = term_time() * 1000.0;
size_t alloc_buffer_waste = 0; size_t alloc_buffer_waste = 0;
size_t undo_waste = 0; size_t undo_waste = 0;
_plab_allocator->waste(alloc_buffer_waste, undo_waste); _plab_allocator->waste(alloc_buffer_waste, undo_waste);
st->print_cr("%3d %9.2f %9.2f %6.2f " st->print_cr("%3u %9.2f %9.2f %6.2f "
"%9.2f %6.2f " SIZE_FORMAT_W(8) " " "%9.2f %6.2f " SIZE_FORMAT_W(8) " "
SIZE_FORMAT_W(7) " " SIZE_FORMAT_W(7) " " SIZE_FORMAT_W(7), SIZE_FORMAT_W(7) " " SIZE_FORMAT_W(7) " " SIZE_FORMAT_W(7),
i, elapsed_ms, s_roots_ms, s_roots_ms * 100 / elapsed_ms, _queue_num, elapsed_ms, s_roots_ms, s_roots_ms * 100 / elapsed_ms,
term_ms, term_ms * 100 / elapsed_ms, term_attempts(), term_ms, term_ms * 100 / elapsed_ms, term_attempts(),
(alloc_buffer_waste + undo_waste) * HeapWordSize / K, (alloc_buffer_waste + undo_waste) * HeapWordSize / K,
alloc_buffer_waste * HeapWordSize / K, alloc_buffer_waste * HeapWordSize / K,

View File

@ -139,8 +139,11 @@ class G1ParScanThreadState : public StackObj {
return os::elapsedTime() - _start; return os::elapsedTime() - _start;
} }
// Print the header for the per-thread termination statistics.
static void print_termination_stats_hdr(outputStream* const st = gclog_or_tty); static void print_termination_stats_hdr(outputStream* const st = gclog_or_tty);
void print_termination_stats(int i, outputStream* const st = gclog_or_tty) const;
// Print actual per-thread termination statistics.
void print_termination_stats(outputStream* const st = gclog_or_tty) const;
size_t* surviving_young_words() { size_t* surviving_young_words() {
// We add on to hide entry 0 which accumulates surviving words for // We add on to hide entry 0 which accumulates surviving words for