author | stefank |
Fri, 13 Feb 2015 14:37:35 +0100 | |
changeset 29081 | c61eb4914428 |
parent 27462 | 2fef16b8c70f |
child 29201 | fee2bbb2ec1d |
permissions | -rw-r--r-- |
1 | 1 |
/* |
23443
15e8ed68f73a
8036128: Remove deprecated VM flag UseVMInterruptibleIO
fparain
parents:
22796
diff
changeset
|
2 |
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4901
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4901
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4901
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/classLoader.hpp" |
|
27 |
#include "services/attachListener.hpp" |
|
28 |
#include "services/management.hpp" |
|
29 |
#include "services/runtimeService.hpp" |
|
30 |
#include "utilities/dtrace.hpp" |
|
31 |
#include "utilities/exceptions.hpp" |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
13975
diff
changeset
|
32 |
#include "utilities/macros.hpp" |
1 | 33 |
|
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
10739
diff
changeset
|
34 |
#if INCLUDE_MANAGEMENT |
1 | 35 |
TimeStamp RuntimeService::_app_timer; |
36 |
TimeStamp RuntimeService::_safepoint_timer; |
|
37 |
PerfCounter* RuntimeService::_sync_time_ticks = NULL; |
|
38 |
PerfCounter* RuntimeService::_total_safepoints = NULL; |
|
39 |
PerfCounter* RuntimeService::_safepoint_time_ticks = NULL; |
|
40 |
PerfCounter* RuntimeService::_application_time_ticks = NULL; |
|
27462
2fef16b8c70f
8059216: Make PrintGCApplicationStoppedTime print information about stopping threads
vkempik
parents:
23443
diff
changeset
|
41 |
double RuntimeService::_last_safepoint_sync_time_sec = 0.0; |
1 | 42 |
|
43 |
void RuntimeService::init() { |
|
44 |
// Make sure the VM version is initialized |
|
45 |
Abstract_VM_Version::initialize(); |
|
46 |
||
47 |
if (UsePerfData) { |
|
48 |
EXCEPTION_MARK; |
|
49 |
||
50 |
_sync_time_ticks = |
|
51 |
PerfDataManager::create_counter(SUN_RT, "safepointSyncTime", |
|
52 |
PerfData::U_Ticks, CHECK); |
|
53 |
||
54 |
_total_safepoints = |
|
55 |
PerfDataManager::create_counter(SUN_RT, "safepoints", |
|
56 |
PerfData::U_Events, CHECK); |
|
57 |
||
58 |
_safepoint_time_ticks = |
|
59 |
PerfDataManager::create_counter(SUN_RT, "safepointTime", |
|
60 |
PerfData::U_Ticks, CHECK); |
|
61 |
||
62 |
_application_time_ticks = |
|
63 |
PerfDataManager::create_counter(SUN_RT, "applicationTime", |
|
64 |
PerfData::U_Ticks, CHECK); |
|
65 |
||
66 |
||
67 |
// create performance counters for jvm_version and its capabilities |
|
68 |
PerfDataManager::create_constant(SUN_RT, "jvmVersion", PerfData::U_None, |
|
69 |
(jlong) Abstract_VM_Version::jvm_version(), CHECK); |
|
70 |
||
71 |
// The capabilities counter is a binary representation of the VM capabilities in string. |
|
72 |
// This string respresentation simplifies the implementation of the client side |
|
73 |
// to parse the value. |
|
74 |
char capabilities[65]; |
|
75 |
size_t len = sizeof(capabilities); |
|
76 |
memset((void*) capabilities, '0', len); |
|
77 |
capabilities[len-1] = '\0'; |
|
78 |
capabilities[0] = AttachListener::is_attach_supported() ? '1' : '0'; |
|
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
10739
diff
changeset
|
79 |
#if INCLUDE_SERVICES |
1 | 80 |
capabilities[1] = '1'; |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
10739
diff
changeset
|
81 |
#endif // INCLUDE_SERVICES |
1 | 82 |
PerfDataManager::create_string_constant(SUN_RT, "jvmCapabilities", |
83 |
capabilities, CHECK); |
|
84 |
} |
|
85 |
} |
|
86 |
||
87 |
void RuntimeService::record_safepoint_begin() { |
|
10739 | 88 |
HS_PRIVATE_SAFEPOINT_BEGIN(); |
4901
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
89 |
|
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
90 |
// Print the time interval in which the app was executing |
20679
7885e9e68382
8026041: JVM crashes with assert "assert(is_updated()) failed: must not be clear" with -XX:+PrintGCApplicationConcurrentTime in -Xcomp mode
hseigel
parents:
16998
diff
changeset
|
91 |
if (PrintGCApplicationConcurrentTime && _app_timer.is_updated()) { |
16998
d61c4c63f619
8012455: Missing time and date stamps for PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime
brutisso
parents:
15482
diff
changeset
|
92 |
gclog_or_tty->date_stamp(PrintGCDateStamps); |
d61c4c63f619
8012455: Missing time and date stamps for PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime
brutisso
parents:
15482
diff
changeset
|
93 |
gclog_or_tty->stamp(PrintGCTimeStamps); |
4901
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
94 |
gclog_or_tty->print_cr("Application time: %3.7f seconds", |
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
95 |
last_application_time_sec()); |
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
96 |
} |
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
97 |
|
1 | 98 |
// update the time stamp to begin recording safepoint time |
99 |
_safepoint_timer.update(); |
|
27462
2fef16b8c70f
8059216: Make PrintGCApplicationStoppedTime print information about stopping threads
vkempik
parents:
23443
diff
changeset
|
100 |
_last_safepoint_sync_time_sec = 0.0; |
1 | 101 |
if (UsePerfData) { |
102 |
_total_safepoints->inc(); |
|
103 |
if (_app_timer.is_updated()) { |
|
104 |
_application_time_ticks->inc(_app_timer.ticks_since_update()); |
|
105 |
} |
|
106 |
} |
|
107 |
} |
|
108 |
||
109 |
void RuntimeService::record_safepoint_synchronized() { |
|
110 |
if (UsePerfData) { |
|
111 |
_sync_time_ticks->inc(_safepoint_timer.ticks_since_update()); |
|
112 |
} |
|
27462
2fef16b8c70f
8059216: Make PrintGCApplicationStoppedTime print information about stopping threads
vkempik
parents:
23443
diff
changeset
|
113 |
if (PrintGCApplicationStoppedTime) { |
2fef16b8c70f
8059216: Make PrintGCApplicationStoppedTime print information about stopping threads
vkempik
parents:
23443
diff
changeset
|
114 |
_last_safepoint_sync_time_sec = last_safepoint_time_sec(); |
2fef16b8c70f
8059216: Make PrintGCApplicationStoppedTime print information about stopping threads
vkempik
parents:
23443
diff
changeset
|
115 |
} |
1 | 116 |
} |
117 |
||
118 |
void RuntimeService::record_safepoint_end() { |
|
10739 | 119 |
HS_PRIVATE_SAFEPOINT_END(); |
4901
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
120 |
|
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
121 |
// Print the time interval for which the app was stopped |
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
122 |
// during the current safepoint operation. |
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
123 |
if (PrintGCApplicationStoppedTime) { |
16998
d61c4c63f619
8012455: Missing time and date stamps for PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime
brutisso
parents:
15482
diff
changeset
|
124 |
gclog_or_tty->date_stamp(PrintGCDateStamps); |
d61c4c63f619
8012455: Missing time and date stamps for PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime
brutisso
parents:
15482
diff
changeset
|
125 |
gclog_or_tty->stamp(PrintGCTimeStamps); |
4901
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
126 |
gclog_or_tty->print_cr("Total time for which application threads " |
27462
2fef16b8c70f
8059216: Make PrintGCApplicationStoppedTime print information about stopping threads
vkempik
parents:
23443
diff
changeset
|
127 |
"were stopped: %3.7f seconds, " |
2fef16b8c70f
8059216: Make PrintGCApplicationStoppedTime print information about stopping threads
vkempik
parents:
23443
diff
changeset
|
128 |
"Stopping threads took: %3.7f seconds", |
2fef16b8c70f
8059216: Make PrintGCApplicationStoppedTime print information about stopping threads
vkempik
parents:
23443
diff
changeset
|
129 |
last_safepoint_time_sec(), |
2fef16b8c70f
8059216: Make PrintGCApplicationStoppedTime print information about stopping threads
vkempik
parents:
23443
diff
changeset
|
130 |
_last_safepoint_sync_time_sec); |
4901
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
131 |
} |
304ce755c6ee
6782663: Data produced by PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime is not accurate.
johnc
parents:
1
diff
changeset
|
132 |
|
1 | 133 |
// update the time stamp to begin recording app time |
134 |
_app_timer.update(); |
|
135 |
if (UsePerfData) { |
|
136 |
_safepoint_time_ticks->inc(_safepoint_timer.ticks_since_update()); |
|
137 |
} |
|
138 |
} |
|
139 |
||
140 |
void RuntimeService::record_application_start() { |
|
141 |
// update the time stamp to begin recording app time |
|
142 |
_app_timer.update(); |
|
143 |
} |
|
144 |
||
145 |
// Don't need to record application end because we currently |
|
146 |
// exit at a safepoint and record_safepoint_begin() handles updating |
|
147 |
// the application time counter at VM exit. |
|
148 |
||
149 |
jlong RuntimeService::safepoint_sync_time_ms() { |
|
150 |
return UsePerfData ? |
|
151 |
Management::ticks_to_ms(_sync_time_ticks->get_value()) : -1; |
|
152 |
} |
|
153 |
||
154 |
jlong RuntimeService::safepoint_count() { |
|
155 |
return UsePerfData ? |
|
156 |
_total_safepoints->get_value() : -1; |
|
157 |
} |
|
158 |
jlong RuntimeService::safepoint_time_ms() { |
|
159 |
return UsePerfData ? |
|
160 |
Management::ticks_to_ms(_safepoint_time_ticks->get_value()) : -1; |
|
161 |
} |
|
162 |
||
163 |
jlong RuntimeService::application_time_ms() { |
|
164 |
return UsePerfData ? |
|
165 |
Management::ticks_to_ms(_application_time_ticks->get_value()) : -1; |
|
166 |
} |
|
167 |
||
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
10739
diff
changeset
|
168 |
#endif // INCLUDE_MANAGEMENT |