< prev index next >
src/hotspot/share/jfr/periodic/jfrPeriodic.cpp
Print this page
rev 53271 : 8216981: Per thread IO statistics in JFR
@@ -424,10 +424,110 @@
event.set_endtime(time_stamp);
event.commit();
}
}
+TRACE_REQUEST_FUNC(ThreadFileWriteStatistics) {
+ ResourceMark rm;
+ int initial_size = Threads::number_of_threads();
+ GrowableArray<jlong> written(initial_size);
+ GrowableArray<traceid> thread_ids(initial_size);
+ JfrTicks time_stamp = JfrTicks::now();
+ {
+ // Collect file write statistics while holding threads lock
+ MutexLockerEx ml(Threads_lock);
+ for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
+ written.append(jt->statistical_info().getBytesWrittenToFile());
+ thread_ids.append(JFR_THREAD_ID(jt));
+ }
+ }
+
+ // Write file write statistics to buffer.
+ for(int i = 0; i < thread_ids.length(); i++) {
+ EventThreadFileWriteStatistics event(UNTIMED);
+ event.set_written(written.at(i));
+ event.set_thread(thread_ids.at(i));
+ event.set_endtime(time_stamp);
+ event.commit();
+ }
+}
+
+TRACE_REQUEST_FUNC(ThreadFileReadStatistics) {
+ ResourceMark rm;
+ int initial_size = Threads::number_of_threads();
+ GrowableArray<jlong> read(initial_size);
+ GrowableArray<traceid> thread_ids(initial_size);
+ JfrTicks time_stamp = JfrTicks::now();
+ {
+ // Collect file read statistics while holding threads lock
+ MutexLockerEx ml(Threads_lock);
+ for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
+ read.append(jt->statistical_info().getBytesReadFromFile());
+ thread_ids.append(JFR_THREAD_ID(jt));
+ }
+ }
+
+ // Write file read statistics to buffer.
+ for(int i = 0; i < thread_ids.length(); i++) {
+ EventThreadFileReadStatistics event(UNTIMED);
+ event.set_read(read.at(i));
+ event.set_thread(thread_ids.at(i));
+ event.set_endtime(time_stamp);
+ event.commit();
+ }
+}
+
+TRACE_REQUEST_FUNC(ThreadNetworkWriteStatistics) {
+ ResourceMark rm;
+ int initial_size = Threads::number_of_threads();
+ GrowableArray<jlong> written(initial_size);
+ GrowableArray<traceid> thread_ids(initial_size);
+ JfrTicks time_stamp = JfrTicks::now();
+ {
+ // Collect file write statistics while holding threads lock
+ MutexLockerEx ml(Threads_lock);
+ for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
+ written.append(jt->statistical_info().getBytesWrittenToNetwork());
+ thread_ids.append(JFR_THREAD_ID(jt));
+ }
+ }
+
+ // Write file write statistics to buffer.
+ for(int i = 0; i < thread_ids.length(); i++) {
+ EventThreadNetworkWriteStatistics event(UNTIMED);
+ event.set_written(written.at(i));
+ event.set_thread(thread_ids.at(i));
+ event.set_endtime(time_stamp);
+ event.commit();
+ }
+}
+
+TRACE_REQUEST_FUNC(ThreadNetworkReadStatistics) {
+ ResourceMark rm;
+ int initial_size = Threads::number_of_threads();
+ GrowableArray<jlong> read(initial_size);
+ GrowableArray<traceid> thread_ids(initial_size);
+ JfrTicks time_stamp = JfrTicks::now();
+ {
+ // Collect file read statistics while holding threads lock
+ MutexLockerEx ml(Threads_lock);
+ for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
+ read.append(jt->statistical_info().getBytesReadFromNetwork());
+ thread_ids.append(JFR_THREAD_ID(jt));
+ }
+ }
+
+ // Write file read statistics to buffer.
+ for(int i = 0; i < thread_ids.length(); i++) {
+ EventThreadNetworkReadStatistics event(UNTIMED);
+ event.set_read(read.at(i));
+ event.set_thread(thread_ids.at(i));
+ 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.
< prev index next >