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

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

author
tschatzl
date
Fri, 10 Oct 2014 15:51:58 +0200
changeset 7257
e7d0505c8a30
parent 0
f90c822e73f8
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

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP
aoqi@0 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP
aoqi@0 27
aoqi@0 28 #include "memory/allocation.hpp"
aoqi@0 29 #include "gc_implementation/g1/heapRegion.hpp"
aoqi@0 30
aoqi@0 31 #define SKIP_RETIRED_FULL_REGIONS 1
aoqi@0 32
aoqi@0 33 class G1HRPrinter VALUE_OBJ_CLASS_SPEC {
aoqi@0 34 public:
aoqi@0 35 typedef enum {
aoqi@0 36 Alloc,
aoqi@0 37 AllocForce,
aoqi@0 38 Retire,
aoqi@0 39 Reuse,
aoqi@0 40 CSet,
aoqi@0 41 EvacFailure,
aoqi@0 42 Cleanup,
aoqi@0 43 PostCompaction,
aoqi@0 44 Commit,
aoqi@0 45 Uncommit
aoqi@0 46 } ActionType;
aoqi@0 47
aoqi@0 48 typedef enum {
aoqi@0 49 Unset,
aoqi@0 50 Eden,
aoqi@0 51 Survivor,
aoqi@0 52 Old,
aoqi@0 53 SingleHumongous,
aoqi@0 54 StartsHumongous,
aoqi@0 55 ContinuesHumongous
aoqi@0 56 } RegionType;
aoqi@0 57
aoqi@0 58 typedef enum {
aoqi@0 59 StartGC,
aoqi@0 60 EndGC,
aoqi@0 61 StartFullGC,
aoqi@0 62 EndFullGC
aoqi@0 63 } PhaseType;
aoqi@0 64
aoqi@0 65 private:
aoqi@0 66 bool _active;
aoqi@0 67
aoqi@0 68 static const char* action_name(ActionType action);
aoqi@0 69 static const char* region_type_name(RegionType type);
aoqi@0 70 static const char* phase_name(PhaseType phase);
aoqi@0 71
aoqi@0 72 // Print an action event. This version is used in most scenarios and
aoqi@0 73 // only prints the region's bottom. The parameters type and top are
aoqi@0 74 // optional (the "not set" values are Unset and NULL).
aoqi@0 75 static void print(ActionType action, RegionType type,
aoqi@0 76 HeapRegion* hr, HeapWord* top);
aoqi@0 77
aoqi@0 78 // Print an action event. This version prints both the region's
aoqi@0 79 // bottom and end. Used for Commit / Uncommit events.
aoqi@0 80 static void print(ActionType action, HeapWord* bottom, HeapWord* end);
aoqi@0 81
aoqi@0 82 // Print a phase event.
aoqi@0 83 static void print(PhaseType phase, size_t phase_num);
aoqi@0 84
aoqi@0 85 public:
aoqi@0 86 // In some places we iterate over a list in order to generate output
aoqi@0 87 // for the list's elements. By exposing this we can avoid this
aoqi@0 88 // iteration if the printer is not active.
aoqi@0 89 const bool is_active() { return _active; }
aoqi@0 90
aoqi@0 91 // Have to set this explicitly as we have to do this during the
aoqi@0 92 // heap's initialize() method, not in the constructor.
aoqi@0 93 void set_active(bool active) { _active = active; }
aoqi@0 94
aoqi@0 95 // The methods below are convenient wrappers for the print() methods.
aoqi@0 96
aoqi@0 97 void alloc(HeapRegion* hr, RegionType type, bool force = false) {
aoqi@0 98 if (is_active()) {
aoqi@0 99 print((!force) ? Alloc : AllocForce, type, hr, NULL);
aoqi@0 100 }
aoqi@0 101 }
aoqi@0 102
aoqi@0 103 void alloc(RegionType type, HeapRegion* hr, HeapWord* top) {
aoqi@0 104 if (is_active()) {
aoqi@0 105 print(Alloc, type, hr, top);
aoqi@0 106 }
aoqi@0 107 }
aoqi@0 108
aoqi@0 109 void retire(HeapRegion* hr) {
aoqi@0 110 if (is_active()) {
aoqi@0 111 if (!SKIP_RETIRED_FULL_REGIONS || hr->top() < hr->end()) {
aoqi@0 112 print(Retire, Unset, hr, hr->top());
aoqi@0 113 }
aoqi@0 114 }
aoqi@0 115 }
aoqi@0 116
aoqi@0 117 void reuse(HeapRegion* hr) {
aoqi@0 118 if (is_active()) {
aoqi@0 119 print(Reuse, Unset, hr, NULL);
aoqi@0 120 }
aoqi@0 121 }
aoqi@0 122
aoqi@0 123 void cset(HeapRegion* hr) {
aoqi@0 124 if (is_active()) {
aoqi@0 125 print(CSet, Unset, hr, NULL);
aoqi@0 126 }
aoqi@0 127 }
aoqi@0 128
aoqi@0 129 void evac_failure(HeapRegion* hr) {
aoqi@0 130 if (is_active()) {
aoqi@0 131 print(EvacFailure, Unset, hr, NULL);
aoqi@0 132 }
aoqi@0 133 }
aoqi@0 134
aoqi@0 135 void cleanup(HeapRegion* hr) {
aoqi@0 136 if (is_active()) {
aoqi@0 137 print(Cleanup, Unset, hr, NULL);
aoqi@0 138 }
aoqi@0 139 }
aoqi@0 140
aoqi@0 141 void post_compaction(HeapRegion* hr, RegionType type) {
aoqi@0 142 if (is_active()) {
aoqi@0 143 print(PostCompaction, type, hr, hr->top());
aoqi@0 144 }
aoqi@0 145 }
aoqi@0 146
aoqi@0 147 void commit(HeapWord* bottom, HeapWord* end) {
aoqi@0 148 if (is_active()) {
aoqi@0 149 print(Commit, bottom, end);
aoqi@0 150 }
aoqi@0 151 }
aoqi@0 152
aoqi@0 153 void uncommit(HeapWord* bottom, HeapWord* end) {
aoqi@0 154 if (is_active()) {
aoqi@0 155 print(Uncommit, bottom, end);
aoqi@0 156 }
aoqi@0 157 }
aoqi@0 158
aoqi@0 159 void start_gc(bool full, size_t gc_num) {
aoqi@0 160 if (is_active()) {
aoqi@0 161 if (!full) {
aoqi@0 162 print(StartGC, gc_num);
aoqi@0 163 } else {
aoqi@0 164 print(StartFullGC, gc_num);
aoqi@0 165 }
aoqi@0 166 }
aoqi@0 167 }
aoqi@0 168
aoqi@0 169 void end_gc(bool full, size_t gc_num) {
aoqi@0 170 if (is_active()) {
aoqi@0 171 if (!full) {
aoqi@0 172 print(EndGC, gc_num);
aoqi@0 173 } else {
aoqi@0 174 print(EndFullGC, gc_num);
aoqi@0 175 }
aoqi@0 176 }
aoqi@0 177 }
aoqi@0 178
aoqi@0 179 G1HRPrinter() : _active(false) { }
aoqi@0 180 };
aoqi@0 181
aoqi@0 182 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1HRPRINTER_HPP

mercurial