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

Fri, 10 Oct 2014 15:51:58 +0200

author
tschatzl
date
Fri, 10 Oct 2014 15:51:58 +0200
changeset 7257
e7d0505c8a30
parent 7219
8ba0078861d4
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

8059758: Footprint regressions with JDK-8038423
Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything.
Reviewed-by: jwilhelm, brutisso

ysr@777 1 /*
johnc@5078 2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "gc_implementation/g1/concurrentG1Refine.hpp"
stefank@2314 27 #include "gc_implementation/g1/concurrentG1RefineThread.hpp"
stefank@2314 28 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
johnc@5078 29 #include "gc_implementation/g1/g1HotCardCache.hpp"
ehelin@6168 30 #include "runtime/java.hpp"
ysr@777 31
tschatzl@6930 32 ConcurrentG1Refine::ConcurrentG1Refine(G1CollectedHeap* g1h, CardTableEntryClosure* refine_closure) :
johnc@5078 33 _threads(NULL), _n_threads(0),
johnc@5078 34 _hot_card_cache(g1h)
ysr@777 35 {
iveresov@1546 36 // Ergomonically select initial concurrent refinement parameters
tonyp@1717 37 if (FLAG_IS_DEFAULT(G1ConcRefinementGreenZone)) {
tonyp@1717 38 FLAG_SET_DEFAULT(G1ConcRefinementGreenZone, MAX2<int>(ParallelGCThreads, 1));
iveresov@1546 39 }
tonyp@1717 40 set_green_zone(G1ConcRefinementGreenZone);
iveresov@1546 41
tonyp@1717 42 if (FLAG_IS_DEFAULT(G1ConcRefinementYellowZone)) {
tonyp@1717 43 FLAG_SET_DEFAULT(G1ConcRefinementYellowZone, green_zone() * 3);
iveresov@1546 44 }
tonyp@1717 45 set_yellow_zone(MAX2<int>(G1ConcRefinementYellowZone, green_zone()));
iveresov@1546 46
tonyp@1717 47 if (FLAG_IS_DEFAULT(G1ConcRefinementRedZone)) {
tonyp@1717 48 FLAG_SET_DEFAULT(G1ConcRefinementRedZone, yellow_zone() * 2);
iveresov@1546 49 }
tonyp@1717 50 set_red_zone(MAX2<int>(G1ConcRefinementRedZone, yellow_zone()));
johnc@5078 51
iveresov@1546 52 _n_worker_threads = thread_num();
iveresov@1546 53 // We need one extra thread to do the young gen rset size sampling.
iveresov@1546 54 _n_threads = _n_worker_threads + 1;
johnc@5078 55
iveresov@1546 56 reset_threshold_step();
iveresov@1546 57
zgu@3900 58 _threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads, mtGC);
johnc@5078 59
vkempik@6552 60 uint worker_id_offset = DirtyCardQueueSet::num_par_ids();
johnc@5078 61
iveresov@1546 62 ConcurrentG1RefineThread *next = NULL;
vkempik@6552 63 for (uint i = _n_threads - 1; i != UINT_MAX; i--) {
tschatzl@6930 64 ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, refine_closure, worker_id_offset, i);
iveresov@1546 65 assert(t != NULL, "Conc refine should have been created");
ehelin@6168 66 if (t->osthread() == NULL) {
ehelin@6168 67 vm_shutdown_during_initialization("Could not create ConcurrentG1RefineThread");
ehelin@6168 68 }
ehelin@6168 69
iveresov@1546 70 assert(t->cg1r() == this, "Conc refine thread should refer to this");
iveresov@1546 71 _threads[i] = t;
iveresov@1546 72 next = t;
ysr@777 73 }
ysr@777 74 }
ysr@777 75
iveresov@1546 76 void ConcurrentG1Refine::reset_threshold_step() {
tonyp@1717 77 if (FLAG_IS_DEFAULT(G1ConcRefinementThresholdStep)) {
iveresov@1546 78 _thread_threshold_step = (yellow_zone() - green_zone()) / (worker_thread_num() + 1);
iveresov@1546 79 } else {
tonyp@1717 80 _thread_threshold_step = G1ConcRefinementThresholdStep;
iveresov@1230 81 }
iveresov@1546 82 }
iveresov@1546 83
tschatzl@7051 84 void ConcurrentG1Refine::init(G1RegionToSpaceMapper* card_counts_storage) {
tschatzl@7051 85 _hot_card_cache.initialize(card_counts_storage);
ysr@777 86 }
ysr@777 87
iveresov@1229 88 void ConcurrentG1Refine::stop() {
iveresov@1229 89 if (_threads != NULL) {
vkempik@6552 90 for (uint i = 0; i < _n_threads; i++) {
iveresov@1229 91 _threads[i]->stop();
iveresov@1229 92 }
iveresov@1229 93 }
iveresov@1229 94 }
iveresov@1229 95
iveresov@1546 96 void ConcurrentG1Refine::reinitialize_threads() {
iveresov@1546 97 reset_threshold_step();
iveresov@1546 98 if (_threads != NULL) {
vkempik@6552 99 for (uint i = 0; i < _n_threads; i++) {
iveresov@1546 100 _threads[i]->initialize();
iveresov@1546 101 }
iveresov@1546 102 }
iveresov@1546 103 }
iveresov@1546 104
ysr@777 105 ConcurrentG1Refine::~ConcurrentG1Refine() {
iveresov@1229 106 if (_threads != NULL) {
vkempik@6552 107 for (uint i = 0; i < _n_threads; i++) {
iveresov@1229 108 delete _threads[i];
iveresov@1229 109 }
zgu@3900 110 FREE_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _threads, mtGC);
ysr@777 111 }
ysr@777 112 }
ysr@777 113
iveresov@1229 114 void ConcurrentG1Refine::threads_do(ThreadClosure *tc) {
iveresov@1229 115 if (_threads != NULL) {
vkempik@6552 116 for (uint i = 0; i < _n_threads; i++) {
iveresov@1229 117 tc->do_thread(_threads[i]);
iveresov@1229 118 }
ysr@777 119 }
ysr@777 120 }
ysr@777 121
tschatzl@5204 122 void ConcurrentG1Refine::worker_threads_do(ThreadClosure * tc) {
tschatzl@5204 123 if (_threads != NULL) {
vkempik@6552 124 for (uint i = 0; i < worker_thread_num(); i++) {
tschatzl@5204 125 tc->do_thread(_threads[i]);
tschatzl@5204 126 }
tschatzl@5204 127 }
tschatzl@5204 128 }
tschatzl@5204 129
vkempik@6552 130 uint ConcurrentG1Refine::thread_num() {
jwilhelm@7219 131 return G1ConcRefinementThreads;
ysr@777 132 }
tonyp@1454 133
tonyp@1454 134 void ConcurrentG1Refine::print_worker_threads_on(outputStream* st) const {
vkempik@6552 135 for (uint i = 0; i < _n_threads; ++i) {
tonyp@1454 136 _threads[i]->print_on(st);
tonyp@1454 137 st->cr();
tonyp@1454 138 }
tonyp@1454 139 }
tschatzl@5204 140
tschatzl@5204 141 ConcurrentG1RefineThread * ConcurrentG1Refine::sampling_thread() const {
tschatzl@5204 142 return _threads[worker_thread_num()];
tschatzl@5204 143 }

mercurial