src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp

Mon, 03 Aug 2009 12:59:30 -0700

author
johnc
date
Mon, 03 Aug 2009 12:59:30 -0700
changeset 1324
15c5903cf9e1
parent 1230
215f81b4d9b3
child 1325
6cb8e9df7174
permissions
-rw-r--r--

6865703: G1: Parallelize hot card cache cleanup
Summary: Have the GC worker threads clear the hot card cache in parallel by having each worker thread claim a chunk of the card cache and process the cards in that chunk. The size of the chunks that each thread will claim is determined at VM initialization from the size of the card cache and the number of worker threads.
Reviewed-by: jmasa, tonyp

ysr@777 1 /*
xdono@1014 2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
ysr@777 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@777 4 *
ysr@777 5 * This code is free software; you can redistribute it and/or modify it
ysr@777 6 * under the terms of the GNU General Public License version 2 only, as
ysr@777 7 * published by the Free Software Foundation.
ysr@777 8 *
ysr@777 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@777 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@777 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@777 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@777 13 * accompanied this code).
ysr@777 14 *
ysr@777 15 * You should have received a copy of the GNU General Public License version
ysr@777 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@777 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@777 18 *
ysr@777 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
ysr@777 20 * CA 95054 USA or visit www.sun.com if you need additional information or
ysr@777 21 * have any questions.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
ysr@777 25 // Forward decl
ysr@777 26 class ConcurrentG1RefineThread;
ysr@777 27 class G1RemSet;
ysr@777 28
apetrusenko@984 29 class ConcurrentG1Refine: public CHeapObj {
iveresov@1229 30 ConcurrentG1RefineThread** _threads;
iveresov@1229 31 int _n_threads;
ysr@777 32 // The cache for card refinement.
ysr@777 33 bool _use_cache;
ysr@777 34 bool _def_use_cache;
ysr@777 35 size_t _n_periods;
ysr@777 36 size_t _total_cards;
ysr@777 37 size_t _total_travs;
ysr@777 38
johnc@1324 39 unsigned char* _card_counts;
johnc@1324 40 unsigned _n_card_counts;
johnc@1324 41 const jbyte* _ct_bot;
johnc@1324 42 unsigned* _cur_card_count_histo;
johnc@1324 43 unsigned* _cum_card_count_histo;
johnc@1324 44
johnc@1324 45 jbyte** _hot_cache;
johnc@1324 46 int _hot_cache_size;
johnc@1324 47 int _n_hot;
johnc@1324 48 int _hot_cache_idx;
johnc@1324 49
johnc@1324 50 int _hot_cache_par_chunk_size;
johnc@1324 51 volatile int _hot_cache_par_claimed_idx;
ysr@777 52
ysr@777 53 // Returns the count of this card after incrementing it.
ysr@777 54 int add_card_count(jbyte* card_ptr);
ysr@777 55
ysr@777 56 void print_card_count_histo_range(unsigned* histo, int from, int to,
ysr@777 57 float& cum_card_pct,
ysr@777 58 float& cum_travs_pct);
ysr@777 59 public:
ysr@777 60 ConcurrentG1Refine();
ysr@777 61 ~ConcurrentG1Refine();
ysr@777 62
ysr@777 63 void init(); // Accomplish some initialization that has to wait.
iveresov@1229 64 void stop();
ysr@777 65
iveresov@1229 66 // Iterate over the conc refine threads
iveresov@1229 67 void threads_do(ThreadClosure *tc);
ysr@777 68
ysr@777 69 // If this is the first entry for the slot, writes into the cache and
ysr@777 70 // returns NULL. If it causes an eviction, returns the evicted pointer.
ysr@777 71 // Otherwise, its a cache hit, and returns NULL.
ysr@777 72 jbyte* cache_insert(jbyte* card_ptr);
ysr@777 73
ysr@777 74 // Process the cached entries.
ysr@777 75 void clean_up_cache(int worker_i, G1RemSet* g1rs);
ysr@777 76
johnc@1324 77 // Set up for parallel processing of the cards in the hot cache
johnc@1324 78 void clear_hot_cache_claimed_index() {
johnc@1324 79 _hot_cache_par_claimed_idx = 0;
johnc@1324 80 }
johnc@1324 81
ysr@777 82 // Discard entries in the hot cache.
ysr@777 83 void clear_hot_cache() {
ysr@777 84 _hot_cache_idx = 0; _n_hot = 0;
ysr@777 85 }
ysr@777 86
ysr@777 87 bool hot_cache_is_empty() { return _n_hot == 0; }
ysr@777 88
ysr@777 89 bool use_cache() { return _use_cache; }
ysr@777 90 void set_use_cache(bool b) {
ysr@777 91 if (b) _use_cache = _def_use_cache;
ysr@777 92 else _use_cache = false;
ysr@777 93 }
ysr@777 94
ysr@777 95 void clear_and_record_card_counts();
ysr@777 96 void print_final_card_counts();
iveresov@1230 97
iveresov@1230 98 static size_t thread_num();
ysr@777 99 };

mercurial