Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/shared/gcOverheadReporter.hpp @ 362:f8199438385b
Merge
author | apetrusenko |
---|---|
date | Wed, 17 Sep 2008 16:49:18 +0400 |
parents | 37f87013dfd8 |
children |
comparison
equal
deleted
inserted
replaced
316:5fa96a5a7e76 | 362:f8199438385b |
---|---|
1 /* | |
2 * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 // Keeps track of the GC overhead (both concurrent and STW). It stores | |
26 // it in a large array and then prints it to tty at the end of the | |
27 // execution. | |
28 | |
29 // See coTracker.hpp for the explanation on what groups are. | |
30 | |
31 // Let's set a maximum number of concurrent overhead groups, to | |
32 // statically allocate any arrays we need and not to have to | |
33 // malloc/free them. This is just a bit more convenient. | |
34 enum { | |
35 MaxGCOverheadGroupNum = 4 | |
36 }; | |
37 | |
38 typedef struct { | |
39 double _start_sec; | |
40 double _end_sec; | |
41 | |
42 double _conc_overhead[MaxGCOverheadGroupNum]; | |
43 double _stw_overhead; | |
44 } GCOverheadReporterEntry; | |
45 | |
46 class GCOverheadReporter { | |
47 friend class COReportingThread; | |
48 | |
49 private: | |
50 enum PrivateConstants { | |
51 DefaultReporterLength = 128 * 1024 | |
52 }; | |
53 | |
54 // Reference to the single instance of this class. | |
55 static GCOverheadReporter* _reporter; | |
56 | |
57 // These three references point to the array that contains the GC | |
58 // overhead entries (_base is the base of the array, _top is the | |
59 // address passed the last entry of the array, _curr is the next | |
60 // entry to be used). | |
61 GCOverheadReporterEntry* _base; | |
62 GCOverheadReporterEntry* _top; | |
63 GCOverheadReporterEntry* _curr; | |
64 | |
65 // The number of concurrent overhead groups. | |
66 size_t _group_num; | |
67 | |
68 // The wall-clock time of the end of the last recorded period of GC | |
69 // overhead. | |
70 double _prev_end_sec; | |
71 | |
72 // Names for the concurrent overhead groups. | |
73 const char* _group_names[MaxGCOverheadGroupNum]; | |
74 | |
75 // Add a new entry to the large array. conc_overhead being NULL is | |
76 // equivalent to an array full of 0.0s. conc_overhead should have a | |
77 // length of at least _group_num. | |
78 void add(double start_sec, double end_sec, | |
79 double* conc_overhead, | |
80 double stw_overhead); | |
81 | |
82 // Add an entry that represents concurrent GC overhead. | |
83 // conc_overhead must be at least of length _group_num. | |
84 // conc_overhead being NULL is equivalent to an array full of 0.0s. | |
85 void add_conc_overhead(double start_sec, double end_sec, | |
86 double* conc_overhead) { | |
87 add(start_sec, end_sec, conc_overhead, 0.0); | |
88 } | |
89 | |
90 // Add an entry that represents STW GC overhead. | |
91 void add_stw_overhead(double start_sec, double end_sec, | |
92 double stw_overhead) { | |
93 add(start_sec, end_sec, NULL, stw_overhead); | |
94 } | |
95 | |
96 // It records the start of a STW pause (i.e. it records the | |
97 // concurrent overhead up to that point) | |
98 void record_stw_start(double start_sec); | |
99 | |
100 // It records the end of a STW pause (i.e. it records the overhead | |
101 // associated with the pause and adjusts all the trackers to reflect | |
102 // the pause) | |
103 void record_stw_end(double end_sec); | |
104 | |
105 // It queries all the trackers of their concurrent overhead and | |
106 // records it. | |
107 void collect_and_record_conc_overhead(double end_sec); | |
108 | |
109 // It prints the contents of the GC overhead array | |
110 void print() const; | |
111 | |
112 | |
113 // Constructor. The same preconditions for group_num and group_names | |
114 // from initGCOverheadReporter apply here too. | |
115 GCOverheadReporter(size_t group_num, | |
116 const char* group_names[], | |
117 size_t length = DefaultReporterLength); | |
118 | |
119 public: | |
120 | |
121 // statics | |
122 | |
123 // It initialises the GCOverheadReporter and launches the concurrent | |
124 // overhead reporting thread. Both actions happen only if the | |
125 // GCOverheadReporting parameter is set. The length of the | |
126 // group_names array should be >= group_num and group_num should be | |
127 // <= MaxGCOverheadGroupNum. Entries group_namnes[0..group_num-1] | |
128 // should not be NULL. | |
129 static void initGCOverheadReporter(size_t group_num, | |
130 const char* group_names[]); | |
131 | |
132 // The following three are provided for convenience and they are | |
133 // wrappers around record_stw_start(start_sec), record_stw_end(end_sec), | |
134 // and print(). Each of these checks whether GC overhead reporting | |
135 // is on (i.e. _reporter != NULL) and, if it is, calls the | |
136 // corresponding method. Saves from repeating this pattern again and | |
137 // again from the places where they need to be called. | |
138 static void recordSTWStart(double start_sec); | |
139 static void recordSTWEnd(double end_sec); | |
140 static void printGCOverhead(); | |
141 }; |