annotate src/share/vm/gc_implementation/g1/g1RemSet.hpp @ 4769:e72f7eecc96d

8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen Summary: Fixed the output of G1SummarizeRSetStats: too small datatype for the number of concurrently processed cards, added concurrent remembered set thread time retrieval for Linux and Windows (BSD uses os::elapsedTime() now), and other cleanup. The information presented during VM operation is now relative to the previous output, not always cumulative if G1SummarizeRSetStatsPeriod > 0. At VM exit, the code prints a cumulative summary. Reviewed-by: johnc, jwilhelm
author tschatzl
date Tue, 28 May 2013 09:32:06 +0200
parents 194f52aa2f23
children 5888334c9c24
rev   line source
ysr@342 1 /*
johnc@4643 2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
ysr@342 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@342 4 *
ysr@342 5 * This code is free software; you can redistribute it and/or modify it
ysr@342 6 * under the terms of the GNU General Public License version 2 only, as
ysr@342 7 * published by the Free Software Foundation.
ysr@342 8 *
ysr@342 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@342 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@342 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@342 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@342 13 * accompanied this code).
ysr@342 14 *
ysr@342 15 * You should have received a copy of the GNU General Public License version
ysr@342 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@342 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@342 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
ysr@342 22 *
ysr@342 23 */
ysr@342 24
stefank@1879 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_HPP
stefank@1879 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_HPP
stefank@1879 27
tschatzl@4769 28 #include "gc_implementation/g1/g1RemSetSummary.hpp"
tschatzl@4769 29
ysr@342 30 // A G1RemSet provides ways of iterating over pointers into a selected
ysr@342 31 // collection set.
ysr@342 32
ysr@342 33 class G1CollectedHeap;
ysr@342 34 class CardTableModRefBarrierSet;
ysr@342 35 class ConcurrentG1Refine;
ysr@342 36
johnc@1781 37 // A G1RemSet in which each heap region has a rem set that records the
johnc@1781 38 // external heap references into it. Uses a mod ref bs to track updates,
johnc@1781 39 // so that they can be used to update the individual region remsets.
johnc@1781 40
zgu@3465 41 class G1RemSet: public CHeapObj<mtGC> {
tschatzl@4769 42 private:
tschatzl@4769 43 G1RemSetSummary _prev_period_summary;
ysr@342 44 protected:
ysr@342 45 G1CollectedHeap* _g1;
tschatzl@4769 46 size_t _conc_refine_cards;
jmasa@2922 47 uint n_workers();
ysr@342 48
ysr@342 49 protected:
ysr@342 50 enum SomePrivateConstants {
ysr@342 51 UpdateRStoMergeSync = 0,
ysr@342 52 MergeRStoDoDirtySync = 1,
ysr@342 53 DoDirtySync = 2,
ysr@342 54 LastSync = 3,
ysr@342 55
ysr@342 56 SeqTask = 0,
ysr@342 57 NumSeqTasks = 1
ysr@342 58 };
ysr@342 59
johnc@4579 60 CardTableModRefBS* _ct_bs;
johnc@4579 61 SubTasksDone* _seq_task;
johnc@4579 62 G1CollectorPolicy* _g1p;
ysr@342 63
johnc@4579 64 ConcurrentG1Refine* _cg1r;
ysr@342 65
johnc@4579 66 size_t* _cards_scanned;
johnc@4579 67 size_t _total_cards_scanned;
ysr@342 68
johnc@1625 69 // Used for caching the closure that is responsible for scanning
johnc@1625 70 // references into the collection set.
johnc@1625 71 OopsInHeapRegionClosure** _cset_rs_update_cl;
ysr@845 72
tschatzl@4769 73 // Print the given summary info
tschatzl@4769 74 virtual void print_summary_info(G1RemSetSummary * summary, const char * header = NULL);
ysr@342 75 public:
ysr@342 76 // This is called to reset dual hash tables after the gc pause
ysr@342 77 // is finished and the initial hash table is no longer being
ysr@342 78 // scanned.
ysr@342 79 void cleanupHRRS();
ysr@342 80
johnc@1781 81 G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs);
johnc@1781 82 ~G1RemSet();
ysr@342 83
johnc@1781 84 // Invoke "blk->do_oop" on all pointers into the CS in objects in regions
johnc@1781 85 // outside the CS (having invoked "blk->set_region" to set the "from"
johnc@1781 86 // region correctly beforehand.) The "worker_i" param is for the
johnc@1781 87 // parallel case where the number of the worker thread calling this
johnc@1781 88 // function can be helpful in partitioning the work to be done. It
johnc@1781 89 // should be the same as the "i" passed to the calling thread's
johnc@1781 90 // work(i) function. In the sequential case this param will be ingored.
johnc@4643 91 void oops_into_collection_set_do(OopsInHeapRegionClosure* blk, int worker_i);
ysr@342 92
johnc@1781 93 // Prepare for and cleanup after an oops_into_collection_set_do
johnc@1781 94 // call. Must call each of these once before and after (in sequential
johnc@1781 95 // code) any threads call oops_into_collection_set_do. (This offers an
johnc@1781 96 // opportunity to sequential setup and teardown of structures needed by a
johnc@1781 97 // parallel iteration over the CS's RS.)
ysr@342 98 void prepare_for_oops_into_collection_set_do();
ysr@342 99 void cleanup_after_oops_into_collection_set_do();
johnc@1781 100
ysr@342 101 void scanRS(OopsInHeapRegionClosure* oc, int worker_i);
johnc@1625 102 void updateRS(DirtyCardQueue* into_cset_dcq, int worker_i);
johnc@1781 103
ysr@342 104 CardTableModRefBS* ct_bs() { return _ct_bs; }
ysr@342 105 size_t cardsScanned() { return _total_cards_scanned; }
ysr@342 106
ysr@342 107 // Record, if necessary, the fact that *p (where "p" is in region "from",
ysr@342 108 // which is required to be non-NULL) has changed to a new non-NULL value.
johnc@1867 109 template <class T> void write_ref(HeapRegion* from, T* p);
johnc@1867 110 template <class T> void par_write_ref(HeapRegion* from, T* p, int tid);
ysr@342 111
johnc@1781 112 // Requires "region_bm" and "card_bm" to be bitmaps with 1 bit per region
johnc@1781 113 // or card, respectively, such that a region or card with a corresponding
johnc@1781 114 // 0 bit contains no part of any live object. Eliminates any remembered
johnc@1781 115 // set entries that correspond to dead heap ranges.
ysr@342 116 void scrub(BitMap* region_bm, BitMap* card_bm);
johnc@1781 117
johnc@1781 118 // Like the above, but assumes is called in parallel: "worker_num" is the
johnc@1781 119 // parallel thread id of the current thread, and "claim_val" is the
johnc@1781 120 // value that should be used to claim heap regions.
ysr@342 121 void scrub_par(BitMap* region_bm, BitMap* card_bm,
jmasa@2922 122 uint worker_num, int claim_val);
ysr@342 123
johnc@4643 124 // Refine the card corresponding to "card_ptr".
johnc@1781 125 // If check_for_refs_into_cset is true, a true result is returned
johnc@1781 126 // if the given card contains oops that have references into the
johnc@1781 127 // current collection set.
johnc@4643 128 virtual bool refine_card(jbyte* card_ptr,
johnc@4643 129 int worker_i,
johnc@4643 130 bool check_for_refs_into_cset);
ysr@342 131
tschatzl@4769 132 // Print accumulated summary info from the start of the VM.
ysr@342 133 virtual void print_summary_info();
johnc@1781 134
tschatzl@4769 135 // Print accumulated summary info from the last time called.
tschatzl@4769 136 virtual void print_periodic_summary_info();
tschatzl@4769 137
johnc@1781 138 // Prepare remembered set for verification.
ysr@342 139 virtual void prepare_for_verify();
tschatzl@4769 140
tschatzl@4769 141 size_t conc_refine_cards() const {
tschatzl@4769 142 return _conc_refine_cards;
tschatzl@4769 143 }
ysr@342 144 };
ysr@342 145
ysr@342 146 class CountNonCleanMemRegionClosure: public MemRegionClosure {
ysr@342 147 G1CollectedHeap* _g1;
ysr@342 148 int _n;
ysr@342 149 HeapWord* _start_first;
ysr@342 150 public:
ysr@342 151 CountNonCleanMemRegionClosure(G1CollectedHeap* g1) :
ysr@342 152 _g1(g1), _n(0), _start_first(NULL)
ysr@342 153 {}
ysr@342 154 void do_MemRegion(MemRegion mr);
ysr@342 155 int n() { return _n; };
ysr@342 156 HeapWord* start_first() { return _start_first; }
ysr@342 157 };
apetrusenko@626 158
coleenp@3602 159 class UpdateRSOopClosure: public ExtendedOopClosure {
apetrusenko@626 160 HeapRegion* _from;
johnc@1781 161 G1RemSet* _rs;
apetrusenko@626 162 int _worker_i;
ysr@845 163
ysr@845 164 template <class T> void do_oop_work(T* p);
ysr@845 165
apetrusenko@626 166 public:
johnc@1781 167 UpdateRSOopClosure(G1RemSet* rs, int worker_i = 0) :
johnc@1867 168 _from(NULL), _rs(rs), _worker_i(worker_i)
johnc@1867 169 {}
apetrusenko@626 170
apetrusenko@626 171 void set_from(HeapRegion* from) {
apetrusenko@626 172 assert(from != NULL, "from region must be non-NULL");
apetrusenko@626 173 _from = from;
apetrusenko@626 174 }
apetrusenko@626 175
ysr@845 176 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
ysr@845 177 virtual void do_oop(oop* p) { do_oop_work(p); }
apetrusenko@626 178
apetrusenko@626 179 // Override: this closure is idempotent.
apetrusenko@626 180 // bool idempotent() { return true; }
apetrusenko@626 181 bool apply_to_weak_ref_discovered_field() { return true; }
apetrusenko@626 182 };
johnc@1625 183
johnc@1625 184 class UpdateRSetImmediate: public OopsInHeapRegionClosure {
johnc@1625 185 private:
johnc@1625 186 G1RemSet* _g1_rem_set;
johnc@1625 187
johnc@1625 188 template <class T> void do_oop_work(T* p);
johnc@1625 189 public:
johnc@1625 190 UpdateRSetImmediate(G1RemSet* rs) :
johnc@1625 191 _g1_rem_set(rs) {}
johnc@1625 192
johnc@1625 193 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
johnc@1625 194 virtual void do_oop( oop* p) { do_oop_work(p); }
johnc@1625 195 };
johnc@1867 196
stefank@1879 197
stefank@1879 198 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_HPP