/* * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
/* * This is left empty on purpose, having ExecutionSample as a requestable * is a way of getting the period. The period is passed to ThreadSampling::update_period. * Implementation in jfrSamples.cpp
*/
TRACE_REQUEST_FUNC(ExecutionSample) {
}
TRACE_REQUEST_FUNC(NativeMethodSample) {
}
TRACE_REQUEST_FUNC(CPUInformation) {
CPUInformation cpu_info; int ret_val = JfrOSInterface::cpu_information(cpu_info); if (ret_val == OS_ERR) {
log_debug(jfr, system)( "Unable to generate requestable event CPUInformation"); return;
} if (ret_val == FUNCTIONALITY_NOT_IMPLEMENTED) { return;
} if (ret_val == OS_OK) {
EventCPUInformation event;
event.set_cpu(cpu_info.cpu_name());
event.set_description(cpu_info.cpu_description());
event.set_sockets(cpu_info.number_of_sockets());
event.set_cores(cpu_info.number_of_cores());
event.set_hwThreads(cpu_info.number_of_hardware_threads());
event.commit();
}
}
TRACE_REQUEST_FUNC(CPULoad) { double u = 0; // user time double s = 0; // kernel time double t = 0; // total time int ret_val = OS_ERR;
{ // Can take some time on certain platforms, especially under heavy load. // Transition to native to avoid unnecessary stalls for pending safepoint synchronizations.
ThreadToNativeFromVM transition(JavaThread::current());
ret_val = JfrOSInterface::cpu_loads_process(&u, &s, &t);
} if (ret_val == OS_ERR) {
log_debug(jfr, system)( "Unable to generate requestable event CPULoad"); return;
} if (ret_val == OS_OK) {
EventCPULoad event;
event.set_jvmUser((float)u);
event.set_jvmSystem((float)s);
event.set_machineTotal((float)t);
event.commit();
}
}
TRACE_REQUEST_FUNC(SystemProcess) { char pid_buf[16];
SystemProcess* processes = NULL; int num_of_processes = 0;
JfrTicks start_time = JfrTicks::now(); int ret_val = JfrOSInterface::system_processes(&processes, &num_of_processes); if (ret_val == OS_ERR) {
log_debug(jfr, system)( "Unable to generate requestable event SystemProcesses"); return;
}
JfrTicks end_time = JfrTicks::now(); if (ret_val == FUNCTIONALITY_NOT_IMPLEMENTED) { return;
} if (ret_val == OS_OK) { // feature is implemented, write real event while (processes != NULL) {
SystemProcess* tmp = processes; constchar* info = processes->command_line(); if (info == NULL) {
info = processes->path();
} if (info == NULL) {
info = processes->name();
} if (info == NULL) {
info = "?";
}
jio_snprintf(pid_buf, sizeof(pid_buf), "%d", processes->pid());
EventSystemProcess event(UNTIMED);
event.set_pid(pid_buf);
event.set_commandLine(info);
event.set_starttime(start_time);
event.set_endtime(end_time);
event.commit();
processes = processes->next(); delete tmp;
}
}
}
TRACE_REQUEST_FUNC(ThreadContextSwitchRate) { double rate = 0.0; int ret_val = OS_ERR;
{ // Can take some time on certain platforms, especially under heavy load. // Transition to native to avoid unnecessary stalls for pending safepoint synchronizations.
ThreadToNativeFromVM transition(JavaThread::current());
ret_val = JfrOSInterface::context_switch_rate(&rate);
} if (ret_val == OS_ERR) {
log_debug(jfr, system)( "Unable to generate requestable event ThreadContextSwitchRate"); return;
} if (ret_val == FUNCTIONALITY_NOT_IMPLEMENTED) { return;
} if (ret_val == OS_OK) {
EventThreadContextSwitchRate event;
event.set_switchRate((float)rate + 0.0f);
event.commit();
}
}
// Write allocation statistics to buffer. for(int i = 0; i < thread_ids.length(); i++) {
EventThreadAllocationStatistics event(UNTIMED);
event.set_allocated(allocated.at(i));
event.set_thread(thread_ids.at(i));
event.set_starttime(time_stamp);
event.set_endtime(time_stamp);
event.commit();
}
}
/** * PhysicalMemory event represents: * * @totalSize == The amount of physical memory (hw) installed and reported by the OS, in bytes. * @usedSize == The amount of physical memory currently in use in the system (reserved/committed), in bytes. * * Both fields are systemwide, i.e. represents the entire OS/HW environment. * These fields do not include virtual memory. * * If running inside a guest OS on top of a hypervisor in a virtualized environment, * the total memory reported is the amount of memory configured for the guest OS by the hypervisor.
*/
TRACE_REQUEST_FUNC(PhysicalMemory) {
u8 totalPhysicalMemory = os::physical_memory();
EventPhysicalMemory event;
event.set_totalSize(totalPhysicalMemory);
event.set_usedSize(totalPhysicalMemory - os::available_memory());
event.commit();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.