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

Tue, 21 Aug 2012 14:10:39 -0700

author
johnc
date
Tue, 21 Aug 2012 14:10:39 -0700
changeset 3998
7383557659bd
parent 3713
720b6a76dd9d
child 6876
710a3c8b516e
child 9327
f96fcd9e1e1b
permissions
-rw-r--r--

7185699: G1: Prediction model discrepancies
Summary: Correct the result value of G1CollectedHeap::pending_card_num(). Change the code that calculates the GC efficiency of a non-young heap region to use historical data from mixed GCs and the actual number of live bytes when predicting how long it would take to collect the region. Changes were also reviewed by Thomas Schatzl.
Reviewed-by: azeemj, brutisso

tonyp@3114 1 /*
tonyp@3713 2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
tonyp@3114 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
tonyp@3114 4 *
tonyp@3114 5 * This code is free software; you can redistribute it and/or modify it
tonyp@3114 6 * under the terms of the GNU General Public License version 2 only, as
tonyp@3114 7 * published by the Free Software Foundation.
tonyp@3114 8 *
tonyp@3114 9 * This code is distributed in the hope that it will be useful, but WITHOUT
tonyp@3114 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
tonyp@3114 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
tonyp@3114 12 * version 2 for more details (a copy is included in the LICENSE file that
tonyp@3114 13 * accompanied this code).
tonyp@3114 14 *
tonyp@3114 15 * You should have received a copy of the GNU General Public License version
tonyp@3114 16 * 2 along with this work; if not, write to the Free Software Foundation,
tonyp@3114 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
tonyp@3114 18 *
tonyp@3114 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
tonyp@3114 20 * or visit www.oracle.com if you need additional information or have any
tonyp@3114 21 * questions.
tonyp@3114 22 *
tonyp@3114 23 */
tonyp@3114 24
tonyp@3114 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1ERGOVERBOSE_HPP
tonyp@3114 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1ERGOVERBOSE_HPP
tonyp@3114 27
tonyp@3114 28 #include "memory/allocation.hpp"
tonyp@3114 29 #include "utilities/debug.hpp"
tonyp@3114 30
tonyp@3114 31 // The log of G1's heuristic decisions comprises of a series of
tonyp@3114 32 // records which have a similar format in order to maintain
tonyp@3114 33 // consistency across records and ultimately easier parsing of the
tonyp@3114 34 // output, if we ever choose to do that. Each record consists of:
tonyp@3114 35 // * A time stamp to be able to easily correlate each record with
tonyp@3114 36 // other events.
tonyp@3114 37 // * A unique string to allow us to easily identify such records.
tonyp@3114 38 // * The name of the heuristic the record corresponds to.
tonyp@3114 39 // * An action string which describes the action that G1 did or is
tonyp@3114 40 // about to do.
tonyp@3114 41 // * An optional reason string which describes the reason for the
tonyp@3114 42 // action.
tonyp@3114 43 // * An optional number of name/value pairs which contributed to the
tonyp@3114 44 // decision to take the action described in the record.
tonyp@3114 45 //
tonyp@3114 46 // Each record is associated with a "tag" which is the combination of
tonyp@3114 47 // the heuristic the record corresponds to, as well as the min level
tonyp@3114 48 // of verboseness at which the record should be printed. The tag is
tonyp@3114 49 // checked against the current settings to determine whether the record
tonyp@3114 50 // should be printed or not.
tonyp@3114 51
tonyp@3114 52 // The available verboseness levels.
tonyp@3114 53 typedef enum {
tonyp@3114 54 // Determine which part of the tag is occupied by the level.
tonyp@3114 55 ErgoLevelShift = 8,
tonyp@3114 56 ErgoLevelMask = ~((1 << ErgoLevelShift) - 1),
tonyp@3114 57
tonyp@3114 58 // ErgoLow is 0 so that we don't have to explicitly or a heuristic
tonyp@3114 59 // id with ErgoLow to keep its use simpler.
tonyp@3114 60 ErgoLow = 0,
tonyp@3126 61 ErgoHigh = 1 << ErgoLevelShift
tonyp@3114 62 } ErgoLevel;
tonyp@3114 63
tonyp@3114 64 // The available heuristics.
tonyp@3114 65 typedef enum {
tonyp@3114 66 // Determines which part of the tag is occupied by the heuristic id.
tonyp@3114 67 ErgoHeuristicMask = ~ErgoLevelMask,
tonyp@3114 68
tonyp@3114 69 ErgoHeapSizing = 0,
tonyp@3114 70 ErgoCSetConstruction,
tonyp@3114 71 ErgoConcCycles,
tonyp@3337 72 ErgoMixedGCs,
tonyp@3114 73
tonyp@3114 74 ErgoHeuristicNum
tonyp@3114 75 } ErgoHeuristic;
tonyp@3114 76
tonyp@3114 77 class G1ErgoVerbose : AllStatic {
tonyp@3114 78 private:
tonyp@3114 79 // Determines the minimum verboseness level at which records will be
tonyp@3114 80 // printed.
tonyp@3114 81 static ErgoLevel _level;
tonyp@3114 82 // Determines which heuristics are currently enabled.
tonyp@3114 83 static bool _enabled[ErgoHeuristicNum];
tonyp@3114 84
tonyp@3114 85 static ErgoLevel extract_level(int tag) {
tonyp@3114 86 return (ErgoLevel) (tag & ErgoLevelMask);
tonyp@3114 87 }
tonyp@3114 88
tonyp@3114 89 static ErgoHeuristic extract_heuristic(int tag) {
tonyp@3114 90 return (ErgoHeuristic) (tag & ErgoHeuristicMask);
tonyp@3114 91 }
tonyp@3114 92
tonyp@3114 93 public:
tonyp@3114 94 // Needs to be explicitly called at GC initialization.
tonyp@3114 95 static void initialize();
tonyp@3114 96
tonyp@3114 97 static void set_level(ErgoLevel level);
tonyp@3114 98 static void set_enabled(ErgoHeuristic h, bool enabled);
tonyp@3114 99 // It is applied to all heuristics.
tonyp@3114 100 static void set_enabled(bool enabled);
tonyp@3114 101
tonyp@3114 102 static bool enabled(int tag) {
tonyp@3114 103 ErgoLevel level = extract_level(tag);
tonyp@3114 104 ErgoHeuristic n = extract_heuristic(tag);
tonyp@3114 105 return level <= _level && _enabled[n];
tonyp@3114 106 }
tonyp@3114 107
tonyp@3114 108 // Extract the heuristic id from the tag and return a string with
tonyp@3114 109 // its name.
tonyp@3114 110 static const char* to_string(int tag);
tonyp@3114 111 };
tonyp@3114 112
tonyp@3114 113 // The macros below generate the format string for values of different
tonyp@3114 114 // types and/or metrics.
tonyp@3114 115
tonyp@3114 116 // The reason for the action is optional and is handled specially: the
tonyp@3114 117 // reason string is concatenated here so it's not necessary to pass it
tonyp@3114 118 // as a parameter.
tonyp@3114 119 #define ergo_format_reason(_reason_) ", reason: " _reason_
tonyp@3114 120
tonyp@3114 121 // Single parameter format strings
tonyp@3114 122 #define ergo_format_str(_name_) ", " _name_ ": %s"
tonyp@3713 123 #define ergo_format_region(_name_) ", " _name_ ": %u regions"
tonyp@3114 124 #define ergo_format_byte(_name_) ", " _name_ ": "SIZE_FORMAT" bytes"
tonyp@3114 125 #define ergo_format_double(_name_) ", " _name_ ": %1.2f"
tonyp@3114 126 #define ergo_format_perc(_name_) ", " _name_ ": %1.2f %%"
tonyp@3114 127 #define ergo_format_ms(_name_) ", " _name_ ": %1.2f ms"
johnc@3998 128 #define ergo_format_size(_name_) ", " _name_ ": "SIZE_FORMAT
tonyp@3114 129
tonyp@3114 130 // Double parameter format strings
tonyp@3114 131 #define ergo_format_byte_perc(_name_) \
tonyp@3114 132 ", " _name_ ": "SIZE_FORMAT" bytes (%1.2f %%)"
tonyp@3114 133
tonyp@3114 134 // Generates the format string
tonyp@3539 135 #define ergo_format(_extra_format_) \
tonyp@3539 136 " %1.3f: [G1Ergonomics (%s) %s" _extra_format_ "]"
tonyp@3114 137
tonyp@3114 138 // Conditionally, prints an ergonomic decision record. _extra_format_
tonyp@3114 139 // is the format string for the optional items we'd like to print
tonyp@3114 140 // (i.e., the decision's reason and any associated values). This
tonyp@3114 141 // string should be built up using the ergo_*_format macros (see
tonyp@3114 142 // above) to ensure consistency.
tonyp@3114 143 //
tonyp@3114 144 // Since we cannot rely on the compiler supporting variable argument
tonyp@3114 145 // macros, this macro accepts a fixed number of arguments and passes
tonyp@3114 146 // them to the print method. For convenience, we have wrapper macros
tonyp@3114 147 // below which take a specific number of arguments and set the rest to
tonyp@3114 148 // a default value.
tonyp@3539 149 #define ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 150 _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_) \
tonyp@3539 151 do { \
tonyp@3539 152 if (G1ErgoVerbose::enabled((_tag_))) { \
tonyp@3539 153 gclog_or_tty->print_cr(ergo_format(_extra_format_), \
tonyp@3539 154 os::elapsedTime(), \
tonyp@3539 155 G1ErgoVerbose::to_string((_tag_)), \
tonyp@3539 156 (_action_), \
tonyp@3539 157 (_arg0_), (_arg1_), (_arg2_), \
tonyp@3539 158 (_arg3_), (_arg4_), (_arg5_)); \
tonyp@3539 159 } \
tonyp@3114 160 } while (0)
tonyp@3114 161
tonyp@3114 162
tonyp@3539 163 #define ergo_verbose(_tag_, _action_) \
tonyp@3114 164 ergo_verbose_common(_tag_, _action_, "", 0, 0, 0, 0, 0, 0)
tonyp@3114 165
tonyp@3114 166 #define ergo_verbose0(_tag_, _action_, _extra_format_) \
tonyp@3114 167 ergo_verbose_common(_tag_, _action_, _extra_format_, 0, 0, 0, 0, 0, 0)
tonyp@3114 168
tonyp@3114 169 #define ergo_verbose1(_tag_, _action_, _extra_format_, \
tonyp@3114 170 _arg0_) \
tonyp@3114 171 ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 172 _arg0_, 0, 0, 0, 0, 0)
tonyp@3114 173
tonyp@3114 174 #define ergo_verbose2(_tag_, _action_, _extra_format_, \
tonyp@3114 175 _arg0_, _arg1_) \
tonyp@3114 176 ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 177 _arg0_, _arg1_, 0, 0, 0, 0)
tonyp@3114 178
tonyp@3114 179 #define ergo_verbose3(_tag_, _action_, _extra_format_, \
tonyp@3114 180 _arg0_, _arg1_, _arg2_) \
tonyp@3114 181 ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 182 _arg0_, _arg1_, _arg2_, 0, 0, 0)
tonyp@3114 183
tonyp@3114 184 #define ergo_verbose4(_tag_, _action_, _extra_format_, \
tonyp@3114 185 _arg0_, _arg1_, _arg2_, _arg3_) \
tonyp@3114 186 ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 187 _arg0_, _arg1_, _arg2_, _arg3_, 0, 0)
tonyp@3114 188
tonyp@3114 189 #define ergo_verbose5(_tag_, _action_, _extra_format_, \
tonyp@3114 190 _arg0_, _arg1_, _arg2_, _arg3_, _arg4_) \
tonyp@3114 191 ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 192 _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, 0)
tonyp@3114 193
tonyp@3114 194 #define ergo_verbose6(_tag_, _action_, _extra_format_, \
tonyp@3114 195 _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_) \
tonyp@3114 196 ergo_verbose_common(_tag_, _action_, _extra_format_, \
tonyp@3114 197 _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_)
tonyp@3114 198
tonyp@3114 199 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ERGOVERBOSE_HPP

mercurial