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

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

author
tschatzl
date
Fri, 10 Oct 2014 15:51:58 +0200
changeset 7257
e7d0505c8a30
parent 6906
581e70386ec9
child 7535
7ae4e26cb1e0
child 8452
04a62a3d51d7
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

pliden@6413 1 /*
pliden@6413 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
pliden@6413 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
pliden@6413 4 *
pliden@6413 5 * This code is free software; you can redistribute it and/or modify it
pliden@6413 6 * under the terms of the GNU General Public License version 2 only, as
pliden@6413 7 * published by the Free Software Foundation.
pliden@6413 8 *
pliden@6413 9 * This code is distributed in the hope that it will be useful, but WITHOUT
pliden@6413 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
pliden@6413 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
pliden@6413 12 * version 2 for more details (a copy is included in the LICENSE file that
pliden@6413 13 * accompanied this code).
pliden@6413 14 *
pliden@6413 15 * You should have received a copy of the GNU General Public License version
pliden@6413 16 * 2 along with this work; if not, write to the Free Software Foundation,
pliden@6413 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
pliden@6413 18 *
pliden@6413 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
pliden@6413 20 * or visit www.oracle.com if you need additional information or have any
pliden@6413 21 * questions.
pliden@6413 22 *
pliden@6413 23 */
pliden@6413 24
pliden@6413 25 #include "precompiled.hpp"
pliden@6413 26 #include "gc_implementation/g1/g1Log.hpp"
pliden@6413 27 #include "gc_implementation/g1/g1StringDedup.hpp"
pliden@6413 28 #include "gc_implementation/g1/g1StringDedupTable.hpp"
pliden@6413 29 #include "gc_implementation/g1/g1StringDedupThread.hpp"
pliden@6413 30 #include "gc_implementation/g1/g1StringDedupQueue.hpp"
pliden@6413 31
pliden@6413 32 G1StringDedupThread* G1StringDedupThread::_thread = NULL;
pliden@6413 33
pliden@6413 34 G1StringDedupThread::G1StringDedupThread() :
pliden@6413 35 ConcurrentGCThread() {
pliden@6413 36 set_name("String Deduplication Thread");
pliden@6413 37 create_and_start();
pliden@6413 38 }
pliden@6413 39
pliden@6413 40 G1StringDedupThread::~G1StringDedupThread() {
pliden@6413 41 ShouldNotReachHere();
pliden@6413 42 }
pliden@6413 43
pliden@6413 44 void G1StringDedupThread::create() {
pliden@6413 45 assert(G1StringDedup::is_enabled(), "String deduplication not enabled");
pliden@6413 46 assert(_thread == NULL, "One string deduplication thread allowed");
pliden@6413 47 _thread = new G1StringDedupThread();
pliden@6413 48 }
pliden@6413 49
pliden@6413 50 G1StringDedupThread* G1StringDedupThread::thread() {
pliden@6413 51 assert(G1StringDedup::is_enabled(), "String deduplication not enabled");
pliden@6413 52 assert(_thread != NULL, "String deduplication thread not created");
pliden@6413 53 return _thread;
pliden@6413 54 }
pliden@6413 55
pliden@6413 56 void G1StringDedupThread::print_on(outputStream* st) const {
pliden@6413 57 st->print("\"%s\" ", name());
pliden@6413 58 Thread::print_on(st);
pliden@6413 59 st->cr();
pliden@6413 60 }
pliden@6413 61
pliden@6413 62 void G1StringDedupThread::run() {
pliden@6413 63 G1StringDedupStat total_stat;
pliden@6413 64
pliden@6413 65 initialize_in_thread();
pliden@6413 66 wait_for_universe_init();
pliden@6413 67
pliden@6413 68 // Main loop
pliden@6413 69 for (;;) {
pliden@6413 70 G1StringDedupStat stat;
pliden@6413 71
pliden@6413 72 stat.mark_idle();
pliden@6413 73
pliden@6413 74 // Wait for the queue to become non-empty
pliden@6413 75 G1StringDedupQueue::wait();
pliden@6690 76 if (_should_terminate) {
pliden@6690 77 break;
pliden@6690 78 }
pliden@6413 79
pliden@6906 80 {
pliden@6906 81 // Include thread in safepoints
pliden@6906 82 SuspendibleThreadSetJoiner sts;
pliden@6413 83
pliden@6906 84 stat.mark_exec();
pliden@6413 85
pliden@6906 86 // Process the queue
pliden@6906 87 for (;;) {
pliden@6906 88 oop java_string = G1StringDedupQueue::pop();
pliden@6906 89 if (java_string == NULL) {
pliden@6906 90 break;
pliden@6906 91 }
pliden@6906 92
pliden@6906 93 G1StringDedupTable::deduplicate(java_string, stat);
pliden@6906 94
pliden@6906 95 // Safepoint this thread if needed
pliden@6906 96 if (sts.should_yield()) {
pliden@6906 97 stat.mark_block();
pliden@6906 98 sts.yield();
pliden@6906 99 stat.mark_unblock();
pliden@6906 100 }
pliden@6413 101 }
pliden@6413 102
pliden@6906 103 G1StringDedupTable::trim_entry_cache();
pliden@6413 104
pliden@6906 105 stat.mark_done();
pliden@6906 106
pliden@6906 107 // Print statistics
pliden@6906 108 total_stat.add(stat);
pliden@6906 109 print(gclog_or_tty, stat, total_stat);
pliden@6413 110 }
pliden@6413 111 }
pliden@6413 112
pliden@6690 113 terminate();
pliden@6690 114 }
pliden@6690 115
pliden@6690 116 void G1StringDedupThread::stop() {
pliden@6690 117 {
pliden@6690 118 MonitorLockerEx ml(Terminator_lock);
pliden@6690 119 _thread->_should_terminate = true;
pliden@6690 120 }
pliden@6690 121
pliden@6690 122 G1StringDedupQueue::cancel_wait();
pliden@6690 123
pliden@6690 124 {
pliden@6690 125 MonitorLockerEx ml(Terminator_lock);
pliden@6690 126 while (!_thread->_has_terminated) {
pliden@6690 127 ml.wait();
pliden@6690 128 }
pliden@6690 129 }
pliden@6413 130 }
pliden@6413 131
pliden@6413 132 void G1StringDedupThread::print(outputStream* st, const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) {
pliden@6413 133 if (G1Log::fine() || PrintStringDeduplicationStatistics) {
pliden@6413 134 G1StringDedupStat::print_summary(st, last_stat, total_stat);
pliden@6413 135 if (PrintStringDeduplicationStatistics) {
pliden@6413 136 G1StringDedupStat::print_statistics(st, last_stat, false);
pliden@6413 137 G1StringDedupStat::print_statistics(st, total_stat, true);
pliden@6413 138 G1StringDedupTable::print_statistics(st);
pliden@6413 139 G1StringDedupQueue::print_statistics(st);
pliden@6413 140 }
pliden@6413 141 }
pliden@6413 142 }

mercurial