< prev index next >
src/share/vm/gc_implementation/g1/g1HotCardCache.hpp
Print this page
rev 7695 : 8069273: Reduce Hot Card Cache Lock contention
Reviewed-by: tschatzl
rev 7696 : [mq]: atomicadd
@@ -52,25 +52,34 @@
//
// This can significantly reduce the overhead of the write barrier
// code, increasing throughput.
class G1HotCardCache: public CHeapObj<mtGC> {
+
G1CollectedHeap* _g1h;
+ bool _use_cache;
+
+ G1CardCounts _card_counts;
+
// The card cache table
jbyte** _hot_cache;
- int _hot_cache_size;
- int _n_hot;
- int _hot_cache_idx;
+ size_t _hot_cache_size;
int _hot_cache_par_chunk_size;
- volatile int _hot_cache_par_claimed_idx;
- bool _use_cache;
+ // Avoids false sharing when concurrently updating _hot_cache_idx or
+ // _hot_cache_par_claimed_idx. These are never updated at the same time
+ // thus it's not necessary to separate them as well
+ char _pad_before[DEFAULT_CACHE_LINE_SIZE];
- G1CardCounts _card_counts;
+ volatile size_t _hot_cache_idx;
+
+ volatile size_t _hot_cache_par_claimed_idx;
+
+ char _pad_after[DEFAULT_CACHE_LINE_SIZE];
// The number of cached cards a thread claims when flushing the cache
static const int ClaimChunkSize = 32;
bool default_use_cache() const {
@@ -111,14 +120,18 @@
// Resets the hot card cache and discards the entries.
void reset_hot_cache() {
assert(SafepointSynchronize::is_at_safepoint(), "Should be at a safepoint");
assert(Thread::current()->is_VM_thread(), "Current thread should be the VMthread");
- _hot_cache_idx = 0; _n_hot = 0;
+ if (default_use_cache()) {
+ assert(_hot_cache != NULL, "Logic");
+ _hot_cache_idx = 0;
+ for (size_t i = 0; i < _hot_cache_size; i++) {
+ _hot_cache[i] = NULL;
+ }
+ }
}
-
- bool hot_cache_is_empty() { return _n_hot == 0; }
// Zeros the values in the card counts table for entire committed heap
void reset_card_counts();
// Zeros the values in the card counts table for the given region
< prev index next >