@@ -530,16 +530,13 @@ bool G1DirtyCardQueueSet::refine_completed_buffer_concurrently(uint worker_id,
530
530
return true ;
531
531
}
532
532
533
- void G1DirtyCardQueueSet::abandon_logs () {
533
+ void G1DirtyCardQueueSet::abandon_logs_and_stats () {
534
534
assert_at_safepoint ();
535
- abandon_completed_buffers ();
536
- _detached_refinement_stats.reset ();
537
535
538
536
// Disable mutator refinement until concurrent refinement decides otherwise.
539
537
set_mutator_refinement_threshold (SIZE_MAX);
540
538
541
- // Since abandon is done only at safepoints, we can safely manipulate
542
- // these queues.
539
+ // Iterate over all the threads, resetting per-thread queues and stats.
543
540
struct AbandonThreadLogClosure : public ThreadClosure {
544
541
G1DirtyCardQueueSet& _qset;
545
542
AbandonThreadLogClosure (G1DirtyCardQueueSet& qset) : _qset(qset) {}
@@ -550,9 +547,16 @@ void G1DirtyCardQueueSet::abandon_logs() {
550
547
}
551
548
} closure (*this );
552
549
Threads::threads_do (&closure);
550
+
551
+ enqueue_all_paused_buffers ();
552
+ abandon_completed_buffers ();
553
+
554
+ // Reset stats from detached threads.
555
+ MutexLocker ml (G1DetachedRefinementStats_lock, Mutex::_no_safepoint_check_flag);
556
+ _detached_refinement_stats.reset ();
553
557
}
554
558
555
- void G1DirtyCardQueueSet::concatenate_logs () {
559
+ void G1DirtyCardQueueSet::concatenate_logs_and_stats () {
556
560
assert_at_safepoint ();
557
561
558
562
// Disable mutator refinement until concurrent refinement decides otherwise.
@@ -562,47 +566,39 @@ void G1DirtyCardQueueSet::concatenate_logs() {
562
566
// the global list of logs.
563
567
struct ConcatenateThreadLogClosure : public ThreadClosure {
564
568
G1DirtyCardQueueSet& _qset;
565
- ConcatenateThreadLogClosure (G1DirtyCardQueueSet& qset) : _qset(qset) {}
569
+ G1ConcurrentRefineStats _total_stats;
570
+
571
+ ConcatenateThreadLogClosure (G1DirtyCardQueueSet& qset) :
572
+ _qset{qset}, _total_stats{} {}
573
+
566
574
virtual void do_thread (Thread* t) {
567
575
G1DirtyCardQueue& queue = G1ThreadLocalData::dirty_card_queue (t);
576
+ // Flush the buffer if non-empty. Flush before accumulating and
577
+ // resetting stats, since flushing may modify the stats.
568
578
if ((queue.buffer () != nullptr ) &&
569
579
(queue.index () != _qset.buffer_size ())) {
570
580
_qset.flush_queue (queue);
571
581
}
582
+ G1ConcurrentRefineStats& qstats = *queue.refinement_stats ();
583
+ _total_stats += qstats;
584
+ qstats.reset ();
572
585
}
573
586
} closure (*this );
574
587
Threads::threads_do (&closure);
588
+ _concatenated_refinement_stats = closure._total_stats ;
575
589
576
590
enqueue_all_paused_buffers ();
577
591
verify_num_cards ();
578
- }
579
-
580
- G1ConcurrentRefineStats G1DirtyCardQueueSet::get_and_reset_refinement_stats () {
581
- assert_at_safepoint ();
582
-
583
- // Since we're at a safepoint, there aren't any races with recording of
584
- // detached refinement stats. In particular, there's no risk of double
585
- // counting a thread that detaches after we've examined it but before
586
- // we've processed the detached stats.
587
-
588
- // Collect and reset stats for attached threads.
589
- struct CollectStats : public ThreadClosure {
590
- G1ConcurrentRefineStats _total_stats;
591
- virtual void do_thread (Thread* t) {
592
- G1DirtyCardQueue& dcq = G1ThreadLocalData::dirty_card_queue (t);
593
- G1ConcurrentRefineStats& stats = *dcq.refinement_stats ();
594
- _total_stats += stats;
595
- stats.reset ();
596
- }
597
- } closure;
598
- Threads::threads_do (&closure);
599
592
600
593
// Collect and reset stats from detached threads.
601
594
MutexLocker ml (G1DetachedRefinementStats_lock, Mutex::_no_safepoint_check_flag);
602
- closure. _total_stats += _detached_refinement_stats;
595
+ _concatenated_refinement_stats += _detached_refinement_stats;
603
596
_detached_refinement_stats.reset ();
597
+ }
604
598
605
- return closure._total_stats ;
599
+ G1ConcurrentRefineStats G1DirtyCardQueueSet::concatenated_refinement_stats () const {
600
+ assert_at_safepoint ();
601
+ return _concatenated_refinement_stats;
606
602
}
607
603
608
604
void G1DirtyCardQueueSet::record_detached_refinement_stats (G1ConcurrentRefineStats* stats) {
0 commit comments