runtimeService.cpp revision 4430
0N/A/*
3258N/A * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation.
0N/A *
2362N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
2362N/A *
2362N/A */
0N/A
0N/A#include "precompiled.hpp"
0N/A#include "classfile/classLoader.hpp"
0N/A#include "services/attachListener.hpp"
0N/A#include "services/management.hpp"
0N/A#include "services/runtimeService.hpp"
0N/A#include "utilities/dtrace.hpp"
0N/A#include "utilities/exceptions.hpp"
0N/A
0N/A#ifndef USDT2
0N/AHS_DTRACE_PROBE_DECL(hs_private, safepoint__begin);
0N/AHS_DTRACE_PROBE_DECL(hs_private, safepoint__end);
0N/A#endif /* !USDT2 */
0N/A
0N/ATimeStamp RuntimeService::_app_timer;
0N/ATimeStamp RuntimeService::_safepoint_timer;
0N/APerfCounter* RuntimeService::_sync_time_ticks = NULL;
0N/APerfCounter* RuntimeService::_total_safepoints = NULL;
0N/APerfCounter* RuntimeService::_safepoint_time_ticks = NULL;
0N/APerfCounter* RuntimeService::_application_time_ticks = NULL;
0N/APerfCounter* RuntimeService::_thread_interrupt_signaled_count = NULL;
0N/APerfCounter* RuntimeService::_interrupted_before_count = NULL;
168N/APerfCounter* RuntimeService::_interrupted_during_count = NULL;
168N/A
3258N/Avoid RuntimeService::init() {
3258N/A // Make sure the VM version is initialized
3258N/A Abstract_VM_Version::initialize();
3258N/A
0N/A if (UsePerfData) {
0N/A EXCEPTION_MARK;
0N/A
0N/A _sync_time_ticks =
0N/A PerfDataManager::create_counter(SUN_RT, "safepointSyncTime",
0N/A PerfData::U_Ticks, CHECK);
0N/A
0N/A _total_safepoints =
3258N/A PerfDataManager::create_counter(SUN_RT, "safepoints",
0N/A PerfData::U_Events, CHECK);
0N/A
0N/A _safepoint_time_ticks =
0N/A PerfDataManager::create_counter(SUN_RT, "safepointTime",
795N/A PerfData::U_Ticks, CHECK);
0N/A
3258N/A _application_time_ticks =
0N/A PerfDataManager::create_counter(SUN_RT, "applicationTime",
0N/A PerfData::U_Ticks, CHECK);
3258N/A
795N/A
795N/A // create performance counters for jvm_version and its capabilities
795N/A PerfDataManager::create_constant(SUN_RT, "jvmVersion", PerfData::U_None,
795N/A (jlong) Abstract_VM_Version::jvm_version(), CHECK);
3258N/A
795N/A // I/O interruption related counters
3258N/A
3258N/A // thread signaling via os::interrupt()
3258N/A
2324N/A _thread_interrupt_signaled_count =
0N/A PerfDataManager::create_counter(SUN_RT,
795N/A "threadInterruptSignaled", PerfData::U_Events, CHECK);
0N/A
0N/A // OS_INTRPT via "check before" in _INTERRUPTIBLE
0N/A
0N/A _interrupted_before_count =
0N/A PerfDataManager::create_counter(SUN_RT, "interruptedBeforeIO",
0N/A PerfData::U_Events, CHECK);
0N/A
0N/A // OS_INTRPT via "check during" in _INTERRUPTIBLE
0N/A
3258N/A _interrupted_during_count =
0N/A PerfDataManager::create_counter(SUN_RT, "interruptedDuringIO",
0N/A PerfData::U_Events, CHECK);
0N/A
0N/A // The capabilities counter is a binary representation of the VM capabilities in string.
1365N/A // This string respresentation simplifies the implementation of the client side
3258N/A // to parse the value.
3258N/A char capabilities[65];
3258N/A size_t len = sizeof(capabilities);
0N/A memset((void*) capabilities, '0', len);
0N/A capabilities[len-1] = '\0';
0N/A capabilities[0] = AttachListener::is_attach_supported() ? '1' : '0';
0N/A PerfDataManager::create_string_constant(SUN_RT, "jvmCapabilities",
0N/A capabilities, CHECK);
0N/A }
0N/A}
0N/A
0N/Avoid RuntimeService::record_safepoint_begin() {
0N/A#ifndef USDT2
0N/A HS_DTRACE_PROBE(hs_private, safepoint__begin);
0N/A#else /* USDT2 */
1365N/A HS_PRIVATE_SAFEPOINT_BEGIN();
1365N/A#endif /* USDT2 */
0N/A
0N/A // Print the time interval in which the app was executing
942N/A if (PrintGCApplicationConcurrentTime) {
942N/A gclog_or_tty->date_stamp(PrintGCDateStamps);
942N/A gclog_or_tty->stamp(PrintGCTimeStamps);
942N/A gclog_or_tty->print_cr("Application time: %3.7f seconds",
942N/A last_application_time_sec());
2324N/A }
2324N/A
3258N/A // update the time stamp to begin recording safepoint time
3258N/A _safepoint_timer.update();
3258N/A if (UsePerfData) {
3258N/A _total_safepoints->inc();
3258N/A if (_app_timer.is_updated()) {
3258N/A _application_time_ticks->inc(_app_timer.ticks_since_update());
3258N/A }
3258N/A }
942N/A}
3258N/A
3258N/Avoid RuntimeService::record_safepoint_synchronized() {
3258N/A if (UsePerfData) {
3258N/A _sync_time_ticks->inc(_safepoint_timer.ticks_since_update());
3258N/A }
3258N/A}
3258N/A
3258N/Avoid RuntimeService::record_safepoint_end() {
0N/A#ifndef USDT2
3258N/A HS_DTRACE_PROBE(hs_private, safepoint__end);
3258N/A#else /* USDT2 */
3258N/A HS_PRIVATE_SAFEPOINT_END();
3258N/A#endif /* USDT2 */
3258N/A
3258N/A // Print the time interval for which the app was stopped
3258N/A // during the current safepoint operation.
3258N/A if (PrintGCApplicationStoppedTime) {
3258N/A gclog_or_tty->date_stamp(PrintGCDateStamps);
0N/A gclog_or_tty->stamp(PrintGCTimeStamps);
0N/A gclog_or_tty->print_cr("Total time for which application threads "
0N/A "were stopped: %3.7f seconds",
0N/A last_safepoint_time_sec());
3258N/A }
0N/A
0N/A // update the time stamp to begin recording app time
3258N/A _app_timer.update();
3258N/A if (UsePerfData) {
3258N/A _safepoint_time_ticks->inc(_safepoint_timer.ticks_since_update());
0N/A }
0N/A}
void RuntimeService::record_application_start() {
// update the time stamp to begin recording app time
_app_timer.update();
}
// Don't need to record application end because we currently
// exit at a safepoint and record_safepoint_begin() handles updating
// the application time counter at VM exit.
jlong RuntimeService::safepoint_sync_time_ms() {
return UsePerfData ?
Management::ticks_to_ms(_sync_time_ticks->get_value()) : -1;
}
jlong RuntimeService::safepoint_count() {
return UsePerfData ?
_total_safepoints->get_value() : -1;
}
jlong RuntimeService::safepoint_time_ms() {
return UsePerfData ?
Management::ticks_to_ms(_safepoint_time_ticks->get_value()) : -1;
}
jlong RuntimeService::application_time_ms() {
return UsePerfData ?
Management::ticks_to_ms(_application_time_ticks->get_value()) : -1;
}
void RuntimeService::record_interrupted_before_count() {
if (UsePerfData) {
_interrupted_before_count->inc();
}
}
void RuntimeService::record_interrupted_during_count() {
if (UsePerfData) {
_interrupted_during_count->inc();
}
}
void RuntimeService::record_thread_interrupt_signaled_count() {
if (UsePerfData) {
_thread_interrupt_signaled_count->inc();
}
}