Sat, 27 Sep 2008 00:33:13 -0700
6740923: NUMA allocator: Ensure the progress of adaptive chunk resizing
Summary: Treat a chuck where the allocation has failed as fully used.
Reviewed-by: ysr
ysr@777 | 1 | /* |
ysr@777 | 2 | * Copyright 2001-2007 Sun Microsystems, Inc. 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 | * |
ysr@777 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
ysr@777 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
ysr@777 | 21 | * have any questions. |
ysr@777 | 22 | * |
ysr@777 | 23 | */ |
ysr@777 | 24 | |
ysr@777 | 25 | // Keeps track of the GC overhead (both concurrent and STW). It stores |
ysr@777 | 26 | // it in a large array and then prints it to tty at the end of the |
ysr@777 | 27 | // execution. |
ysr@777 | 28 | |
ysr@777 | 29 | // See coTracker.hpp for the explanation on what groups are. |
ysr@777 | 30 | |
ysr@777 | 31 | // Let's set a maximum number of concurrent overhead groups, to |
ysr@777 | 32 | // statically allocate any arrays we need and not to have to |
ysr@777 | 33 | // malloc/free them. This is just a bit more convenient. |
ysr@777 | 34 | enum { |
ysr@777 | 35 | MaxGCOverheadGroupNum = 4 |
ysr@777 | 36 | }; |
ysr@777 | 37 | |
ysr@777 | 38 | typedef struct { |
ysr@777 | 39 | double _start_sec; |
ysr@777 | 40 | double _end_sec; |
ysr@777 | 41 | |
ysr@777 | 42 | double _conc_overhead[MaxGCOverheadGroupNum]; |
ysr@777 | 43 | double _stw_overhead; |
ysr@777 | 44 | } GCOverheadReporterEntry; |
ysr@777 | 45 | |
ysr@777 | 46 | class GCOverheadReporter { |
ysr@777 | 47 | friend class COReportingThread; |
ysr@777 | 48 | |
ysr@777 | 49 | private: |
ysr@777 | 50 | enum PrivateConstants { |
ysr@777 | 51 | DefaultReporterLength = 128 * 1024 |
ysr@777 | 52 | }; |
ysr@777 | 53 | |
ysr@777 | 54 | // Reference to the single instance of this class. |
ysr@777 | 55 | static GCOverheadReporter* _reporter; |
ysr@777 | 56 | |
ysr@777 | 57 | // These three references point to the array that contains the GC |
ysr@777 | 58 | // overhead entries (_base is the base of the array, _top is the |
ysr@777 | 59 | // address passed the last entry of the array, _curr is the next |
ysr@777 | 60 | // entry to be used). |
ysr@777 | 61 | GCOverheadReporterEntry* _base; |
ysr@777 | 62 | GCOverheadReporterEntry* _top; |
ysr@777 | 63 | GCOverheadReporterEntry* _curr; |
ysr@777 | 64 | |
ysr@777 | 65 | // The number of concurrent overhead groups. |
ysr@777 | 66 | size_t _group_num; |
ysr@777 | 67 | |
ysr@777 | 68 | // The wall-clock time of the end of the last recorded period of GC |
ysr@777 | 69 | // overhead. |
ysr@777 | 70 | double _prev_end_sec; |
ysr@777 | 71 | |
ysr@777 | 72 | // Names for the concurrent overhead groups. |
ysr@777 | 73 | const char* _group_names[MaxGCOverheadGroupNum]; |
ysr@777 | 74 | |
ysr@777 | 75 | // Add a new entry to the large array. conc_overhead being NULL is |
ysr@777 | 76 | // equivalent to an array full of 0.0s. conc_overhead should have a |
ysr@777 | 77 | // length of at least _group_num. |
ysr@777 | 78 | void add(double start_sec, double end_sec, |
ysr@777 | 79 | double* conc_overhead, |
ysr@777 | 80 | double stw_overhead); |
ysr@777 | 81 | |
ysr@777 | 82 | // Add an entry that represents concurrent GC overhead. |
ysr@777 | 83 | // conc_overhead must be at least of length _group_num. |
ysr@777 | 84 | // conc_overhead being NULL is equivalent to an array full of 0.0s. |
ysr@777 | 85 | void add_conc_overhead(double start_sec, double end_sec, |
ysr@777 | 86 | double* conc_overhead) { |
ysr@777 | 87 | add(start_sec, end_sec, conc_overhead, 0.0); |
ysr@777 | 88 | } |
ysr@777 | 89 | |
ysr@777 | 90 | // Add an entry that represents STW GC overhead. |
ysr@777 | 91 | void add_stw_overhead(double start_sec, double end_sec, |
ysr@777 | 92 | double stw_overhead) { |
ysr@777 | 93 | add(start_sec, end_sec, NULL, stw_overhead); |
ysr@777 | 94 | } |
ysr@777 | 95 | |
ysr@777 | 96 | // It records the start of a STW pause (i.e. it records the |
ysr@777 | 97 | // concurrent overhead up to that point) |
ysr@777 | 98 | void record_stw_start(double start_sec); |
ysr@777 | 99 | |
ysr@777 | 100 | // It records the end of a STW pause (i.e. it records the overhead |
ysr@777 | 101 | // associated with the pause and adjusts all the trackers to reflect |
ysr@777 | 102 | // the pause) |
ysr@777 | 103 | void record_stw_end(double end_sec); |
ysr@777 | 104 | |
ysr@777 | 105 | // It queries all the trackers of their concurrent overhead and |
ysr@777 | 106 | // records it. |
ysr@777 | 107 | void collect_and_record_conc_overhead(double end_sec); |
ysr@777 | 108 | |
ysr@777 | 109 | // It prints the contents of the GC overhead array |
ysr@777 | 110 | void print() const; |
ysr@777 | 111 | |
ysr@777 | 112 | |
ysr@777 | 113 | // Constructor. The same preconditions for group_num and group_names |
ysr@777 | 114 | // from initGCOverheadReporter apply here too. |
ysr@777 | 115 | GCOverheadReporter(size_t group_num, |
ysr@777 | 116 | const char* group_names[], |
ysr@777 | 117 | size_t length = DefaultReporterLength); |
ysr@777 | 118 | |
ysr@777 | 119 | public: |
ysr@777 | 120 | |
ysr@777 | 121 | // statics |
ysr@777 | 122 | |
ysr@777 | 123 | // It initialises the GCOverheadReporter and launches the concurrent |
ysr@777 | 124 | // overhead reporting thread. Both actions happen only if the |
ysr@777 | 125 | // GCOverheadReporting parameter is set. The length of the |
ysr@777 | 126 | // group_names array should be >= group_num and group_num should be |
ysr@777 | 127 | // <= MaxGCOverheadGroupNum. Entries group_namnes[0..group_num-1] |
ysr@777 | 128 | // should not be NULL. |
ysr@777 | 129 | static void initGCOverheadReporter(size_t group_num, |
ysr@777 | 130 | const char* group_names[]); |
ysr@777 | 131 | |
ysr@777 | 132 | // The following three are provided for convenience and they are |
ysr@777 | 133 | // wrappers around record_stw_start(start_sec), record_stw_end(end_sec), |
ysr@777 | 134 | // and print(). Each of these checks whether GC overhead reporting |
ysr@777 | 135 | // is on (i.e. _reporter != NULL) and, if it is, calls the |
ysr@777 | 136 | // corresponding method. Saves from repeating this pattern again and |
ysr@777 | 137 | // again from the places where they need to be called. |
ysr@777 | 138 | static void recordSTWStart(double start_sec); |
ysr@777 | 139 | static void recordSTWEnd(double end_sec); |
ysr@777 | 140 | static void printGCOverhead(); |
ysr@777 | 141 | }; |