< prev index next >

src/hotspot/share/jfr/periodic/jfrPeriodic.cpp

Print this page
rev 53271 : 8216981: Per thread IO statistics in JFR


 409   JfrTicks time_stamp = JfrTicks::now();
 410   {
 411     // Collect allocation statistics while holding threads lock
 412     MutexLockerEx ml(Threads_lock);
 413     for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
 414       allocated.append(jt->cooked_allocated_bytes());
 415       thread_ids.append(JFR_THREAD_ID(jt));
 416     }
 417   }
 418 
 419   // Write allocation statistics to buffer.
 420   for(int i = 0; i < thread_ids.length(); i++) {
 421     EventThreadAllocationStatistics event(UNTIMED);
 422     event.set_allocated(allocated.at(i));
 423     event.set_thread(thread_ids.at(i));
 424     event.set_endtime(time_stamp);
 425     event.commit();
 426   }
 427 }
 428 




































































































 429 /**
 430  *  PhysicalMemory event represents:
 431  *
 432  *  @totalSize == The amount of physical memory (hw) installed and reported by the OS, in bytes.
 433  *  @usedSize  == The amount of physical memory currently in use in the system (reserved/committed), in bytes.
 434  *
 435  *  Both fields are systemwide, i.e. represents the entire OS/HW environment.
 436  *  These fields do not include virtual memory.
 437  *
 438  *  If running inside a guest OS on top of a hypervisor in a virtualized environment,
 439  *  the total memory reported is the amount of memory configured for the guest OS by the hypervisor.
 440  */
 441 TRACE_REQUEST_FUNC(PhysicalMemory) {
 442   u8 totalPhysicalMemory = os::physical_memory();
 443   EventPhysicalMemory event;
 444   event.set_totalSize(totalPhysicalMemory);
 445   event.set_usedSize(totalPhysicalMemory - os::available_memory());
 446   event.commit();
 447 }
 448 




 409   JfrTicks time_stamp = JfrTicks::now();
 410   {
 411     // Collect allocation statistics while holding threads lock
 412     MutexLockerEx ml(Threads_lock);
 413     for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
 414       allocated.append(jt->cooked_allocated_bytes());
 415       thread_ids.append(JFR_THREAD_ID(jt));
 416     }
 417   }
 418 
 419   // Write allocation statistics to buffer.
 420   for(int i = 0; i < thread_ids.length(); i++) {
 421     EventThreadAllocationStatistics event(UNTIMED);
 422     event.set_allocated(allocated.at(i));
 423     event.set_thread(thread_ids.at(i));
 424     event.set_endtime(time_stamp);
 425     event.commit();
 426   }
 427 }
 428 
 429 TRACE_REQUEST_FUNC(ThreadFileWriteStatistics) {
 430   ResourceMark rm;
 431   int initial_size = Threads::number_of_threads();
 432   GrowableArray<jlong> written(initial_size);
 433   GrowableArray<traceid> thread_ids(initial_size);
 434   JfrTicks time_stamp = JfrTicks::now();
 435   {
 436     // Collect file write statistics while holding threads lock
 437     MutexLockerEx ml(Threads_lock);
 438     for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
 439       written.append(jt->statistical_info().getBytesWrittenToFile());
 440       thread_ids.append(JFR_THREAD_ID(jt));
 441     }
 442   }
 443 
 444   // Write file write statistics to buffer.
 445   for(int i = 0; i < thread_ids.length(); i++) {
 446     EventThreadFileWriteStatistics event(UNTIMED);
 447     event.set_written(written.at(i));
 448     event.set_thread(thread_ids.at(i));
 449     event.set_endtime(time_stamp);
 450     event.commit();
 451   }
 452 }
 453 
 454 TRACE_REQUEST_FUNC(ThreadFileReadStatistics) {
 455   ResourceMark rm;
 456   int initial_size = Threads::number_of_threads();
 457   GrowableArray<jlong> read(initial_size);
 458   GrowableArray<traceid> thread_ids(initial_size);
 459   JfrTicks time_stamp = JfrTicks::now();
 460   {
 461     // Collect file read statistics while holding threads lock
 462     MutexLockerEx ml(Threads_lock);
 463     for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
 464       read.append(jt->statistical_info().getBytesReadFromFile());
 465       thread_ids.append(JFR_THREAD_ID(jt));
 466     }
 467   }
 468 
 469   // Write file read statistics to buffer.
 470   for(int i = 0; i < thread_ids.length(); i++) {
 471     EventThreadFileReadStatistics event(UNTIMED);
 472     event.set_read(read.at(i));
 473     event.set_thread(thread_ids.at(i));
 474     event.set_endtime(time_stamp);
 475     event.commit();
 476   }
 477 }
 478 
 479 TRACE_REQUEST_FUNC(ThreadNetworkWriteStatistics) {
 480   ResourceMark rm;
 481   int initial_size = Threads::number_of_threads();
 482   GrowableArray<jlong> written(initial_size);
 483   GrowableArray<traceid> thread_ids(initial_size);
 484   JfrTicks time_stamp = JfrTicks::now();
 485   {
 486     // Collect file write statistics while holding threads lock
 487     MutexLockerEx ml(Threads_lock);
 488     for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
 489       written.append(jt->statistical_info().getBytesWrittenToNetwork());
 490       thread_ids.append(JFR_THREAD_ID(jt));
 491     }
 492   }
 493 
 494   // Write file write statistics to buffer.
 495   for(int i = 0; i < thread_ids.length(); i++) {
 496     EventThreadNetworkWriteStatistics event(UNTIMED);
 497     event.set_written(written.at(i));
 498     event.set_thread(thread_ids.at(i));
 499     event.set_endtime(time_stamp);
 500     event.commit();
 501   }
 502 }
 503 
 504 TRACE_REQUEST_FUNC(ThreadNetworkReadStatistics) {
 505   ResourceMark rm;
 506   int initial_size = Threads::number_of_threads();
 507   GrowableArray<jlong> read(initial_size);
 508   GrowableArray<traceid> thread_ids(initial_size);
 509   JfrTicks time_stamp = JfrTicks::now();
 510   {
 511     // Collect file read statistics while holding threads lock
 512     MutexLockerEx ml(Threads_lock);
 513     for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
 514       read.append(jt->statistical_info().getBytesReadFromNetwork());
 515       thread_ids.append(JFR_THREAD_ID(jt));
 516     }
 517   }
 518 
 519   // Write file read statistics to buffer.
 520   for(int i = 0; i < thread_ids.length(); i++) {
 521     EventThreadNetworkReadStatistics event(UNTIMED);
 522     event.set_read(read.at(i));
 523     event.set_thread(thread_ids.at(i));
 524     event.set_endtime(time_stamp);
 525     event.commit();
 526   }
 527 }
 528 
 529 /**
 530  *  PhysicalMemory event represents:
 531  *
 532  *  @totalSize == The amount of physical memory (hw) installed and reported by the OS, in bytes.
 533  *  @usedSize  == The amount of physical memory currently in use in the system (reserved/committed), in bytes.
 534  *
 535  *  Both fields are systemwide, i.e. represents the entire OS/HW environment.
 536  *  These fields do not include virtual memory.
 537  *
 538  *  If running inside a guest OS on top of a hypervisor in a virtualized environment,
 539  *  the total memory reported is the amount of memory configured for the guest OS by the hypervisor.
 540  */
 541 TRACE_REQUEST_FUNC(PhysicalMemory) {
 542   u8 totalPhysicalMemory = os::physical_memory();
 543   EventPhysicalMemory event;
 544   event.set_totalSize(totalPhysicalMemory);
 545   event.set_usedSize(totalPhysicalMemory - os::available_memory());
 546   event.commit();
 547 }
 548 


< prev index next >