29 #include "services/runtimeService.hpp"
30 #include "utilities/dtrace.hpp"
31 #include "utilities/exceptions.hpp"
32 #include "utilities/macros.hpp"
33
34 #ifndef USDT2
35 HS_DTRACE_PROBE_DECL(hs_private, safepoint__begin);
36 HS_DTRACE_PROBE_DECL(hs_private, safepoint__end);
37 #endif /* !USDT2 */
38
39 #if INCLUDE_MANAGEMENT
40 TimeStamp RuntimeService::_app_timer;
41 TimeStamp RuntimeService::_safepoint_timer;
42 PerfCounter* RuntimeService::_sync_time_ticks = NULL;
43 PerfCounter* RuntimeService::_total_safepoints = NULL;
44 PerfCounter* RuntimeService::_safepoint_time_ticks = NULL;
45 PerfCounter* RuntimeService::_application_time_ticks = NULL;
46 PerfCounter* RuntimeService::_thread_interrupt_signaled_count = NULL;
47 PerfCounter* RuntimeService::_interrupted_before_count = NULL;
48 PerfCounter* RuntimeService::_interrupted_during_count = NULL;
49
50 void RuntimeService::init() {
51 // Make sure the VM version is initialized
52 Abstract_VM_Version::initialize();
53
54 if (UsePerfData) {
55 EXCEPTION_MARK;
56
57 _sync_time_ticks =
58 PerfDataManager::create_counter(SUN_RT, "safepointSyncTime",
59 PerfData::U_Ticks, CHECK);
60
61 _total_safepoints =
62 PerfDataManager::create_counter(SUN_RT, "safepoints",
63 PerfData::U_Events, CHECK);
64
65 _safepoint_time_ticks =
66 PerfDataManager::create_counter(SUN_RT, "safepointTime",
67 PerfData::U_Ticks, CHECK);
68
111 }
112 }
113
114 void RuntimeService::record_safepoint_begin() {
115 #ifndef USDT2
116 HS_DTRACE_PROBE(hs_private, safepoint__begin);
117 #else /* USDT2 */
118 HS_PRIVATE_SAFEPOINT_BEGIN();
119 #endif /* USDT2 */
120
121 // Print the time interval in which the app was executing
122 if (PrintGCApplicationConcurrentTime && _app_timer.is_updated()) {
123 gclog_or_tty->date_stamp(PrintGCDateStamps);
124 gclog_or_tty->stamp(PrintGCTimeStamps);
125 gclog_or_tty->print_cr("Application time: %3.7f seconds",
126 last_application_time_sec());
127 }
128
129 // update the time stamp to begin recording safepoint time
130 _safepoint_timer.update();
131 if (UsePerfData) {
132 _total_safepoints->inc();
133 if (_app_timer.is_updated()) {
134 _application_time_ticks->inc(_app_timer.ticks_since_update());
135 }
136 }
137 }
138
139 void RuntimeService::record_safepoint_synchronized() {
140 if (UsePerfData) {
141 _sync_time_ticks->inc(_safepoint_timer.ticks_since_update());
142 }
143 }
144
145 void RuntimeService::record_safepoint_end() {
146 #ifndef USDT2
147 HS_DTRACE_PROBE(hs_private, safepoint__end);
148 #else /* USDT2 */
149 HS_PRIVATE_SAFEPOINT_END();
150 #endif /* USDT2 */
151
152 // Print the time interval for which the app was stopped
153 // during the current safepoint operation.
154 if (PrintGCApplicationStoppedTime) {
155 gclog_or_tty->date_stamp(PrintGCDateStamps);
156 gclog_or_tty->stamp(PrintGCTimeStamps);
157 gclog_or_tty->print_cr("Total time for which application threads "
158 "were stopped: %3.7f seconds",
159 last_safepoint_time_sec());
160 }
161
162 // update the time stamp to begin recording app time
163 _app_timer.update();
164 if (UsePerfData) {
165 _safepoint_time_ticks->inc(_safepoint_timer.ticks_since_update());
166 }
167 }
168
169 void RuntimeService::record_application_start() {
170 // update the time stamp to begin recording app time
171 _app_timer.update();
172 }
173
174 // Don't need to record application end because we currently
175 // exit at a safepoint and record_safepoint_begin() handles updating
176 // the application time counter at VM exit.
177
178 jlong RuntimeService::safepoint_sync_time_ms() {
179 return UsePerfData ?
|
29 #include "services/runtimeService.hpp"
30 #include "utilities/dtrace.hpp"
31 #include "utilities/exceptions.hpp"
32 #include "utilities/macros.hpp"
33
34 #ifndef USDT2
35 HS_DTRACE_PROBE_DECL(hs_private, safepoint__begin);
36 HS_DTRACE_PROBE_DECL(hs_private, safepoint__end);
37 #endif /* !USDT2 */
38
39 #if INCLUDE_MANAGEMENT
40 TimeStamp RuntimeService::_app_timer;
41 TimeStamp RuntimeService::_safepoint_timer;
42 PerfCounter* RuntimeService::_sync_time_ticks = NULL;
43 PerfCounter* RuntimeService::_total_safepoints = NULL;
44 PerfCounter* RuntimeService::_safepoint_time_ticks = NULL;
45 PerfCounter* RuntimeService::_application_time_ticks = NULL;
46 PerfCounter* RuntimeService::_thread_interrupt_signaled_count = NULL;
47 PerfCounter* RuntimeService::_interrupted_before_count = NULL;
48 PerfCounter* RuntimeService::_interrupted_during_count = NULL;
49 double RuntimeService::_last_safepoint_sync_time_sec = 0.0;
50
51 void RuntimeService::init() {
52 // Make sure the VM version is initialized
53 Abstract_VM_Version::initialize();
54
55 if (UsePerfData) {
56 EXCEPTION_MARK;
57
58 _sync_time_ticks =
59 PerfDataManager::create_counter(SUN_RT, "safepointSyncTime",
60 PerfData::U_Ticks, CHECK);
61
62 _total_safepoints =
63 PerfDataManager::create_counter(SUN_RT, "safepoints",
64 PerfData::U_Events, CHECK);
65
66 _safepoint_time_ticks =
67 PerfDataManager::create_counter(SUN_RT, "safepointTime",
68 PerfData::U_Ticks, CHECK);
69
112 }
113 }
114
115 void RuntimeService::record_safepoint_begin() {
116 #ifndef USDT2
117 HS_DTRACE_PROBE(hs_private, safepoint__begin);
118 #else /* USDT2 */
119 HS_PRIVATE_SAFEPOINT_BEGIN();
120 #endif /* USDT2 */
121
122 // Print the time interval in which the app was executing
123 if (PrintGCApplicationConcurrentTime && _app_timer.is_updated()) {
124 gclog_or_tty->date_stamp(PrintGCDateStamps);
125 gclog_or_tty->stamp(PrintGCTimeStamps);
126 gclog_or_tty->print_cr("Application time: %3.7f seconds",
127 last_application_time_sec());
128 }
129
130 // update the time stamp to begin recording safepoint time
131 _safepoint_timer.update();
132 _last_safepoint_sync_time_sec = 0.0;
133 if (UsePerfData) {
134 _total_safepoints->inc();
135 if (_app_timer.is_updated()) {
136 _application_time_ticks->inc(_app_timer.ticks_since_update());
137 }
138 }
139 }
140
141 void RuntimeService::record_safepoint_synchronized() {
142 if (UsePerfData) {
143 _sync_time_ticks->inc(_safepoint_timer.ticks_since_update());
144 }
145 if (PrintGCApplicationStoppedTime) {
146 _last_safepoint_sync_time_sec = last_safepoint_time_sec();
147 }
148 }
149
150 void RuntimeService::record_safepoint_end() {
151 #ifndef USDT2
152 HS_DTRACE_PROBE(hs_private, safepoint__end);
153 #else /* USDT2 */
154 HS_PRIVATE_SAFEPOINT_END();
155 #endif /* USDT2 */
156
157 // Print the time interval for which the app was stopped
158 // during the current safepoint operation.
159 if (PrintGCApplicationStoppedTime) {
160 gclog_or_tty->date_stamp(PrintGCDateStamps);
161 gclog_or_tty->stamp(PrintGCTimeStamps);
162 gclog_or_tty->print_cr("Total time for which application threads "
163 "were stopped: %3.7f seconds, "
164 "Stopping threads took: %3.7f seconds",
165 last_safepoint_time_sec(),
166 _last_safepoint_sync_time_sec);
167 }
168
169 // update the time stamp to begin recording app time
170 _app_timer.update();
171 if (UsePerfData) {
172 _safepoint_time_ticks->inc(_safepoint_timer.ticks_since_update());
173 }
174 }
175
176 void RuntimeService::record_application_start() {
177 // update the time stamp to begin recording app time
178 _app_timer.update();
179 }
180
181 // Don't need to record application end because we currently
182 // exit at a safepoint and record_safepoint_begin() handles updating
183 // the application time counter at VM exit.
184
185 jlong RuntimeService::safepoint_sync_time_ms() {
186 return UsePerfData ?
|