author | stuefe |
Fri, 07 Sep 2018 07:52:35 +0200 | |
branch | stuefe-statistical-history |
changeset 57221 | 9653470b7294 |
child 57245 | 0ed37e453a39 |
permissions | -rw-r--r-- |
57221
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1 |
/* |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
3 |
* Copyright (c) 2018, SAP SE. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
4 |
* |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
5 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
6 |
* |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
7 |
* This code is free software; you can redistribute it and/or modify it |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
8 |
* under the terms of the GNU General Public License version 2 only, as |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
9 |
* published by the Free Software Foundation. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
10 |
* |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
15 |
* accompanied this code). |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
16 |
* |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
20 |
* |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
23 |
* questions. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
24 |
* |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
25 |
*/ |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
26 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
27 |
#include "precompiled.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
28 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
29 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
30 |
#include "gc/shared/collectedHeap.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
31 |
#include "classfile/classLoaderDataGraph.inline.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
32 |
#include "code/codeCache.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
33 |
#include "memory/allocation.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
34 |
#include "memory/universe.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
35 |
#include "runtime/thread.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
36 |
#include "services/memTracker.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
37 |
#include "services/stathist.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
38 |
#include "services/stathist_internals.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
39 |
#include "utilities/debug.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
40 |
#include "utilities/globalDefinitions.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
41 |
#include "utilities/ostream.hpp" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
42 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
43 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
44 |
#include <locale.h> |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
45 |
#include <time.h> |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
46 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
47 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
48 |
// Define this switch to limit sampling to those values which can be obtained without locking. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
49 |
#undef NEVER_LOCK_WHEN_SAMPLING |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
50 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
51 |
namespace StatisticsHistory { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
52 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
53 |
namespace counters { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
54 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
55 |
// These are counters for the statistics history. Ideally, they would live |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
56 |
// inside their thematical homes, e.g. thread.cpp or classLoaderDataGraph.cpp, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
57 |
// however since this is unlikely ever to be brought upstream we keep them separate |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
58 |
// from central coding to ease maintenance. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
59 |
static volatile size_t g_classes_loaded = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
60 |
static volatile size_t g_classes_unloaded = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
61 |
static volatile size_t g_threads_created = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
62 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
63 |
void inc_classes_loaded(size_t count) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
64 |
Atomic::add(count, &g_classes_loaded); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
65 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
66 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
67 |
void inc_classes_unloaded(size_t count) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
68 |
Atomic::add(count, &g_classes_unloaded); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
69 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
70 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
71 |
void inc_threads_created(size_t count) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
72 |
Atomic::add(count, &g_threads_created); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
73 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
74 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
75 |
} // namespace counters |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
76 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
77 |
// helper function for the missing outputStream::put(int c, int repeat) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
78 |
static void ostream_put_n(outputStream* st, int c, int repeat) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
79 |
for (int i = 0; i < repeat; i ++) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
80 |
st->put(c); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
81 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
82 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
83 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
84 |
static size_t record_size_in_bytes() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
85 |
const int num_columns = ColumnList::the_list()->num_columns(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
86 |
return sizeof(record_t) + sizeof(value_t) * (num_columns - 1); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
87 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
88 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
89 |
static void print_text_with_dashes(outputStream* st, const char* text, int width) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
90 |
assert(width > 0, "Sanity"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
91 |
// Print the name centered within the width like this |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
92 |
// ----- system ------ |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
93 |
int extra_space = width - (int)strlen(text); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
94 |
if (extra_space > 0) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
95 |
int left_space = extra_space / 2; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
96 |
int right_space = extra_space - left_space; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
97 |
ostream_put_n(st, '-', left_space); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
98 |
st->print_raw(text); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
99 |
ostream_put_n(st, '-', right_space); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
100 |
} else { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
101 |
ostream_put_n(st, '-', width); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
102 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
103 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
104 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
105 |
// Helper function for printing: |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
106 |
// Print to ostream, but only if ostream is given. In any case return number ofcat_process = 10, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
107 |
// characters printed (or which would have been printed). |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
108 |
static |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
109 |
ATTRIBUTE_PRINTF(2, 3) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
110 |
int printf_helper(outputStream* st, const char *fmt, ...) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
111 |
// We only print numbers, so a small buffer is fine. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
112 |
char buf[64]; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
113 |
va_list args; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
114 |
int len = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
115 |
va_start(args, fmt); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
116 |
len = jio_vsnprintf(buf, sizeof(buf), fmt, args); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
117 |
va_end(args); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
118 |
assert((size_t)len < sizeof(buf), "Truncation. Increase bufsize."); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
119 |
if (st != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
120 |
st->print_raw(buf); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
121 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
122 |
return len; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
123 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
124 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
125 |
// length of time stamp |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
126 |
#define TIMESTAMP_LEN 19 |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
127 |
// number of spaces after time stamp |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
128 |
#define TIMESTAMP_DIVIDER_LEN 3 |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
129 |
static void print_timestamp(outputStream* st, time_t t) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
130 |
struct tm _tm; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
131 |
if (os::localtime_pd(&t, &_tm) == &_tm) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
132 |
char buf[32]; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
133 |
::strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &_tm); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
134 |
st->print("%*s", TIMESTAMP_LEN, buf); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
135 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
136 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
137 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
138 |
// A little RAII class to temporarily change locale to "C" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
139 |
class CLocaleMark { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
140 |
const char* _orig; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
141 |
public: |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
142 |
CLocaleMark() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
143 |
_orig = ::setlocale(LC_NUMERIC, NULL); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
144 |
::setlocale(LC_NUMERIC, "C"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
145 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
146 |
~CLocaleMark() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
147 |
::setlocale(LC_NUMERIC, _orig); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
148 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
149 |
}; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
150 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
151 |
////// class ColumnList methods //// |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
152 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
153 |
ColumnList* ColumnList::_the_list = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
154 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
155 |
bool ColumnList::initialize() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
156 |
_the_list = new ColumnList(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
157 |
return _the_list != NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
158 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
159 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
160 |
void ColumnList::add_column(Column* c) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
161 |
assert(c->index() == -1, "Do not add twice."); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
162 |
Column* c_last = _last; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
163 |
if (_last != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
164 |
_last->_next = c; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
165 |
_last = c; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
166 |
} else { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
167 |
_first = _last = c; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
168 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
169 |
// fix indices (describe position of column within table/category/header |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
170 |
c->_idx = c->_idx_cat = c->_idx_hdr = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
171 |
if (c_last != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
172 |
c->_idx = c_last->_idx + 1; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
173 |
if (::strcmp(c->category(), c_last->category()) == 0) { // same category as last column? |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
174 |
c->_idx_cat = c_last->_idx_cat + 1; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
175 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
176 |
if (c->header() != NULL && c_last->header() != NULL && |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
177 |
::strcmp(c_last->header(), c->header()) == 0) { // have header and same as last column? |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
178 |
c->_idx_hdr = c_last->_idx_hdr + 1; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
179 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
180 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
181 |
_num_columns ++; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
182 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
183 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
184 |
//////////////////// |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
185 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
186 |
// At various places we need a scratch buffer of ints with one element per column; since |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
187 |
// after initialization the number of columns is fixed, we pre-create this. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
188 |
static int* g_widths = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
189 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
190 |
bool initialize_widths_buffer() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
191 |
assert(ColumnList::the_list() != NULL && g_widths == NULL, "Initialization order problem."); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
192 |
g_widths = (int*)os::malloc(sizeof(int) * ColumnList::the_list()->num_columns(), mtInternal); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
193 |
return g_widths != NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
194 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
195 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
196 |
// pre-allocated space for a single record used to take current values when printing via dcmd. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
197 |
static record_t* g_record_now = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
198 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
199 |
bool initialize_space_for_now_record() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
200 |
assert(ColumnList::the_list() != NULL && g_record_now == NULL, "Initialization order problem."); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
201 |
g_record_now = (record_t*) os::malloc(record_size_in_bytes(), mtInternal); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
202 |
return g_record_now != NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
203 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
204 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
205 |
//////////////////// |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
206 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
207 |
static void print_category_line(outputStream* st, int widths[], const print_info_t* pi) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
208 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
209 |
assert(pi->cvs == false, "Not in cvs mode"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
210 |
ostream_put_n(st, ' ', TIMESTAMP_LEN + TIMESTAMP_DIVIDER_LEN); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
211 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
212 |
const Column* c = ColumnList::the_list()->first(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
213 |
assert(c != NULL, "no columns?"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
214 |
const char* last_category_text = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
215 |
int width = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
216 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
217 |
while(c != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
218 |
if (c->index_within_category_section() == 0) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
219 |
if (width > 0) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
220 |
// Print category label centered over the last n columns, surrounded by dashes. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
221 |
print_text_with_dashes(st, last_category_text, width - 1); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
222 |
st->put(' '); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
223 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
224 |
width = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
225 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
226 |
width += widths[c->index()]; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
227 |
width += 1; // divider between columns |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
228 |
last_category_text = c->category(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
229 |
c = c->next(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
230 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
231 |
print_text_with_dashes(st, last_category_text, width - 1); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
232 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
233 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
234 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
235 |
static void print_header_line(outputStream* st, int widths[], const print_info_t* pi) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
236 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
237 |
assert(pi->cvs == false, "Not in cvs mode"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
238 |
ostream_put_n(st, ' ', TIMESTAMP_LEN + TIMESTAMP_DIVIDER_LEN); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
239 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
240 |
const Column* c = ColumnList::the_list()->first(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
241 |
assert(c != NULL, "no columns?"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
242 |
const char* last_header_text = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
243 |
int width = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
244 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
245 |
while(c != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
246 |
if (c->index_within_header_section() == 0) { // First in header section |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
247 |
if (width > 0) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
248 |
if (last_header_text != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
249 |
// Print header label centered over the last n columns, surrounded by dashes. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
250 |
print_text_with_dashes(st, last_header_text, width - 1); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
251 |
st->put(' '); // divider |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
252 |
} else { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
253 |
// the last n columns had no header. Just fill with blanks. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
254 |
ostream_put_n(st, ' ', width); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
255 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
256 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
257 |
width = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
258 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
259 |
width += widths[c->index()]; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
260 |
width += 1; // divider between columns |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
261 |
last_header_text = c->header(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
262 |
c = c->next(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
263 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
264 |
if (width > 0 && last_header_text != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
265 |
print_text_with_dashes(st, last_header_text, width - 1); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
266 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
267 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
268 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
269 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
270 |
static void print_column_names(outputStream* st, int widths[], const print_info_t* pi) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
271 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
272 |
// Leave space for timestamp column |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
273 |
if (pi->cvs == false) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
274 |
ostream_put_n(st, ' ', TIMESTAMP_LEN + TIMESTAMP_DIVIDER_LEN); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
275 |
} else { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
276 |
st->put(','); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
277 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
278 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
279 |
const Column* c = ColumnList::the_list()->first(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
280 |
const Column* previous = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
281 |
while (c != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
282 |
if (pi->cvs == false) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
283 |
st->print("%-*s ", widths[c->index()], c->name()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
284 |
} else { // cvs mode |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
285 |
// cvs: use comma as delimiter, don't pad, and precede name with header if there is one. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
286 |
if (c->header() != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
287 |
st->print("%s-", c->header()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
288 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
289 |
st->print("%s,", c->name()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
290 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
291 |
previous = c; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
292 |
c = c->next(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
293 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
294 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
295 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
296 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
297 |
static void print_legend(outputStream* st, const print_info_t* pi) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
298 |
const Column* c = ColumnList::the_list()->first(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
299 |
const Column* c_prev = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
300 |
while (c != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
301 |
// Print category label. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
302 |
if (c->index_within_category_section() == 0) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
303 |
print_text_with_dashes(st, c->category(), 30); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
304 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
305 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
306 |
// print column name and description |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
307 |
const int min_width_column_label = 16; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
308 |
char buf[32]; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
309 |
if (c->header() != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
310 |
jio_snprintf(buf, sizeof(buf), "%s-%s", c->header(), c->name()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
311 |
} else { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
312 |
jio_snprintf(buf, sizeof(buf), "%s", c->name()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
313 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
314 |
st->print("%*s: %s", min_width_column_label, buf, c->description()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
315 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
316 |
// If memory units are not dynamic (otion scale), print out the unit as well. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
317 |
if (c->is_memory_size() && pi->scale != 0) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
318 |
st->print_raw(" [mem]"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
319 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
320 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
321 |
// If column is a delta value, indicate so |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
322 |
if (c->is_delta()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
323 |
st->print_raw(" [delta]"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
324 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
325 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
326 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
327 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
328 |
c_prev = c; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
329 |
c = c->next(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
330 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
331 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
332 |
st->print_cr("[delta] values refer to the previous measurement."); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
333 |
if (pi->scale != 0) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
334 |
const char* display_unit = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
335 |
switch (pi->scale) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
336 |
case K: display_unit = "KB"; break; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
337 |
case M: display_unit = "MB"; break; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
338 |
case G: display_unit = "GB"; break; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
339 |
default: ShouldNotReachHere(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
340 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
341 |
st->print_cr("[mem] values are in %s.", display_unit); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
342 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
343 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
344 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
345 |
// Print a human readable size. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
346 |
// byte_size: size, in bytes, to be printed. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
347 |
// scale: K,M,G or 0 (dynamic) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
348 |
// width: printing width. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
349 |
static int print_memory_size(outputStream* st, size_t byte_size, size_t scale) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
350 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
351 |
bool print_unit = false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
352 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
353 |
if (scale == 0) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
354 |
print_unit = true; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
355 |
// Dynamic mode. Choose scale for this value. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
356 |
if (byte_size == 0) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
357 |
scale = K; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
358 |
} else { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
359 |
if (byte_size >= G) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
360 |
scale = G; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
361 |
} else if (byte_size >= M) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
362 |
scale = M; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
363 |
} else { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
364 |
scale = K; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
365 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
366 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
367 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
368 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
369 |
const char* display_unit = ""; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
370 |
if (print_unit) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
371 |
switch(scale) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
372 |
case K: display_unit = "k"; break; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
373 |
case M: display_unit = "m"; break; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
374 |
case G: display_unit = "g"; break; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
375 |
default: |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
376 |
ShouldNotReachHere(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
377 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
378 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
379 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
380 |
int l = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
381 |
float display_value = (float) byte_size / scale; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
382 |
// Values smaller than 1M are shown are rounded up to whole numbers to de-clutter |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
383 |
// the display. Who cares for half kbytes. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
384 |
int precision = scale < G ? 0 : 1; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
385 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
386 |
if (byte_size > 0 && byte_size < K) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
387 |
// Prevent values smaller than one K but not 0 showing up as . |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
388 |
l = printf_helper(st, "<1%s", display_unit); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
389 |
} else { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
390 |
l = printf_helper(st, "%.*f%s", precision, display_value, display_unit); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
391 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
392 |
return l; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
393 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
394 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
395 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
396 |
///////// class Column and childs /////////// |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
397 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
398 |
Column::Column(const char* category, const char* header, const char* name, const char* description) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
399 |
: _category(category), |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
400 |
_header(header), // may be NULL |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
401 |
_name(name), |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
402 |
_description(description), |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
403 |
_next(NULL), _idx(-1), |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
404 |
_idx_cat(-1), _idx_hdr(-1) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
405 |
{ |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
406 |
ColumnList::the_list()->add_column(this); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
407 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
408 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
409 |
void Column::print_value(outputStream* st, value_t value, value_t last_value, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
410 |
int last_value_age, int min_width, const print_info_t* pi) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
411 |
#ifdef ASSERT |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
412 |
if (pi->raw) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
413 |
printf_helper(st, UINT64_FORMAT, value); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
414 |
return; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
415 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
416 |
#endif |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
417 |
// We print all values right aligned. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
418 |
int needed = calc_print_size(value, last_value, last_value_age, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
419 |
if (pi->cvs == false && min_width > needed) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
420 |
// In ascii (non cvs) mode, pad to minimum width |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
421 |
ostream_put_n(st, ' ', min_width - needed); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
422 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
423 |
do_print(st, value, last_value, last_value_age, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
424 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
425 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
426 |
// Returns the number of characters this value needs to be printed. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
427 |
int Column::calc_print_size(value_t value, value_t last_value, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
428 |
int last_value_age, const print_info_t* pi) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
429 |
return do_print(NULL, value, last_value, last_value_age, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
430 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
431 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
432 |
int PlainValueColumn::do_print(outputStream* st, value_t value, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
433 |
value_t last_value, int last_value_age, const print_info_t* pi) const |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
434 |
{ |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
435 |
int l = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
436 |
if (value != INVALID_VALUE) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
437 |
l = printf_helper(st, UINT64_FORMAT, value); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
438 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
439 |
return l; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
440 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
441 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
442 |
int DeltaValueColumn::do_print(outputStream* st, value_t value, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
443 |
value_t last_value, int last_value_age, const print_info_t* pi) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
444 |
if (_show_only_positive && last_value > value) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
445 |
// we assume the underlying value to be monotonically raising, and that |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
446 |
// any negative delta would be just a fluke (e.g. counter overflows) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
447 |
// we do not want to show |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
448 |
return 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
449 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
450 |
int l = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
451 |
if (value != INVALID_VALUE && last_value != INVALID_VALUE) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
452 |
l = printf_helper(st, INT64_FORMAT, (int64_t)(value - last_value)); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
453 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
454 |
return l; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
455 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
456 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
457 |
int MemorySizeColumn::do_print(outputStream* st, value_t value, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
458 |
value_t last_value, int last_value_age, const print_info_t* pi) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
459 |
int l = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
460 |
if (value != INVALID_VALUE) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
461 |
l = print_memory_size(st, value, pi->scale); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
462 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
463 |
return l; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
464 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
465 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
466 |
int DeltaMemorySizeColumn::do_print(outputStream* st, value_t value, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
467 |
value_t last_value, int last_value_age, const print_info_t* pi) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
468 |
int l = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
469 |
if (value != INVALID_VALUE && last_value != INVALID_VALUE) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
470 |
l = print_memory_size(st, value - last_value, pi->scale); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
471 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
472 |
return l; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
473 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
474 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
475 |
////////////// Record printing /////////////////////////// |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
476 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
477 |
// Print one record. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
478 |
static void print_one_record(outputStream* st, const record_t* record, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
479 |
const record_t* last_record, const int widths[], const print_info_t* pi) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
480 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
481 |
// Print timestamp and divider |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
482 |
if (record->timestamp == 0) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
483 |
st->print("%*s", TIMESTAMP_LEN, "Now"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
484 |
} else { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
485 |
print_timestamp(st, record->timestamp); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
486 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
487 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
488 |
if (pi->cvs == false) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
489 |
ostream_put_n(st, ' ', TIMESTAMP_DIVIDER_LEN); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
490 |
} else { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
491 |
st->put(','); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
492 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
493 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
494 |
const Column* c = ColumnList::the_list()->first(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
495 |
while (c != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
496 |
const int idx = c->index(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
497 |
const value_t v = record->values[idx]; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
498 |
value_t v2 = INVALID_VALUE; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
499 |
int age = -1; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
500 |
if (last_record != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
501 |
v2 = last_record->values[idx]; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
502 |
age = record->timestamp - last_record->timestamp; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
503 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
504 |
const int min_width = widths[idx]; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
505 |
c->print_value(st, v, v2, age, min_width, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
506 |
st->put(pi->cvs ? ',' : ' '); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
507 |
c = c->next(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
508 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
509 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
510 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
511 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
512 |
// For each value in record, update the width in the widths array if it is smaller than |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
513 |
// the value printing width |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
514 |
static void update_widths_from_one_record(const record_t* record, const record_t* last_record, int widths[], |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
515 |
const print_info_t* pi) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
516 |
const Column* c = ColumnList::the_list()->first(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
517 |
while (c != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
518 |
const int idx = c->index(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
519 |
const value_t v = record->values[idx]; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
520 |
value_t v2 = INVALID_VALUE; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
521 |
int age = -1; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
522 |
if (last_record != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
523 |
v2 = last_record->values[idx]; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
524 |
age = record->timestamp - last_record->timestamp; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
525 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
526 |
int needed = c->calc_print_size(v, v2, age, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
527 |
if (widths[idx] < needed) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
528 |
widths[idx] = needed; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
529 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
530 |
c = c->next(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
531 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
532 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
533 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
534 |
////////////// Class RecordTable ///////////////////////// |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
535 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
536 |
class RecordTable : public CHeapObj<mtInternal> { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
537 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
538 |
const int _num_records; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
539 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
540 |
record_t* _records; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
541 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
542 |
int _pos; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
543 |
bool _did_wrap; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
544 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
545 |
RecordTable* const _follower; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
546 |
const int _follower_ratio; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
547 |
int _follower_countdown; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
548 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
549 |
void check_pos(int pos) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
550 |
assert(pos >= 0 && pos < _num_records, "invalid position"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
551 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
552 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
553 |
int preceeding_pos(int pos) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
554 |
check_pos(pos); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
555 |
int p2 = pos - 1; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
556 |
if (p2 == -1) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
557 |
if (_did_wrap) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
558 |
p2 = _num_records - 1; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
559 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
560 |
} else if (p2 == _pos) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
561 |
assert(_did_wrap, "Sanity"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
562 |
p2 = -1; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
563 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
564 |
return p2; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
565 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
566 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
567 |
record_t* at(int pos) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
568 |
check_pos(pos); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
569 |
return (record_t*) ((address)_records + (record_size_in_bytes() * pos)); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
570 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
571 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
572 |
// May return NULL |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
573 |
const record_t* preceeding(int pos) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
574 |
int p2 = preceeding_pos(pos); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
575 |
if (p2 != -1) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
576 |
return at(p2); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
577 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
578 |
return NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
579 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
580 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
581 |
class ConstReverseIterator { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
582 |
const RecordTable* const _rt; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
583 |
int _p; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
584 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
585 |
public: |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
586 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
587 |
ConstReverseIterator(const RecordTable* rt) : _rt(rt), _p(-1) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
588 |
_p = _rt->preceeding_pos(_rt->_pos); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
589 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
590 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
591 |
bool valid() const { return _p != -1; } |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
592 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
593 |
void step() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
594 |
if (valid()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
595 |
_p = _rt->preceeding_pos(_p); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
596 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
597 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
598 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
599 |
const record_t* get() const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
600 |
assert(valid(), "Sanity"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
601 |
return _rt->at(_p); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
602 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
603 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
604 |
// May return NULL |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
605 |
const record_t* get_preceeding() const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
606 |
return _rt->preceeding(_p); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
607 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
608 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
609 |
}; // end ConstReverseIterator |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
610 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
611 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
612 |
void add_record(const record_t* record) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
613 |
::memcpy(current_record(), record, record_size_in_bytes()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
614 |
finish_current_record(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
615 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
616 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
617 |
// This "dry-prints" all records just to calculate the maximum print width, per column, needed to |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
618 |
// display the values. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
619 |
void update_widths_from_all_records(int widths[], const print_info_t* pi) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
620 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
621 |
// reset widths - note: minimum width is the length of the name of the column. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
622 |
const Column* c = ColumnList::the_list()->first(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
623 |
while (c != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
624 |
widths[c->index()] = (int)::strlen(c->name()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
625 |
c = c->next(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
626 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
627 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
628 |
ConstReverseIterator it(this); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
629 |
while(it.valid()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
630 |
const record_t* record = it.get(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
631 |
const record_t* previous_record = it.get_preceeding(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
632 |
update_widths_from_one_record(record, previous_record, widths, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
633 |
it.step(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
634 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
635 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
636 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
637 |
// Print all records. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
638 |
void print_all_records(outputStream* st, const int widths[], const print_info_t* pi) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
639 |
ConstReverseIterator it(this); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
640 |
while(it.valid()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
641 |
const record_t* record = it.get(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
642 |
const record_t* previous_record = it.get_preceeding(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
643 |
print_one_record(st, record, previous_record, widths, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
644 |
it.step(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
645 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
646 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
647 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
648 |
bool is_empty() const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
649 |
return _pos == 0 && _did_wrap == false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
650 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
651 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
652 |
public: |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
653 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
654 |
RecordTable(int num_records, RecordTable* follower = NULL, int follower_ratio = -1) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
655 |
: _num_records(num_records), |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
656 |
_records(NULL), _pos(0), _did_wrap(false), |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
657 |
_follower(follower), _follower_ratio(follower_ratio), |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
658 |
_follower_countdown(0) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
659 |
{} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
660 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
661 |
bool initialize() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
662 |
_records = (record_t*) os::malloc(record_size_in_bytes() * _num_records, mtInternal); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
663 |
return _records != NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
664 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
665 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
666 |
// returns the pointer to the current, unfinished record. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
667 |
record_t* current_record() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
668 |
return at(_pos); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
669 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
670 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
671 |
// finish the current record: advances the write position in the FIFO buffer by one. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
672 |
// Should that cause a record to fall out of the FIFO end, it propagates the record to |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
673 |
// the follower table if needed. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
674 |
void finish_current_record() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
675 |
_pos ++; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
676 |
if (_pos == _num_records) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
677 |
_pos = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
678 |
_did_wrap = true; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
679 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
680 |
if (_did_wrap) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
681 |
// propagate old record if needed. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
682 |
if (_follower != NULL && _follower_countdown == 0) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
683 |
_follower->add_record(current_record()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
684 |
_follower_countdown = _follower_ratio; // reset countdown. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
685 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
686 |
_follower_countdown --; // count down. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
687 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
688 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
689 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
690 |
void print_table(outputStream* st, const print_info_t* pi, const record_t* values_now = NULL) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
691 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
692 |
// print numbers with C locale to make parsing easier. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
693 |
CLocaleMark clm; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
694 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
695 |
if (is_empty() && values_now == NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
696 |
st->print_cr("(no records)"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
697 |
return; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
698 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
699 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
700 |
const record_t* const youngest_in_table = preceeding(_pos); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
701 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
702 |
// Before actually printing, lets calculate the printing widths |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
703 |
// (if now-values are given, they are part of the table too, so include them in the widths calculation) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
704 |
update_widths_from_all_records(g_widths, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
705 |
if (values_now != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
706 |
update_widths_from_one_record(values_now, youngest_in_table, g_widths, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
707 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
708 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
709 |
// Print headers (not in cvs mode) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
710 |
if (pi->cvs == false) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
711 |
print_category_line(st, g_widths, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
712 |
print_header_line(st, g_widths, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
713 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
714 |
print_column_names(st, g_widths, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
715 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
716 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
717 |
// Now print the actual values. Youngest to oldest, first one the now-values. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
718 |
if (values_now != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
719 |
print_one_record(st, values_now, youngest_in_table, g_widths, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
720 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
721 |
print_all_records(st, g_widths, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
722 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
723 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
724 |
}; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
725 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
726 |
class RecordTables: public CHeapObj<mtInternal> { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
727 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
728 |
enum { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
729 |
// short term: 15 seconds per sample, 60 samples or 15 minutes total |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
730 |
short_term_interval_default = 15, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
731 |
short_term_num_samples = 60, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
732 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
733 |
// mid term: 15 minutes per sample (aka 60 short term samples), 96 samples or 24 hours in total |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
734 |
mid_term_interval_ratio = 60, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
735 |
mid_term_num_samples = 96, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
736 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
737 |
// long term history: 2 hour intervals (aka 8 mid term samples), 120 samples or 10 days in total |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
738 |
long_term_interval_ratio = 8, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
739 |
long_term_num_samples = 120 |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
740 |
}; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
741 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
742 |
int _short_term_interval; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
743 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
744 |
RecordTable* _short_term_table; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
745 |
RecordTable* _mid_term_table; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
746 |
RecordTable* _long_term_table; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
747 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
748 |
static RecordTables* _the_tables; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
749 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
750 |
// Call this after column list has been initialized. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
751 |
bool initialize(int short_term_interval) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
752 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
753 |
// Calculate intervals |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
754 |
_short_term_interval = short_term_interval; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
755 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
756 |
// Initialize tables, oldest first (since it has no follower) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
757 |
_long_term_table = new RecordTable(long_term_num_samples); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
758 |
if (_long_term_table == NULL || !_long_term_table->initialize()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
759 |
return false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
760 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
761 |
_mid_term_table = new RecordTable(mid_term_num_samples, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
762 |
_long_term_table, long_term_interval_ratio); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
763 |
if (_mid_term_table == NULL || !_mid_term_table->initialize()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
764 |
return false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
765 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
766 |
_short_term_table = new RecordTable(short_term_num_samples, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
767 |
_mid_term_table, mid_term_interval_ratio); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
768 |
if (_short_term_table == NULL || !_short_term_table->initialize()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
769 |
return false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
770 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
771 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
772 |
return true; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
773 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
774 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
775 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
776 |
public: |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
777 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
778 |
static RecordTables* the_tables() { return _the_tables; } |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
779 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
780 |
// Call this after column list has been initialized. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
781 |
static bool initialize() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
782 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
783 |
_the_tables = new RecordTables(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
784 |
if (_the_tables == NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
785 |
return false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
786 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
787 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
788 |
const int short_term_interval = StatHistSampleInterval != 0 ? |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
789 |
StatHistSampleInterval : short_term_interval_default; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
790 |
return _the_tables->initialize(short_term_interval); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
791 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
792 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
793 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
794 |
void print_all(outputStream* st, const print_info_t* pi, const record_t* values_now = NULL) const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
795 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
796 |
st->print_cr("Short Term Values:"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
797 |
// At the start of the short term table we print the current (now) values. The intent is to be able |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
798 |
// to see very short term developments (e.g. a spike in heap usage in the last n seconds) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
799 |
_short_term_table->print_table(st, pi, values_now); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
800 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
801 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
802 |
st->print_cr("Mid Term Values:"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
803 |
_mid_term_table->print_table(st, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
804 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
805 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
806 |
st->print_cr("Long Term Values:"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
807 |
_long_term_table->print_table(st, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
808 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
809 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
810 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
811 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
812 |
RecordTable* first_table() const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
813 |
return _short_term_table; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
814 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
815 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
816 |
int short_term_interval() const { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
817 |
return _short_term_interval; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
818 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
819 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
820 |
}; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
821 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
822 |
RecordTables* RecordTables::_the_tables = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
823 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
824 |
static void sample_values(record_t* record, bool avoid_locking) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
825 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
826 |
// reset all values to be invalid. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
827 |
const ColumnList* clist = ColumnList::the_list(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
828 |
for (int colno = 0; colno < clist->num_columns(); colno ++) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
829 |
record->values[colno] = INVALID_VALUE; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
830 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
831 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
832 |
// sample... |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
833 |
sample_jvm_values(record, avoid_locking); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
834 |
sample_platform_values(record); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
835 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
836 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
837 |
class SamplerThread: public NamedThread { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
838 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
839 |
bool _stop; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
840 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
841 |
void take_sample() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
842 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
843 |
const ColumnList* clist = ColumnList::the_list(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
844 |
RecordTable* record_table = RecordTables::the_tables()->first_table(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
845 |
record_t* record = record_table->current_record(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
846 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
847 |
::time(&record->timestamp); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
848 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
849 |
sample_values(record, StatHistLockFree); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
850 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
851 |
// After sampling, finish record. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
852 |
record_table->finish_current_record(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
853 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
854 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
855 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
856 |
public: |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
857 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
858 |
SamplerThread() |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
859 |
: NamedThread() |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
860 |
, _stop(false) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
861 |
{ |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
862 |
this->set_name("stathist sampler thread"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
863 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
864 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
865 |
virtual void run() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
866 |
record_stack_base_and_size(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
867 |
for (;;) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
868 |
take_sample(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
869 |
os::sleep(this, RecordTables::the_tables()->short_term_interval() * 1000, false); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
870 |
if (_stop) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
871 |
break; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
872 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
873 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
874 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
875 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
876 |
void stop() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
877 |
_stop = true; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
878 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
879 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
880 |
}; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
881 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
882 |
static SamplerThread* g_sampler_thread = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
883 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
884 |
static bool initialize_sampler_thread() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
885 |
g_sampler_thread = new SamplerThread(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
886 |
if (g_sampler_thread != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
887 |
if (os::create_thread(g_sampler_thread, os::os_thread)) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
888 |
os::start_thread(g_sampler_thread); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
889 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
890 |
return true; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
891 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
892 |
return false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
893 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
894 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
895 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
896 |
/////// JVM-specific columns ////////// |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
897 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
898 |
static Column* g_col_heap_committed = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
899 |
static Column* g_col_heap_used = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
900 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
901 |
static Column* g_col_metaspace_committed = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
902 |
static Column* g_col_metaspace_used = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
903 |
static Column* g_col_classspace_committed = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
904 |
static Column* g_col_classspace_used = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
905 |
static Column* g_col_metaspace_cap_until_gc = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
906 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
907 |
static Column* g_col_codecache_committed = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
908 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
909 |
static Column* g_col_nmt_malloc = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
910 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
911 |
static Column* g_col_number_of_java_threads = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
912 |
static Column* g_col_number_of_java_threads_non_demon = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
913 |
static Column* g_col_size_thread_stacks = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
914 |
static Column* g_col_number_of_java_threads_created = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
915 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
916 |
static Column* g_col_number_of_clds = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
917 |
static Column* g_col_number_of_anon_clds = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
918 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
919 |
static Column* g_col_number_of_classes = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
920 |
static Column* g_col_number_of_class_loads = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
921 |
static Column* g_col_number_of_class_unloads = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
922 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
923 |
//... |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
924 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
925 |
static bool add_jvm_columns() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
926 |
// Order matters! |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
927 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
928 |
g_col_heap_committed = new MemorySizeColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
929 |
"heap", "comm", "Java Heap Size, committed"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
930 |
g_col_heap_used = new MemorySizeColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
931 |
"heap", "used", "Java Heap Size, used"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
932 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
933 |
g_col_metaspace_committed = new MemorySizeColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
934 |
"meta", "comm", "Meta Space Size (class+nonclass), committed"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
935 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
936 |
g_col_metaspace_used = new MemorySizeColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
937 |
"meta", "used", "Meta Space Size (class+nonclass), used"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
938 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
939 |
if (Metaspace::using_class_space()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
940 |
g_col_classspace_committed = new MemorySizeColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
941 |
"meta", "csc", "Class Space Size, committed"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
942 |
g_col_classspace_used = new MemorySizeColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
943 |
"meta", "csu", "Class Space Size, used"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
944 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
945 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
946 |
g_col_metaspace_cap_until_gc = new MemorySizeColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
947 |
"meta", "gctr", "GC threshold"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
948 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
949 |
g_col_codecache_committed = new MemorySizeColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
950 |
NULL, "code", "Code cache, committed"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
951 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
952 |
g_col_nmt_malloc = new MemorySizeColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
953 |
NULL, "mlc", "Memory malloced by hotspot (requires NMT)"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
954 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
955 |
g_col_number_of_java_threads = new PlainValueColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
956 |
"jthr", "num", "Number of java threads"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
957 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
958 |
g_col_number_of_java_threads_non_demon = new PlainValueColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
959 |
"jthr", "nd", "Number of non-demon java threads"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
960 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
961 |
g_col_number_of_java_threads_created = new DeltaValueColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
962 |
"jthr", "cr", "Threads created"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
963 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
964 |
g_col_size_thread_stacks = new MemorySizeColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
965 |
"jthr", "st", "Total reserved size of java thread stacks"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
966 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
967 |
g_col_number_of_clds = new PlainValueColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
968 |
"cldg", "num", "Classloader Data"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
969 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
970 |
g_col_number_of_anon_clds = new PlainValueColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
971 |
"cldg", "anon", "Anonymous CLD"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
972 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
973 |
g_col_number_of_classes = new PlainValueColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
974 |
"cls", "num", "Classes (instance + array)"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
975 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
976 |
g_col_number_of_class_loads = new DeltaValueColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
977 |
"cls", "ld", "Class loaded"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
978 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
979 |
g_col_number_of_class_unloads = new DeltaValueColumn("jvm", |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
980 |
"cls", "uld", "Classes unloaded"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
981 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
982 |
return true; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
983 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
984 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
985 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
986 |
////////// class ValueSampler and childs ///////////////// |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
987 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
988 |
template <typename T> |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
989 |
static void set_value_in_record(const Column* col, record_t* r, T t) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
990 |
if (col != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
991 |
int idx = col->index(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
992 |
assert(ColumnList::the_list()->is_valid_column_index(idx), "Invalid column index"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
993 |
r->values[idx] = (value_t)t; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
994 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
995 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
996 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
997 |
class AddStackSizeThreadClosure: public ThreadClosure { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
998 |
size_t _l; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
999 |
public: |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1000 |
AddStackSizeThreadClosure() : ThreadClosure(), _l(0) {} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1001 |
void do_thread(Thread* thread) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1002 |
_l += thread->stack_size(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1003 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1004 |
size_t get() const { return _l; } |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1005 |
}; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1006 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1007 |
static size_t accumulate_thread_stack_size() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1008 |
#if defined(LINUX) || defined(__APPLE__) |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1009 |
// Do not iterate thread list and query stack size until 8212173 is completely solved. It is solved |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1010 |
// for BSD and Linux; on the other platforms, one runs a miniscule but real risk of triggering |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1011 |
// the assert in Thread::stack_size(). |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1012 |
size_t l = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1013 |
AddStackSizeThreadClosure tc; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1014 |
{ |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1015 |
MutexLocker ml(Threads_lock); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1016 |
Threads::threads_do(&tc); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1017 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1018 |
return tc.get(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1019 |
#else |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1020 |
return INVALID_VALUE; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1021 |
#endif |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1022 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1023 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1024 |
// Count CLDs |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1025 |
class CLDCounterClosure: public CLDClosure { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1026 |
public: |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1027 |
int _cnt; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1028 |
int _anon_cnt; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1029 |
CLDCounterClosure() : _cnt(0), _anon_cnt(0) {} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1030 |
void do_cld(ClassLoaderData* cld) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1031 |
_cnt ++; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1032 |
if (cld->is_unsafe_anonymous()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1033 |
_anon_cnt ++; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1034 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1035 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1036 |
}; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1037 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1038 |
void sample_jvm_values(record_t* record, bool avoid_locking) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1039 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1040 |
// Heap |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1041 |
if (!avoid_locking) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1042 |
size_t heap_cap = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1043 |
size_t heap_used = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1044 |
const CollectedHeap* const heap = Universe::heap(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1045 |
if (heap != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1046 |
MutexLocker hl(Heap_lock); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1047 |
heap_cap = Universe::heap()->capacity(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1048 |
heap_used = Universe::heap()->used(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1049 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1050 |
set_value_in_record(g_col_heap_committed, record, heap_cap); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1051 |
set_value_in_record(g_col_heap_used, record, heap_used); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1052 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1053 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1054 |
// Metaspace |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1055 |
set_value_in_record(g_col_metaspace_committed, record, MetaspaceUtils::committed_bytes()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1056 |
set_value_in_record(g_col_metaspace_used, record, MetaspaceUtils::used_bytes()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1057 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1058 |
if (Metaspace::using_class_space()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1059 |
set_value_in_record(g_col_classspace_committed, record, MetaspaceUtils::committed_bytes(Metaspace::ClassType)); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1060 |
set_value_in_record(g_col_classspace_used, record, MetaspaceUtils::used_bytes(Metaspace::ClassType)); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1061 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1062 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1063 |
set_value_in_record(g_col_metaspace_cap_until_gc, record, MetaspaceGC::capacity_until_GC()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1064 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1065 |
// Code cache |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1066 |
const size_t codecache_committed = CodeCache::capacity(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1067 |
set_value_in_record(g_col_codecache_committed, record, codecache_committed); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1068 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1069 |
// NMT |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1070 |
if (!avoid_locking) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1071 |
size_t malloc_footprint = 0; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1072 |
if (MemTracker::tracking_level() != NMT_off) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1073 |
MutexLocker locker(MemTracker::query_lock()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1074 |
malloc_footprint = MallocMemorySummary::as_snapshot()->total(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1075 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1076 |
set_value_in_record(g_col_nmt_malloc, record, malloc_footprint); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1077 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1078 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1079 |
// Java threads |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1080 |
set_value_in_record(g_col_number_of_java_threads, record, Threads::number_of_threads()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1081 |
set_value_in_record(g_col_number_of_java_threads_non_demon, record, Threads::number_of_non_daemon_threads()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1082 |
set_value_in_record(g_col_number_of_java_threads_created, record, counters::g_threads_created); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1083 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1084 |
// Java thread stack size |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1085 |
if (!avoid_locking) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1086 |
set_value_in_record(g_col_size_thread_stacks, record, accumulate_thread_stack_size()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1087 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1088 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1089 |
// CLDG |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1090 |
if (!avoid_locking) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1091 |
CLDCounterClosure cl; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1092 |
{ |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1093 |
MutexLocker lck(ClassLoaderDataGraph_lock); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1094 |
ClassLoaderDataGraph::cld_do(&cl); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1095 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1096 |
set_value_in_record(g_col_number_of_clds, record, cl._cnt); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1097 |
set_value_in_record(g_col_number_of_anon_clds, record, cl._anon_cnt); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1098 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1099 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1100 |
// Classes |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1101 |
set_value_in_record(g_col_number_of_classes, record, |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1102 |
ClassLoaderDataGraph::num_instance_classes() + ClassLoaderDataGraph::num_array_classes()); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1103 |
set_value_in_record(g_col_number_of_class_loads, record, counters::g_classes_loaded); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1104 |
set_value_in_record(g_col_number_of_class_unloads, record, counters::g_classes_unloaded); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1105 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1106 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1107 |
bool initialize() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1108 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1109 |
if (!ColumnList::initialize()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1110 |
return false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1111 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1112 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1113 |
// Order matters. First platform columns, then jvm columns. |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1114 |
if (!platform_columns_initialize()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1115 |
return false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1116 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1117 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1118 |
if (!add_jvm_columns()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1119 |
return false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1120 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1121 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1122 |
// -- Now the number of columns is known (and fixed). -- |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1123 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1124 |
if (!initialize_widths_buffer()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1125 |
return false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1126 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1127 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1128 |
if (!initialize_space_for_now_record()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1129 |
return false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1130 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1131 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1132 |
if (!RecordTables::initialize()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1133 |
return false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1134 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1135 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1136 |
if (!initialize_sampler_thread()) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1137 |
return false; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1138 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1139 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1140 |
return true; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1141 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1142 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1143 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1144 |
void cleanup() { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1145 |
if (g_sampler_thread != NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1146 |
g_sampler_thread->stop(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1147 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1148 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1149 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1150 |
void print_report(outputStream* st, const print_info_t* pi) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1151 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1152 |
st->print("stathist:"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1153 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1154 |
if (ColumnList::the_list() == NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1155 |
st->print_cr(" (unavailable)"); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1156 |
return; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1157 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1158 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1159 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1160 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1161 |
static const print_info_t default_settings = { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1162 |
false, // raw |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1163 |
false, // cvs |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1164 |
false, // omit_legend |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1165 |
true // avoid_sampling |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1166 |
}; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1167 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1168 |
if (pi == NULL) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1169 |
pi = &default_settings; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1170 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1171 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1172 |
// Print legend at the top (omit if suppressed on command line, or in cvs mode). |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1173 |
if (pi->no_legend == false && pi->cvs == false) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1174 |
print_legend(st, pi); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1175 |
st->cr(); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1176 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1177 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1178 |
CLocaleMark locale_mark; // Print all numbers with locale "C" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1179 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1180 |
record_t* values_now = NULL; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1181 |
if (!pi->avoid_sampling) { |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1182 |
// Sample the current values (not when reporting errors, since we do not want to risk secondary errors). |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1183 |
values_now = g_record_now; |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1184 |
values_now->timestamp = 0; // means "Now" |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1185 |
sample_values(values_now, true); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1186 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1187 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1188 |
RecordTables::the_tables()->print_all(st, pi, values_now); |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1189 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1190 |
} |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1191 |
|
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1192 |
} // namespace StatisticsHistory |
9653470b7294
Initial implementation of statistical history (JDK-8212618)
stuefe
parents:
diff
changeset
|
1193 |