Mon, 12 Aug 2019 18:30:40 +0300
8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens
apetushkov@9858 | 1 | /* |
apetushkov@9858 | 2 | * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. |
apetushkov@9858 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
apetushkov@9858 | 4 | * |
apetushkov@9858 | 5 | * This code is free software; you can redistribute it and/or modify it |
apetushkov@9858 | 6 | * under the terms of the GNU General Public License version 2 only, as |
apetushkov@9858 | 7 | * published by the Free Software Foundation. |
apetushkov@9858 | 8 | * |
apetushkov@9858 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
apetushkov@9858 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
apetushkov@9858 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
apetushkov@9858 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
apetushkov@9858 | 13 | * accompanied this code). |
apetushkov@9858 | 14 | * |
apetushkov@9858 | 15 | * You should have received a copy of the GNU General Public License version |
apetushkov@9858 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
apetushkov@9858 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
apetushkov@9858 | 18 | * |
apetushkov@9858 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
apetushkov@9858 | 20 | * or visit www.oracle.com if you need additional information or have any |
apetushkov@9858 | 21 | * questions. |
apetushkov@9858 | 22 | * |
apetushkov@9858 | 23 | */ |
apetushkov@9858 | 24 | |
apetushkov@9858 | 25 | #include "precompiled.hpp" |
apetushkov@9858 | 26 | #include "jvm.h" |
apetushkov@9858 | 27 | #include "classfile/classLoaderStats.hpp" |
apetushkov@9858 | 28 | #include "classfile/javaClasses.hpp" |
apetushkov@9858 | 29 | #include "code/codeCache.hpp" |
apetushkov@9858 | 30 | #include "compiler/compileBroker.hpp" |
apetushkov@9858 | 31 | #include "gc_implementation/g1/g1HeapRegionEventSender.hpp" |
apetushkov@9858 | 32 | #include "gc_implementation/shared/gcConfiguration.hpp" |
apetushkov@9858 | 33 | #include "gc_implementation/shared/gcTrace.hpp" |
apetushkov@9858 | 34 | #include "gc_implementation/shared/objectCountEventSender.hpp" |
apetushkov@9858 | 35 | #include "gc_implementation/shared/vmGCOperations.hpp" |
apetushkov@9858 | 36 | #include "jfr/jfrEvents.hpp" |
apetushkov@9858 | 37 | #include "jfr/periodic/jfrOSInterface.hpp" |
apetushkov@9858 | 38 | #include "jfr/periodic/jfrThreadCPULoadEvent.hpp" |
apetushkov@9858 | 39 | #include "jfr/periodic/jfrThreadDumpEvent.hpp" |
apetushkov@9858 | 40 | #include "jfr/periodic/jfrNetworkUtilization.hpp" |
apetushkov@9858 | 41 | #include "jfr/recorder/jfrRecorder.hpp" |
apetushkov@9858 | 42 | #include "jfr/support/jfrThreadId.hpp" |
apetushkov@9858 | 43 | #include "jfr/utilities/jfrTime.hpp" |
apetushkov@9858 | 44 | #include "jfrfiles/jfrPeriodic.hpp" |
apetushkov@9858 | 45 | #include "memory/heapInspection.hpp" |
apetushkov@9858 | 46 | #include "memory/resourceArea.hpp" |
apetushkov@9858 | 47 | #include "oops/oop.inline.hpp" |
apetushkov@9858 | 48 | #include "runtime/arguments.hpp" |
apetushkov@9858 | 49 | #include "runtime/globals.hpp" |
apetushkov@9858 | 50 | #include "runtime/os.hpp" |
apetushkov@9858 | 51 | #include "runtime/os_perf.hpp" |
apetushkov@9858 | 52 | #include "runtime/thread.inline.hpp" |
apetushkov@9858 | 53 | #include "runtime/sweeper.hpp" |
apetushkov@9858 | 54 | #include "runtime/vmThread.hpp" |
apetushkov@9858 | 55 | #include "services/classLoadingService.hpp" |
apetushkov@9858 | 56 | #include "services/management.hpp" |
apetushkov@9858 | 57 | #include "services/threadService.hpp" |
apetushkov@9858 | 58 | #include "utilities/exceptions.hpp" |
apetushkov@9858 | 59 | #include "utilities/globalDefinitions.hpp" |
apetushkov@9858 | 60 | |
apetushkov@9858 | 61 | /** |
apetushkov@9858 | 62 | * JfrPeriodic class |
apetushkov@9858 | 63 | * Implementation of declarations in |
apetushkov@9858 | 64 | * xsl generated traceRequestables.hpp |
apetushkov@9858 | 65 | */ |
apetushkov@9858 | 66 | #define TRACE_REQUEST_FUNC(id) void JfrPeriodicEventSet::request##id(void) |
apetushkov@9858 | 67 | |
apetushkov@9858 | 68 | TRACE_REQUEST_FUNC(JVMInformation) { |
apetushkov@9858 | 69 | ResourceMark rm; |
apetushkov@9858 | 70 | EventJVMInformation event; |
apetushkov@9858 | 71 | event.set_jvmName(VM_Version::vm_name()); |
apetushkov@9858 | 72 | event.set_jvmVersion(VM_Version::internal_vm_info_string()); |
apetushkov@9858 | 73 | event.set_javaArguments(Arguments::java_command()); |
apetushkov@9858 | 74 | event.set_jvmArguments(Arguments::jvm_args()); |
apetushkov@9858 | 75 | event.set_jvmFlags(Arguments::jvm_flags()); |
apetushkov@9858 | 76 | event.set_jvmStartTime(Management::vm_init_done_time()); |
apetushkov@9858 | 77 | event.commit(); |
apetushkov@9858 | 78 | } |
apetushkov@9858 | 79 | |
apetushkov@9858 | 80 | TRACE_REQUEST_FUNC(OSInformation) { |
apetushkov@9858 | 81 | ResourceMark rm; |
apetushkov@9858 | 82 | char* os_name = NEW_RESOURCE_ARRAY(char, 2048); |
apetushkov@9858 | 83 | JfrOSInterface::os_version(&os_name); |
apetushkov@9858 | 84 | EventOSInformation event; |
apetushkov@9858 | 85 | event.set_osVersion(os_name); |
apetushkov@9858 | 86 | event.commit(); |
apetushkov@9858 | 87 | } |
apetushkov@9858 | 88 | |
apetushkov@9858 | 89 | /* |
apetushkov@9858 | 90 | * This is left empty on purpose, having ExecutionSample as a requestable |
apetushkov@9858 | 91 | * is a way of getting the period. The period is passed to ThreadSampling::update_period. |
apetushkov@9858 | 92 | * Implementation in jfrSamples.cpp |
apetushkov@9858 | 93 | */ |
apetushkov@9858 | 94 | TRACE_REQUEST_FUNC(ExecutionSample) { |
apetushkov@9858 | 95 | } |
apetushkov@9858 | 96 | TRACE_REQUEST_FUNC(NativeMethodSample) { |
apetushkov@9858 | 97 | } |
apetushkov@9858 | 98 | |
apetushkov@9858 | 99 | TRACE_REQUEST_FUNC(ThreadDump) { |
apetushkov@9858 | 100 | ResourceMark rm; |
apetushkov@9858 | 101 | EventThreadDump event; |
apetushkov@9858 | 102 | event.set_result(JfrDcmdEvent::thread_dump()); |
apetushkov@9858 | 103 | event.commit(); |
apetushkov@9858 | 104 | } |
apetushkov@9858 | 105 | |
apetushkov@9858 | 106 | static int _native_library_callback(const char* name, address base, address top, void *param) { |
apetushkov@9858 | 107 | EventNativeLibrary event(UNTIMED); |
apetushkov@9858 | 108 | event.set_name(name); |
apetushkov@9858 | 109 | event.set_baseAddress((u8)base); |
apetushkov@9858 | 110 | event.set_topAddress((u8)top); |
apetushkov@9858 | 111 | event.set_endtime(*(JfrTicks*) param); |
apetushkov@9858 | 112 | event.commit(); |
apetushkov@9858 | 113 | return 0; |
apetushkov@9858 | 114 | } |
apetushkov@9858 | 115 | |
apetushkov@9858 | 116 | TRACE_REQUEST_FUNC(NativeLibrary) { |
apetushkov@9858 | 117 | JfrTicks ts= JfrTicks::now(); |
apetushkov@9858 | 118 | os::get_loaded_modules_info(&_native_library_callback, (void *)&ts); |
apetushkov@9858 | 119 | } |
apetushkov@9858 | 120 | |
apetushkov@9858 | 121 | TRACE_REQUEST_FUNC(InitialEnvironmentVariable) { |
apetushkov@9858 | 122 | JfrOSInterface::generate_initial_environment_variable_events(); |
apetushkov@9858 | 123 | } |
apetushkov@9858 | 124 | |
apetushkov@9858 | 125 | TRACE_REQUEST_FUNC(CPUInformation) { |
apetushkov@9858 | 126 | CPUInformation cpu_info; |
apetushkov@9858 | 127 | int ret_val = JfrOSInterface::cpu_information(cpu_info); |
apetushkov@9858 | 128 | if (ret_val == OS_ERR) { |
apetushkov@9858 | 129 | if (LogJFR) tty->print_cr( "Unable to generate requestable event CPUInformation"); |
apetushkov@9858 | 130 | return; |
apetushkov@9858 | 131 | } |
apetushkov@9858 | 132 | if (ret_val == FUNCTIONALITY_NOT_IMPLEMENTED) { |
apetushkov@9858 | 133 | return; |
apetushkov@9858 | 134 | } |
apetushkov@9858 | 135 | if (ret_val == OS_OK) { |
apetushkov@9858 | 136 | EventCPUInformation event; |
apetushkov@9858 | 137 | event.set_cpu(cpu_info.cpu_name()); |
apetushkov@9858 | 138 | event.set_description(cpu_info.cpu_description()); |
apetushkov@9858 | 139 | event.set_sockets(cpu_info.number_of_sockets()); |
apetushkov@9858 | 140 | event.set_cores(cpu_info.number_of_cores()); |
apetushkov@9858 | 141 | event.set_hwThreads(cpu_info.number_of_hardware_threads()); |
apetushkov@9858 | 142 | event.commit(); |
apetushkov@9858 | 143 | } |
apetushkov@9858 | 144 | } |
apetushkov@9858 | 145 | |
apetushkov@9858 | 146 | TRACE_REQUEST_FUNC(CPULoad) { |
apetushkov@9858 | 147 | double u = 0; // user time |
apetushkov@9858 | 148 | double s = 0; // kernel time |
apetushkov@9858 | 149 | double t = 0; // total time |
apetushkov@9858 | 150 | int ret_val = JfrOSInterface::cpu_loads_process(&u, &s, &t); |
apetushkov@9858 | 151 | if (ret_val == OS_ERR) { |
apetushkov@9858 | 152 | if (LogJFR) tty->print_cr( "Unable to generate requestable event CPULoad"); |
apetushkov@9858 | 153 | return; |
apetushkov@9858 | 154 | } |
apetushkov@9858 | 155 | if (ret_val == OS_OK) { |
apetushkov@9858 | 156 | EventCPULoad event; |
apetushkov@9858 | 157 | event.set_jvmUser((float)u); |
apetushkov@9858 | 158 | event.set_jvmSystem((float)s); |
apetushkov@9858 | 159 | event.set_machineTotal((float)t); |
apetushkov@9858 | 160 | event.commit(); |
apetushkov@9858 | 161 | } |
apetushkov@9858 | 162 | } |
apetushkov@9858 | 163 | |
apetushkov@9858 | 164 | TRACE_REQUEST_FUNC(ThreadCPULoad) { |
apetushkov@9858 | 165 | JfrThreadCPULoadEvent::send_events(); |
apetushkov@9858 | 166 | } |
apetushkov@9858 | 167 | |
apetushkov@9858 | 168 | TRACE_REQUEST_FUNC(NetworkUtilization) { |
apetushkov@9858 | 169 | JfrNetworkUtilization::send_events(); |
apetushkov@9858 | 170 | } |
apetushkov@9858 | 171 | |
apetushkov@9858 | 172 | TRACE_REQUEST_FUNC(CPUTimeStampCounter) { |
apetushkov@9858 | 173 | EventCPUTimeStampCounter event; |
apetushkov@9858 | 174 | event.set_fastTimeEnabled(JfrTime::is_ft_enabled()); |
apetushkov@9858 | 175 | event.set_fastTimeAutoEnabled(JfrTime::is_ft_supported()); |
apetushkov@9858 | 176 | event.set_osFrequency(os::elapsed_frequency()); |
apetushkov@9858 | 177 | event.set_fastTimeFrequency(JfrTime::frequency()); |
apetushkov@9858 | 178 | event.commit(); |
apetushkov@9858 | 179 | } |
apetushkov@9858 | 180 | |
apetushkov@9858 | 181 | TRACE_REQUEST_FUNC(SystemProcess) { |
apetushkov@9858 | 182 | char pid_buf[16]; |
apetushkov@9858 | 183 | SystemProcess* processes = NULL; |
apetushkov@9858 | 184 | int num_of_processes = 0; |
apetushkov@9858 | 185 | JfrTicks start_time = JfrTicks::now(); |
apetushkov@9858 | 186 | int ret_val = JfrOSInterface::system_processes(&processes, &num_of_processes); |
apetushkov@9858 | 187 | if (ret_val == OS_ERR) { |
apetushkov@9858 | 188 | if (LogJFR) tty->print_cr( "Unable to generate requestable event SystemProcesses"); |
apetushkov@9858 | 189 | return; |
apetushkov@9858 | 190 | } |
apetushkov@9858 | 191 | JfrTicks end_time = JfrTicks::now(); |
apetushkov@9858 | 192 | if (ret_val == FUNCTIONALITY_NOT_IMPLEMENTED) { |
apetushkov@9858 | 193 | return; |
apetushkov@9858 | 194 | } |
apetushkov@9858 | 195 | if (ret_val == OS_OK) { |
apetushkov@9858 | 196 | // feature is implemented, write real event |
apetushkov@9858 | 197 | while (processes != NULL) { |
apetushkov@9858 | 198 | SystemProcess* tmp = processes; |
apetushkov@9858 | 199 | const char* info = processes->command_line(); |
apetushkov@9858 | 200 | if (info == NULL) { |
apetushkov@9858 | 201 | info = processes->path(); |
apetushkov@9858 | 202 | } |
apetushkov@9858 | 203 | if (info == NULL) { |
apetushkov@9858 | 204 | info = processes->name(); |
apetushkov@9858 | 205 | } |
apetushkov@9858 | 206 | if (info == NULL) { |
apetushkov@9858 | 207 | info = "?"; |
apetushkov@9858 | 208 | } |
apetushkov@9858 | 209 | jio_snprintf(pid_buf, sizeof(pid_buf), "%d", processes->pid()); |
apetushkov@9858 | 210 | EventSystemProcess event(UNTIMED); |
apetushkov@9858 | 211 | event.set_pid(pid_buf); |
apetushkov@9858 | 212 | event.set_commandLine(info); |
apetushkov@9858 | 213 | event.set_starttime(start_time); |
apetushkov@9858 | 214 | event.set_endtime(end_time); |
apetushkov@9858 | 215 | event.commit(); |
apetushkov@9858 | 216 | processes = processes->next(); |
apetushkov@9858 | 217 | delete tmp; |
apetushkov@9858 | 218 | } |
apetushkov@9858 | 219 | } |
apetushkov@9858 | 220 | } |
apetushkov@9858 | 221 | |
apetushkov@9858 | 222 | TRACE_REQUEST_FUNC(ThreadContextSwitchRate) { |
apetushkov@9858 | 223 | double rate = 0.0; |
apetushkov@9858 | 224 | int ret_val = JfrOSInterface::context_switch_rate(&rate); |
apetushkov@9858 | 225 | if (ret_val == OS_ERR) { |
apetushkov@9858 | 226 | if (LogJFR) tty->print_cr( "Unable to generate requestable event ThreadContextSwitchRate"); |
apetushkov@9858 | 227 | return; |
apetushkov@9858 | 228 | } |
apetushkov@9858 | 229 | if (ret_val == FUNCTIONALITY_NOT_IMPLEMENTED) { |
apetushkov@9858 | 230 | return; |
apetushkov@9858 | 231 | } |
apetushkov@9858 | 232 | if (ret_val == OS_OK) { |
apetushkov@9858 | 233 | EventThreadContextSwitchRate event; |
apetushkov@9858 | 234 | event.set_switchRate((float)rate + 0.0f); |
apetushkov@9858 | 235 | event.commit(); |
apetushkov@9858 | 236 | } |
apetushkov@9858 | 237 | } |
apetushkov@9858 | 238 | |
apetushkov@9858 | 239 | #define SEND_FLAGS_OF_TYPE(eventType, flagType) \ |
apetushkov@9858 | 240 | do { \ |
apetushkov@9858 | 241 | Flag *flag = Flag::flags; \ |
apetushkov@9858 | 242 | while (flag->_name != NULL) { \ |
apetushkov@9858 | 243 | if (flag->is_ ## flagType()) { \ |
apetushkov@9858 | 244 | if (flag->is_unlocked()) { \ |
apetushkov@9858 | 245 | Event ## eventType event; \ |
apetushkov@9858 | 246 | event.set_name(flag->_name); \ |
apetushkov@9858 | 247 | event.set_value(flag->get_ ## flagType()); \ |
apetushkov@9858 | 248 | event.set_origin(flag->get_origin()); \ |
apetushkov@9858 | 249 | event.commit(); \ |
apetushkov@9858 | 250 | } \ |
apetushkov@9858 | 251 | } \ |
apetushkov@9858 | 252 | ++flag; \ |
apetushkov@9858 | 253 | } \ |
apetushkov@9858 | 254 | } while (0) |
apetushkov@9858 | 255 | |
apetushkov@9858 | 256 | TRACE_REQUEST_FUNC(IntFlag) { |
apetushkov@9858 | 257 | SEND_FLAGS_OF_TYPE(IntFlag, intx); |
apetushkov@9858 | 258 | } |
apetushkov@9858 | 259 | |
apetushkov@9858 | 260 | TRACE_REQUEST_FUNC(UnsignedIntFlag) { |
apetushkov@9858 | 261 | SEND_FLAGS_OF_TYPE(UnsignedIntFlag, uintx); |
apetushkov@9858 | 262 | } |
apetushkov@9858 | 263 | |
apetushkov@9858 | 264 | TRACE_REQUEST_FUNC(LongFlag) { |
apetushkov@9858 | 265 | SEND_FLAGS_OF_TYPE(LongFlag, intx); |
apetushkov@9858 | 266 | } |
apetushkov@9858 | 267 | |
apetushkov@9858 | 268 | TRACE_REQUEST_FUNC(UnsignedLongFlag) { |
apetushkov@9858 | 269 | SEND_FLAGS_OF_TYPE(UnsignedLongFlag, uintx); |
apetushkov@9858 | 270 | SEND_FLAGS_OF_TYPE(UnsignedLongFlag, uint64_t); |
apetushkov@9858 | 271 | } |
apetushkov@9858 | 272 | |
apetushkov@9858 | 273 | TRACE_REQUEST_FUNC(DoubleFlag) { |
apetushkov@9858 | 274 | SEND_FLAGS_OF_TYPE(DoubleFlag, double); |
apetushkov@9858 | 275 | } |
apetushkov@9858 | 276 | |
apetushkov@9858 | 277 | TRACE_REQUEST_FUNC(BooleanFlag) { |
apetushkov@9858 | 278 | SEND_FLAGS_OF_TYPE(BooleanFlag, bool); |
apetushkov@9858 | 279 | } |
apetushkov@9858 | 280 | |
apetushkov@9858 | 281 | TRACE_REQUEST_FUNC(StringFlag) { |
apetushkov@9858 | 282 | SEND_FLAGS_OF_TYPE(StringFlag, ccstr); |
apetushkov@9858 | 283 | } |
apetushkov@9858 | 284 | |
apetushkov@9858 | 285 | class VM_GC_SendObjectCountEvent : public VM_GC_HeapInspection { |
apetushkov@9858 | 286 | public: |
apetushkov@9858 | 287 | VM_GC_SendObjectCountEvent() : VM_GC_HeapInspection(NULL, true) {} |
apetushkov@9858 | 288 | virtual void doit() { |
apetushkov@9858 | 289 | ObjectCountEventSender::enable_requestable_event(); |
apetushkov@9858 | 290 | collect(); |
apetushkov@9858 | 291 | ObjectCountEventSender::disable_requestable_event(); |
apetushkov@9858 | 292 | } |
apetushkov@9858 | 293 | }; |
apetushkov@9858 | 294 | |
apetushkov@9858 | 295 | TRACE_REQUEST_FUNC(ObjectCount) { |
apetushkov@9858 | 296 | VM_GC_SendObjectCountEvent op; |
apetushkov@9858 | 297 | VMThread::execute(&op); |
apetushkov@9858 | 298 | } |
apetushkov@9858 | 299 | |
apetushkov@9858 | 300 | class VM_G1SendHeapRegionInfoEvents : public VM_Operation { |
apetushkov@9858 | 301 | virtual void doit() { |
apetushkov@9858 | 302 | G1HeapRegionEventSender::send_events(); |
apetushkov@9858 | 303 | } |
apetushkov@9858 | 304 | virtual VMOp_Type type() const { return VMOp_HeapIterateOperation; } |
apetushkov@9858 | 305 | }; |
apetushkov@9858 | 306 | |
apetushkov@9858 | 307 | TRACE_REQUEST_FUNC(G1HeapRegionInformation) { |
apetushkov@9858 | 308 | if (UseG1GC) { |
apetushkov@9858 | 309 | VM_G1SendHeapRegionInfoEvents op; |
apetushkov@9858 | 310 | VMThread::execute(&op); |
apetushkov@9858 | 311 | } |
apetushkov@9858 | 312 | } |
apetushkov@9858 | 313 | |
apetushkov@9858 | 314 | // Java Mission Control (JMC) uses (Java) Long.MIN_VALUE to describe that a |
apetushkov@9858 | 315 | // long value is undefined. |
apetushkov@9858 | 316 | static jlong jmc_undefined_long = min_jlong; |
apetushkov@9858 | 317 | |
apetushkov@9858 | 318 | TRACE_REQUEST_FUNC(GCConfiguration) { |
apetushkov@9858 | 319 | GCConfiguration conf; |
apetushkov@9858 | 320 | jlong pause_target = conf.has_pause_target_default_value() ? jmc_undefined_long : conf.pause_target(); |
apetushkov@9858 | 321 | EventGCConfiguration event; |
apetushkov@9858 | 322 | event.set_youngCollector(conf.young_collector()); |
apetushkov@9858 | 323 | event.set_oldCollector(conf.old_collector()); |
apetushkov@9858 | 324 | event.set_parallelGCThreads(conf.num_parallel_gc_threads()); |
apetushkov@9858 | 325 | event.set_concurrentGCThreads(conf.num_concurrent_gc_threads()); |
apetushkov@9858 | 326 | event.set_usesDynamicGCThreads(conf.uses_dynamic_gc_threads()); |
apetushkov@9858 | 327 | event.set_isExplicitGCConcurrent(conf.is_explicit_gc_concurrent()); |
apetushkov@9858 | 328 | event.set_isExplicitGCDisabled(conf.is_explicit_gc_disabled()); |
apetushkov@9858 | 329 | event.set_gcTimeRatio(conf.gc_time_ratio()); |
apetushkov@9858 | 330 | event.set_pauseTarget((s8)pause_target); |
apetushkov@9858 | 331 | event.commit(); |
apetushkov@9858 | 332 | } |
apetushkov@9858 | 333 | |
apetushkov@9858 | 334 | TRACE_REQUEST_FUNC(GCTLABConfiguration) { |
apetushkov@9858 | 335 | GCTLABConfiguration conf; |
apetushkov@9858 | 336 | EventGCTLABConfiguration event; |
apetushkov@9858 | 337 | event.set_usesTLABs(conf.uses_tlabs()); |
apetushkov@9858 | 338 | event.set_minTLABSize(conf.min_tlab_size()); |
apetushkov@9858 | 339 | event.set_tlabRefillWasteLimit(conf.tlab_refill_waste_limit()); |
apetushkov@9858 | 340 | event.commit(); |
apetushkov@9858 | 341 | } |
apetushkov@9858 | 342 | |
apetushkov@9858 | 343 | TRACE_REQUEST_FUNC(GCSurvivorConfiguration) { |
apetushkov@9858 | 344 | GCSurvivorConfiguration conf; |
apetushkov@9858 | 345 | EventGCSurvivorConfiguration event; |
apetushkov@9858 | 346 | event.set_maxTenuringThreshold(conf.max_tenuring_threshold()); |
apetushkov@9858 | 347 | event.set_initialTenuringThreshold(conf.initial_tenuring_threshold()); |
apetushkov@9858 | 348 | event.commit(); |
apetushkov@9858 | 349 | } |
apetushkov@9858 | 350 | |
apetushkov@9858 | 351 | TRACE_REQUEST_FUNC(GCHeapConfiguration) { |
apetushkov@9858 | 352 | GCHeapConfiguration conf; |
apetushkov@9858 | 353 | EventGCHeapConfiguration event; |
apetushkov@9858 | 354 | event.set_minSize(conf.min_size()); |
apetushkov@9858 | 355 | event.set_maxSize(conf.max_size()); |
apetushkov@9858 | 356 | event.set_initialSize(conf.initial_size()); |
apetushkov@9858 | 357 | event.set_usesCompressedOops(conf.uses_compressed_oops()); |
apetushkov@9858 | 358 | event.set_compressedOopsMode(conf.narrow_oop_mode()); |
apetushkov@9858 | 359 | event.set_objectAlignment(conf.object_alignment_in_bytes()); |
apetushkov@9858 | 360 | event.set_heapAddressBits(conf.heap_address_size_in_bits()); |
apetushkov@9858 | 361 | event.commit(); |
apetushkov@9858 | 362 | } |
apetushkov@9858 | 363 | |
apetushkov@9858 | 364 | TRACE_REQUEST_FUNC(YoungGenerationConfiguration) { |
apetushkov@9858 | 365 | GCYoungGenerationConfiguration conf; |
apetushkov@9858 | 366 | jlong max_size = conf.has_max_size_default_value() ? jmc_undefined_long : conf.max_size(); |
apetushkov@9858 | 367 | EventYoungGenerationConfiguration event; |
apetushkov@9858 | 368 | event.set_maxSize((u8)max_size); |
apetushkov@9858 | 369 | event.set_minSize(conf.min_size()); |
apetushkov@9858 | 370 | event.set_newRatio(conf.new_ratio()); |
apetushkov@9858 | 371 | event.commit(); |
apetushkov@9858 | 372 | } |
apetushkov@9858 | 373 | |
apetushkov@9858 | 374 | TRACE_REQUEST_FUNC(InitialSystemProperty) { |
apetushkov@9858 | 375 | SystemProperty* p = Arguments::system_properties(); |
apetushkov@9858 | 376 | JfrTicks time_stamp = JfrTicks::now(); |
apetushkov@9858 | 377 | while (p != NULL) { |
apetushkov@9858 | 378 | if (true/* XXX fix me if you want !p->internal()*/) { |
apetushkov@9858 | 379 | EventInitialSystemProperty event(UNTIMED); |
apetushkov@9858 | 380 | event.set_key(p->key()); |
apetushkov@9858 | 381 | event.set_value(p->value()); |
apetushkov@9858 | 382 | event.set_endtime(time_stamp); |
apetushkov@9858 | 383 | event.commit(); |
apetushkov@9858 | 384 | } |
apetushkov@9858 | 385 | p = p->next(); |
apetushkov@9858 | 386 | } |
apetushkov@9858 | 387 | } |
apetushkov@9858 | 388 | |
apetushkov@9858 | 389 | TRACE_REQUEST_FUNC(ThreadAllocationStatistics) { |
apetushkov@9858 | 390 | ResourceMark rm; |
apetushkov@9858 | 391 | int initial_size = Threads::number_of_threads(); |
apetushkov@9858 | 392 | GrowableArray<jlong> allocated(initial_size); |
apetushkov@9858 | 393 | GrowableArray<traceid> thread_ids(initial_size); |
apetushkov@9858 | 394 | JfrTicks time_stamp = JfrTicks::now(); |
apetushkov@9858 | 395 | { |
apetushkov@9858 | 396 | // Collect allocation statistics while holding threads lock |
apetushkov@9858 | 397 | MutexLockerEx ml(Threads_lock); |
apetushkov@9858 | 398 | for (JavaThread *thread = Threads::first(); thread != NULL; thread = thread->next()) { |
apetushkov@9858 | 399 | allocated.append(thread->cooked_allocated_bytes()); |
apetushkov@9858 | 400 | thread_ids.append(JFR_THREAD_ID(thread)); |
apetushkov@9858 | 401 | } |
apetushkov@9858 | 402 | } |
apetushkov@9858 | 403 | |
apetushkov@9858 | 404 | // Write allocation statistics to buffer. |
apetushkov@9858 | 405 | for(int i = 0; i < thread_ids.length(); i++) { |
apetushkov@9858 | 406 | EventThreadAllocationStatistics event(UNTIMED); |
apetushkov@9858 | 407 | event.set_allocated(allocated.at(i)); |
apetushkov@9858 | 408 | event.set_thread(thread_ids.at(i)); |
apetushkov@9858 | 409 | event.set_endtime(time_stamp); |
apetushkov@9858 | 410 | event.commit(); |
apetushkov@9858 | 411 | } |
apetushkov@9858 | 412 | } |
apetushkov@9858 | 413 | |
apetushkov@9858 | 414 | /** |
apetushkov@9858 | 415 | * PhysicalMemory event represents: |
apetushkov@9858 | 416 | * |
apetushkov@9858 | 417 | * @totalSize == The amount of physical memory (hw) installed and reported by the OS, in bytes. |
apetushkov@9858 | 418 | * @usedSize == The amount of physical memory currently in use in the system (reserved/committed), in bytes. |
apetushkov@9858 | 419 | * |
apetushkov@9858 | 420 | * Both fields are systemwide, i.e. represents the entire OS/HW environment. |
apetushkov@9858 | 421 | * These fields do not include virtual memory. |
apetushkov@9858 | 422 | * |
apetushkov@9858 | 423 | * If running inside a guest OS on top of a hypervisor in a virtualized environment, |
apetushkov@9858 | 424 | * the total memory reported is the amount of memory configured for the guest OS by the hypervisor. |
apetushkov@9858 | 425 | */ |
apetushkov@9858 | 426 | TRACE_REQUEST_FUNC(PhysicalMemory) { |
apetushkov@9858 | 427 | u8 totalPhysicalMemory = os::physical_memory(); |
apetushkov@9858 | 428 | EventPhysicalMemory event; |
apetushkov@9858 | 429 | event.set_totalSize(totalPhysicalMemory); |
apetushkov@9858 | 430 | event.set_usedSize(totalPhysicalMemory - os::available_memory()); |
apetushkov@9858 | 431 | event.commit(); |
apetushkov@9858 | 432 | } |
apetushkov@9858 | 433 | |
apetushkov@9858 | 434 | TRACE_REQUEST_FUNC(JavaThreadStatistics) { |
apetushkov@9858 | 435 | EventJavaThreadStatistics event; |
apetushkov@9858 | 436 | event.set_activeCount(ThreadService::get_live_thread_count()); |
apetushkov@9858 | 437 | event.set_daemonCount(ThreadService::get_daemon_thread_count()); |
apetushkov@9858 | 438 | event.set_accumulatedCount(ThreadService::get_total_thread_count()); |
apetushkov@9858 | 439 | event.set_peakCount(ThreadService::get_peak_thread_count()); |
apetushkov@9858 | 440 | event.commit(); |
apetushkov@9858 | 441 | } |
apetushkov@9858 | 442 | |
apetushkov@9858 | 443 | TRACE_REQUEST_FUNC(ClassLoadingStatistics) { |
apetushkov@9858 | 444 | EventClassLoadingStatistics event; |
apetushkov@9858 | 445 | event.set_loadedClassCount(ClassLoadingService::loaded_class_count()); |
apetushkov@9858 | 446 | event.set_unloadedClassCount(ClassLoadingService::unloaded_class_count()); |
apetushkov@9858 | 447 | event.commit(); |
apetushkov@9858 | 448 | } |
apetushkov@9858 | 449 | |
apetushkov@9858 | 450 | class JfrClassLoaderStatsClosure : public ClassLoaderStatsClosure { |
apetushkov@9858 | 451 | public: |
apetushkov@9858 | 452 | JfrClassLoaderStatsClosure() : ClassLoaderStatsClosure(NULL) {} |
apetushkov@9858 | 453 | |
apetushkov@9858 | 454 | bool do_entry(oop const& key, ClassLoaderStats* const& cls) { |
apetushkov@9858 | 455 | const ClassLoaderData* this_cld = cls->_class_loader != NULL ? |
apetushkov@9858 | 456 | java_lang_ClassLoader::loader_data(cls->_class_loader) : (ClassLoaderData*)NULL; |
apetushkov@9858 | 457 | const ClassLoaderData* parent_cld = cls->_parent != NULL ? |
apetushkov@9858 | 458 | java_lang_ClassLoader::loader_data(cls->_parent) : (ClassLoaderData*)NULL; |
apetushkov@9858 | 459 | EventClassLoaderStatistics event; |
apetushkov@9858 | 460 | event.set_classLoader(this_cld); |
apetushkov@9858 | 461 | event.set_parentClassLoader(parent_cld); |
apetushkov@9858 | 462 | event.set_classLoaderData((intptr_t)cls->_cld); |
apetushkov@9858 | 463 | event.set_classCount(cls->_classes_count); |
apetushkov@9858 | 464 | event.set_chunkSize(cls->_chunk_sz); |
apetushkov@9858 | 465 | event.set_blockSize(cls->_block_sz); |
apetushkov@9858 | 466 | event.set_anonymousClassCount(cls->_anon_classes_count); |
apetushkov@9858 | 467 | event.set_anonymousChunkSize(cls->_anon_chunk_sz); |
apetushkov@9858 | 468 | event.set_anonymousBlockSize(cls->_anon_block_sz); |
apetushkov@9858 | 469 | event.commit(); |
apetushkov@9858 | 470 | return true; |
apetushkov@9858 | 471 | } |
apetushkov@9858 | 472 | |
apetushkov@9858 | 473 | void createEvents(void) { |
apetushkov@9858 | 474 | _stats->iterate(this); |
apetushkov@9858 | 475 | } |
apetushkov@9858 | 476 | }; |
apetushkov@9858 | 477 | |
apetushkov@9858 | 478 | class JfrClassLoaderStatsVMOperation : public ClassLoaderStatsVMOperation { |
apetushkov@9858 | 479 | public: |
apetushkov@9858 | 480 | JfrClassLoaderStatsVMOperation() : ClassLoaderStatsVMOperation(NULL) { } |
apetushkov@9858 | 481 | |
apetushkov@9858 | 482 | void doit() { |
apetushkov@9858 | 483 | JfrClassLoaderStatsClosure clsc; |
apetushkov@9858 | 484 | ClassLoaderDataGraph::cld_do(&clsc); |
apetushkov@9858 | 485 | clsc.createEvents(); |
apetushkov@9858 | 486 | } |
apetushkov@9858 | 487 | }; |
apetushkov@9858 | 488 | |
apetushkov@9858 | 489 | TRACE_REQUEST_FUNC(ClassLoaderStatistics) { |
apetushkov@9858 | 490 | JfrClassLoaderStatsVMOperation op; |
apetushkov@9858 | 491 | VMThread::execute(&op); |
apetushkov@9858 | 492 | } |
apetushkov@9858 | 493 | |
apetushkov@9858 | 494 | TRACE_REQUEST_FUNC(CompilerStatistics) { |
apetushkov@9858 | 495 | EventCompilerStatistics event; |
apetushkov@9858 | 496 | event.set_compileCount(CompileBroker::get_total_compile_count()); |
apetushkov@9858 | 497 | event.set_bailoutCount(CompileBroker::get_total_bailout_count()); |
apetushkov@9858 | 498 | event.set_invalidatedCount(CompileBroker::get_total_invalidated_count()); |
apetushkov@9858 | 499 | event.set_osrCompileCount(CompileBroker::get_total_osr_compile_count()); |
apetushkov@9858 | 500 | event.set_standardCompileCount(CompileBroker::get_total_standard_compile_count()); |
apetushkov@9858 | 501 | event.set_osrBytesCompiled(CompileBroker::get_sum_osr_bytes_compiled()); |
apetushkov@9858 | 502 | event.set_standardBytesCompiled(CompileBroker::get_sum_standard_bytes_compiled()); |
apetushkov@9858 | 503 | event.set_nmetodsSize(CompileBroker::get_sum_nmethod_size()); |
apetushkov@9858 | 504 | event.set_nmetodCodeSize(CompileBroker::get_sum_nmethod_code_size()); |
apetushkov@9858 | 505 | event.set_peakTimeSpent(CompileBroker::get_peak_compilation_time()); |
apetushkov@9858 | 506 | event.set_totalTimeSpent(CompileBroker::get_total_compilation_time()); |
apetushkov@9858 | 507 | event.commit(); |
apetushkov@9858 | 508 | } |
apetushkov@9858 | 509 | |
apetushkov@9858 | 510 | TRACE_REQUEST_FUNC(CompilerConfiguration) { |
apetushkov@9858 | 511 | EventCompilerConfiguration event; |
apetushkov@9858 | 512 | event.set_threadCount(CICompilerCount); |
apetushkov@9858 | 513 | event.set_tieredCompilation(TieredCompilation); |
apetushkov@9858 | 514 | event.commit(); |
apetushkov@9858 | 515 | } |
apetushkov@9858 | 516 | |
apetushkov@9858 | 517 | TRACE_REQUEST_FUNC(CodeCacheStatistics) { |
apetushkov@9858 | 518 | EventCodeCacheStatistics event; |
apetushkov@9858 | 519 | event.set_codeBlobType((u1)0/*bt*/); // XXX |
apetushkov@9858 | 520 | event.set_startAddress((u8)CodeCache::low_bound()); |
apetushkov@9858 | 521 | event.set_reservedTopAddress((u8)CodeCache::high_bound()); |
apetushkov@9858 | 522 | event.set_entryCount(CodeCache::nof_blobs()); |
apetushkov@9858 | 523 | event.set_methodCount(CodeCache::nof_nmethods()); |
apetushkov@9858 | 524 | event.set_adaptorCount(CodeCache::nof_adapters()); |
apetushkov@9858 | 525 | event.set_unallocatedCapacity(CodeCache::unallocated_capacity()); |
apetushkov@9858 | 526 | event.set_fullCount(CodeCache::get_codemem_full_count()); |
apetushkov@9858 | 527 | event.commit(); |
apetushkov@9858 | 528 | } |
apetushkov@9858 | 529 | |
apetushkov@9858 | 530 | TRACE_REQUEST_FUNC(CodeCacheConfiguration) { |
apetushkov@9858 | 531 | EventCodeCacheConfiguration event; |
apetushkov@9858 | 532 | event.set_initialSize(InitialCodeCacheSize); |
apetushkov@9858 | 533 | event.set_reservedSize(ReservedCodeCacheSize); |
apetushkov@9858 | 534 | event.set_nonNMethodSize(0/*NonNMethodCodeHeapSize*/); // XXX |
apetushkov@9858 | 535 | event.set_profiledSize(0/*ProfiledCodeHeapSize*/); // XXX |
apetushkov@9858 | 536 | event.set_nonProfiledSize(0/*NonProfiledCodeHeapSize*/); // XXX |
apetushkov@9858 | 537 | event.set_expansionSize(CodeCacheExpansionSize); |
apetushkov@9858 | 538 | event.set_minBlockLength(CodeCacheMinBlockLength); |
apetushkov@9858 | 539 | event.set_startAddress((u8)CodeCache::low_bound()); |
apetushkov@9858 | 540 | event.set_reservedTopAddress((u8)CodeCache::high_bound()); |
apetushkov@9858 | 541 | event.commit(); |
apetushkov@9858 | 542 | } |
apetushkov@9858 | 543 | |
apetushkov@9858 | 544 | TRACE_REQUEST_FUNC(CodeSweeperStatistics) { |
apetushkov@9858 | 545 | EventCodeSweeperStatistics event; |
apetushkov@9858 | 546 | event.set_sweepCount(NMethodSweeper::traversal_count()); |
apetushkov@9858 | 547 | event.set_methodReclaimedCount(NMethodSweeper::total_nof_methods_reclaimed()); |
apetushkov@9858 | 548 | event.set_totalSweepTime(NMethodSweeper::total_time_sweeping()); |
apetushkov@9858 | 549 | event.set_peakFractionTime(NMethodSweeper::peak_sweep_fraction_time()); |
apetushkov@9858 | 550 | event.set_peakSweepTime(NMethodSweeper::peak_sweep_time()); |
apetushkov@9858 | 551 | event.commit(); |
apetushkov@9858 | 552 | } |
apetushkov@9858 | 553 | |
apetushkov@9858 | 554 | TRACE_REQUEST_FUNC(CodeSweeperConfiguration) { |
apetushkov@9858 | 555 | EventCodeSweeperConfiguration event; |
apetushkov@9858 | 556 | event.set_sweeperEnabled(MethodFlushing); |
apetushkov@9858 | 557 | event.set_flushingEnabled(UseCodeCacheFlushing); |
apetushkov@9858 | 558 | event.commit(); |
apetushkov@9858 | 559 | } |