comparison src/share/vm/gc_implementation/g1/g1RemSet.cpp @ 6254:a2f7274eb6ef

7114678: G1: various small fixes, code cleanup, and refactoring Summary: Various cleanups as a prelude to introducing iterators for HeapRegions. Reviewed-by: johnc, brutisso
author tonyp
date Thu, 19 Jul 2012 15:15:54 -0700
parents 3a431b605145
children bb3f6194fedb
comparison
equal deleted inserted replaced
6253:db823a892a55 6254:a2f7274eb6ef
278 } 278 }
279 279
280 _g1p->phase_times()->record_update_rs_time(worker_i, (os::elapsedTime() - start) * 1000.0); 280 _g1p->phase_times()->record_update_rs_time(worker_i, (os::elapsedTime() - start) * 1000.0);
281 } 281 }
282 282
283 class CountRSSizeClosure: public HeapRegionClosure {
284 size_t _n;
285 size_t _tot;
286 size_t _max;
287 HeapRegion* _max_r;
288 enum {
289 N = 20,
290 MIN = 6
291 };
292 int _histo[N];
293 public:
294 CountRSSizeClosure() : _n(0), _tot(0), _max(0), _max_r(NULL) {
295 for (int i = 0; i < N; i++) _histo[i] = 0;
296 }
297 bool doHeapRegion(HeapRegion* r) {
298 if (!r->continuesHumongous()) {
299 size_t occ = r->rem_set()->occupied();
300 _n++;
301 _tot += occ;
302 if (occ > _max) {
303 _max = occ;
304 _max_r = r;
305 }
306 // Fit it into a histo bin.
307 int s = 1 << MIN;
308 int i = 0;
309 while (occ > (size_t) s && i < (N-1)) {
310 s = s << 1;
311 i++;
312 }
313 _histo[i]++;
314 }
315 return false;
316 }
317 size_t n() { return _n; }
318 size_t tot() { return _tot; }
319 size_t mx() { return _max; }
320 HeapRegion* mxr() { return _max_r; }
321 void print_histo() {
322 int mx = N;
323 while (mx >= 0) {
324 if (_histo[mx-1] > 0) break;
325 mx--;
326 }
327 gclog_or_tty->print_cr("Number of regions with given RS sizes:");
328 gclog_or_tty->print_cr(" <= %8d %8d", 1 << MIN, _histo[0]);
329 for (int i = 1; i < mx-1; i++) {
330 gclog_or_tty->print_cr(" %8d - %8d %8d",
331 (1 << (MIN + i - 1)) + 1,
332 1 << (MIN + i),
333 _histo[i]);
334 }
335 gclog_or_tty->print_cr(" > %8d %8d", (1 << (MIN+mx-2))+1, _histo[mx-1]);
336 }
337 };
338
339 void G1RemSet::cleanupHRRS() { 283 void G1RemSet::cleanupHRRS() {
340 HeapRegionRemSet::cleanup(); 284 HeapRegionRemSet::cleanup();
341 } 285 }
342 286
343 void G1RemSet::oops_into_collection_set_do(OopsInHeapRegionClosure* oc, 287 void G1RemSet::oops_into_collection_set_do(OopsInHeapRegionClosure* oc,
345 #if CARD_REPEAT_HISTO 289 #if CARD_REPEAT_HISTO
346 ct_freq_update_histo_and_reset(); 290 ct_freq_update_histo_and_reset();
347 #endif 291 #endif
348 if (worker_i == 0) { 292 if (worker_i == 0) {
349 _cg1r->clear_and_record_card_counts(); 293 _cg1r->clear_and_record_card_counts();
350 }
351
352 // Make this into a command-line flag...
353 if (G1RSCountHisto && (ParallelGCThreads == 0 || worker_i == 0)) {
354 CountRSSizeClosure count_cl;
355 _g1->heap_region_iterate(&count_cl);
356 gclog_or_tty->print_cr("Avg of %d RS counts is %f, max is %d, "
357 "max region is " PTR_FORMAT,
358 count_cl.n(), (float)count_cl.tot()/(float)count_cl.n(),
359 count_cl.mx(), count_cl.mxr());
360 count_cl.print_histo();
361 } 294 }
362 295
363 // We cache the value of 'oc' closure into the appropriate slot in the 296 // We cache the value of 'oc' closure into the appropriate slot in the
364 // _cset_rs_update_cl for this worker 297 // _cset_rs_update_cl for this worker
365 assert(worker_i < (int)n_workers(), "sanity"); 298 assert(worker_i < (int)n_workers(), "sanity");
566 n_workers(), 499 n_workers(),
567 claim_val); 500 claim_val);
568 } 501 }
569 502
570 503
571 static IntHistogram out_of_histo(50, 50);
572
573 504
574 G1TriggerClosure::G1TriggerClosure() : 505 G1TriggerClosure::G1TriggerClosure() :
575 _triggered(false) { } 506 _triggered(false) { }
576 507
577 G1InvokeIfNotTriggeredClosure::G1InvokeIfNotTriggeredClosure(G1TriggerClosure* t_cl, 508 G1InvokeIfNotTriggeredClosure::G1InvokeIfNotTriggeredClosure(G1TriggerClosure* t_cl,
669 DirtyCardQueue* sdcq = 600 DirtyCardQueue* sdcq =
670 JavaThread::dirty_card_queue_set().shared_dirty_card_queue(); 601 JavaThread::dirty_card_queue_set().shared_dirty_card_queue();
671 sdcq->enqueue(card_ptr); 602 sdcq->enqueue(card_ptr);
672 } 603 }
673 } else { 604 } else {
674 out_of_histo.add_entry(filter_then_update_rs_oop_cl.out_of_region());
675 _conc_refine_cards++; 605 _conc_refine_cards++;
676 } 606 }
677 607
678 return trigger_cl.triggered(); 608 return trigger_cl.triggered();
679 } 609 }
860 gclog_or_tty->print_cr("\nG1 card_repeat count histogram: "); 790 gclog_or_tty->print_cr("\nG1 card_repeat count histogram: ");
861 gclog_or_tty->print_cr(" # of repeats --> # of cards with that number."); 791 gclog_or_tty->print_cr(" # of repeats --> # of cards with that number.");
862 card_repeat_count.print_on(gclog_or_tty); 792 card_repeat_count.print_on(gclog_or_tty);
863 #endif 793 #endif
864 794
865 if (FILTEROUTOFREGIONCLOSURE_DOHISTOGRAMCOUNT) {
866 gclog_or_tty->print_cr("\nG1 rem-set out-of-region histogram: ");
867 gclog_or_tty->print_cr(" # of CS ptrs --> # of cards with that number.");
868 out_of_histo.print_on(gclog_or_tty);
869 }
870 gclog_or_tty->print_cr("\n Concurrent RS processed %d cards", 795 gclog_or_tty->print_cr("\n Concurrent RS processed %d cards",
871 _conc_refine_cards); 796 _conc_refine_cards);
872 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); 797 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
873 jint tot_processed_buffers = 798 jint tot_processed_buffers =
874 dcqs.processed_buffers_mut() + dcqs.processed_buffers_rs_thread(); 799 dcqs.processed_buffers_mut() + dcqs.processed_buffers_rs_thread();
887 g1->concurrent_g1_refine()->threads_do(&p); 812 g1->concurrent_g1_refine()->threads_do(&p);
888 gclog_or_tty->print_cr(""); 813 gclog_or_tty->print_cr("");
889 814
890 HRRSStatsIter blk; 815 HRRSStatsIter blk;
891 g1->heap_region_iterate(&blk); 816 g1->heap_region_iterate(&blk);
892 gclog_or_tty->print_cr(" Total heap region rem set sizes = " SIZE_FORMAT "K." 817 gclog_or_tty->print_cr(" Total heap region rem set sizes = "SIZE_FORMAT"K."
893 " Max = " SIZE_FORMAT "K.", 818 " Max = "SIZE_FORMAT"K.",
894 blk.total_mem_sz()/K, blk.max_mem_sz()/K); 819 blk.total_mem_sz()/K, blk.max_mem_sz()/K);
895 gclog_or_tty->print_cr(" Static structures = " SIZE_FORMAT "K," 820 gclog_or_tty->print_cr(" Static structures = "SIZE_FORMAT"K,"
896 " free_lists = " SIZE_FORMAT "K.", 821 " free_lists = "SIZE_FORMAT"K.",
897 HeapRegionRemSet::static_mem_size()/K, 822 HeapRegionRemSet::static_mem_size() / K,
898 HeapRegionRemSet::fl_mem_size()/K); 823 HeapRegionRemSet::fl_mem_size() / K);
899 gclog_or_tty->print_cr(" %d occupied cards represented.", 824 gclog_or_tty->print_cr(" "SIZE_FORMAT" occupied cards represented.",
900 blk.occupied()); 825 blk.occupied());
901 gclog_or_tty->print_cr(" Max sz region = [" PTR_FORMAT ", " PTR_FORMAT " )" 826 HeapRegion* max_mem_sz_region = blk.max_mem_sz_region();
902 ", cap = " SIZE_FORMAT "K, occ = " SIZE_FORMAT "K.", 827 HeapRegionRemSet* rem_set = max_mem_sz_region->rem_set();
903 blk.max_mem_sz_region()->bottom(), blk.max_mem_sz_region()->end(), 828 gclog_or_tty->print_cr(" Max size region = "HR_FORMAT", "
904 (blk.max_mem_sz_region()->rem_set()->mem_size() + K - 1)/K, 829 "size = "SIZE_FORMAT "K, occupied = "SIZE_FORMAT"K.",
905 (blk.max_mem_sz_region()->rem_set()->occupied() + K - 1)/K); 830 HR_FORMAT_PARAMS(max_mem_sz_region),
906 gclog_or_tty->print_cr(" Did %d coarsenings.", HeapRegionRemSet::n_coarsenings()); 831 (rem_set->mem_size() + K - 1)/K,
832 (rem_set->occupied() + K - 1)/K);
833 gclog_or_tty->print_cr(" Did %d coarsenings.",
834 HeapRegionRemSet::n_coarsenings());
907 } 835 }
908 836
909 void G1RemSet::prepare_for_verify() { 837 void G1RemSet::prepare_for_verify() {
910 if (G1HRRSFlushLogBuffersOnVerify && 838 if (G1HRRSFlushLogBuffersOnVerify &&
911 (VerifyBeforeGC || VerifyAfterGC) 839 (VerifyBeforeGC || VerifyAfterGC)