annotate src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp @ 1111:44f61c24ddab

6862387: tune concurrent refinement further Summary: Reworked the concurrent refinement: threads activation, feedback-based threshold adjustment, other miscellaneous fixes. Reviewed-by: apetrusenko, tonyp
author iveresov
date Wed, 16 Dec 2009 15:12:51 -0800
parents 035d2e036a9b
children b81f3572f355
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
1 /*
579
0fbdb4381b99 6814575: Update copyright year
xdono
parents: 549
diff changeset
2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
4 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
7 * published by the Free Software Foundation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
8 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
13 * accompanied this code).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
14 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
18 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
21 * have any questions.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
22 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
23 */
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
24
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
25 // Forward decl
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
26 class ConcurrentG1RefineThread;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
27 class G1RemSet;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
28
549
fe3d7c11b4b7 6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents: 342
diff changeset
29 class ConcurrentG1Refine: public CHeapObj {
794
315a5d70b295 6484957: G1: parallel concurrent refinement
iveresov
parents: 579
diff changeset
30 ConcurrentG1RefineThread** _threads;
315a5d70b295 6484957: G1: parallel concurrent refinement
iveresov
parents: 579
diff changeset
31 int _n_threads;
1111
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
32 int _n_worker_threads;
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
33 /*
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
34 * The value of the update buffer queue length falls into one of 3 zones:
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
35 * green, yellow, red. If the value is in [0, green) nothing is
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
36 * done, the buffers are left unprocessed to enable the caching effect of the
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
37 * dirtied cards. In the yellow zone [green, yellow) the concurrent refinement
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
38 * threads are gradually activated. In [yellow, red) all threads are
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
39 * running. If the length becomes red (max queue length) the mutators start
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
40 * processing the buffers.
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
41 *
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
42 * There are some interesting cases (with G1AdaptiveConcRefine turned off):
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
43 * 1) green = yellow = red = 0. In this case the mutator will process all
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
44 * buffers. Except for those that are created by the deferred updates
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
45 * machinery during a collection.
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
46 * 2) green = 0. Means no caching. Can be a good way to minimize the
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
47 * amount of time spent updating rsets during a collection.
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
48 */
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
49 int _green_zone;
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
50 int _yellow_zone;
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
51 int _red_zone;
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
52
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
53 int _thread_threshold_step;
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
54
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
55 // Reset the threshold step value based of the current zone boundaries.
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
56 void reset_threshold_step();
890
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
57
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
58 // The cache for card refinement.
890
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
59 bool _use_cache;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
60 bool _def_use_cache;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
61
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
62 size_t _n_periods; // Used as clearing epoch
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
63
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
64 // An evicting cache of the number of times each card
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
65 // is accessed. Reduces, but does not eliminate, the amount
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
66 // of duplicated processing of dirty cards.
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
67
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
68 enum SomePrivateConstants {
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
69 epoch_bits = 32,
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
70 card_num_shift = epoch_bits,
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
71 epoch_mask = AllBits,
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
72 card_num_mask = AllBits,
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
73
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
74 // The initial cache size is approximately this fraction
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
75 // of a maximal cache (i.e. the size needed for all cards
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
76 // in the heap)
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
77 InitialCacheFraction = 512
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
78 };
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
79
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
80 const static julong card_num_mask_in_place =
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
81 (julong) card_num_mask << card_num_shift;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
82
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
83 typedef struct {
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
84 julong _value; // | card_num | epoch |
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
85 } CardEpochCacheEntry;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
86
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
87 julong make_epoch_entry(unsigned int card_num, unsigned int epoch) {
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
88 assert(0 <= card_num && card_num < _max_n_card_counts, "Bounds");
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
89 assert(0 <= epoch && epoch <= _n_periods, "must be");
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
90
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
91 return ((julong) card_num << card_num_shift) | epoch;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
92 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
93
890
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
94 unsigned int extract_epoch(julong v) {
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
95 return (v & epoch_mask);
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
96 }
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
97
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
98 unsigned int extract_card_num(julong v) {
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
99 return (v & card_num_mask_in_place) >> card_num_shift;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
100 }
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
101
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
102 typedef struct {
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
103 unsigned char _count;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
104 unsigned char _evict_count;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
105 } CardCountCacheEntry;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
106
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
107 CardCountCacheEntry* _card_counts;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
108 CardEpochCacheEntry* _card_epochs;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
109
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
110 // The current number of buckets in the card count cache
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
111 unsigned _n_card_counts;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
112
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
113 // The max number of buckets required for the number of
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
114 // cards for the entire reserved heap
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
115 unsigned _max_n_card_counts;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
116
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
117 // Possible sizes of the cache: odd primes that roughly double in size.
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
118 // (See jvmtiTagMap.cpp).
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
119 static int _cc_cache_sizes[];
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
120
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
121 // The index in _cc_cache_sizes corresponding to the size of
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
122 // _card_counts.
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
123 int _cache_size_index;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
124
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
125 bool _expand_card_counts;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
126
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
127 const jbyte* _ct_bot;
889
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
128
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
129 jbyte** _hot_cache;
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
130 int _hot_cache_size;
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
131 int _n_hot;
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
132 int _hot_cache_idx;
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
133
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
134 int _hot_cache_par_chunk_size;
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
135 volatile int _hot_cache_par_claimed_idx;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
136
890
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
137 // Needed to workaround 6817995
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
138 CardTableModRefBS* _ct_bs;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
139 G1CollectedHeap* _g1h;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
140
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
141 // Expands the array that holds the card counts to the next size up
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
142 void expand_card_count_cache();
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
143
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
144 // hash a given key (index of card_ptr) with the specified size
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
145 static unsigned int hash(size_t key, int size) {
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
146 return (unsigned int) key % size;
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
147 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
148
890
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
149 // hash a given key (index of card_ptr)
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
150 unsigned int hash(size_t key) {
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
151 return hash(key, _n_card_counts);
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
152 }
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
153
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
154 unsigned ptr_2_card_num(jbyte* card_ptr) {
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
155 return (unsigned) (card_ptr - _ct_bot);
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
156 }
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
157
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
158 jbyte* card_num_2_ptr(unsigned card_num) {
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
159 return (jbyte*) (_ct_bot + card_num);
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
160 }
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
161
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
162 // Returns the count of this card after incrementing it.
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
163 jbyte* add_card_count(jbyte* card_ptr, int* count, bool* defer);
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
164
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
165 // Returns true if this card is in a young region
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
166 bool is_young_card(jbyte* card_ptr);
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
167
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
168 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
169 ConcurrentG1Refine();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
170 ~ConcurrentG1Refine();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
171
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
172 void init(); // Accomplish some initialization that has to wait.
794
315a5d70b295 6484957: G1: parallel concurrent refinement
iveresov
parents: 579
diff changeset
173 void stop();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
174
1111
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
175 void reinitialize_threads();
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
176
794
315a5d70b295 6484957: G1: parallel concurrent refinement
iveresov
parents: 579
diff changeset
177 // Iterate over the conc refine threads
315a5d70b295 6484957: G1: parallel concurrent refinement
iveresov
parents: 579
diff changeset
178 void threads_do(ThreadClosure *tc);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
179
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
180 // If this is the first entry for the slot, writes into the cache and
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
181 // returns NULL. If it causes an eviction, returns the evicted pointer.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
182 // Otherwise, its a cache hit, and returns NULL.
890
6cb8e9df7174 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 889
diff changeset
183 jbyte* cache_insert(jbyte* card_ptr, bool* defer);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
184
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
185 // Process the cached entries.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
186 void clean_up_cache(int worker_i, G1RemSet* g1rs);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
187
889
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
188 // Set up for parallel processing of the cards in the hot cache
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
189 void clear_hot_cache_claimed_index() {
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
190 _hot_cache_par_claimed_idx = 0;
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
191 }
15c5903cf9e1 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 795
diff changeset
192
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
193 // Discard entries in the hot cache.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
194 void clear_hot_cache() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
195 _hot_cache_idx = 0; _n_hot = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
196 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
197
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
198 bool hot_cache_is_empty() { return _n_hot == 0; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
199
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
200 bool use_cache() { return _use_cache; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
201 void set_use_cache(bool b) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
202 if (b) _use_cache = _def_use_cache;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
203 else _use_cache = false;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
204 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
205
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
206 void clear_and_record_card_counts();
795
215f81b4d9b3 6841831: G1: assert(contains_reference(from),"We just added it!") fires
iveresov
parents: 794
diff changeset
207
1111
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
208 static int thread_num();
1019
035d2e036a9b 6885041: G1: inconsistent thread dump
tonyp
parents: 890
diff changeset
209
035d2e036a9b 6885041: G1: inconsistent thread dump
tonyp
parents: 890
diff changeset
210 void print_worker_threads_on(outputStream* st) const;
1111
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
211
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
212 void set_green_zone(int x) { _green_zone = x; }
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
213 void set_yellow_zone(int x) { _yellow_zone = x; }
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
214 void set_red_zone(int x) { _red_zone = x; }
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
215
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
216 int green_zone() const { return _green_zone; }
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
217 int yellow_zone() const { return _yellow_zone; }
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
218 int red_zone() const { return _red_zone; }
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
219
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
220 int total_thread_num() const { return _n_threads; }
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
221 int worker_thread_num() const { return _n_worker_threads; }
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
222
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 1019
diff changeset
223 int thread_threshold_step() const { return _thread_threshold_step; }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
224 };