JFR-1751674: Add new JFR Events: FileReadIOStatisticsEvent, FileWriteIOStatisticsEvent #24
Conversation
…eriodicFileIOInstrumentationEvents
…ntationEvents' of https://github.com/microsoft/openjdk-jdk11u into kthatipally/JFR-Internal-1751674-PeriodicFileIOInstrumentationEvents
src/jdk.jfr/share/classes/jdk/jfr/internal/instrument/FileChannelImplInstrumentor.java
Outdated
Show resolved
Hide resolved
src/jdk.jfr/share/classes/jdk/jfr/internal/instrument/FileChannelImplInstrumentor.java
Outdated
Show resolved
Hide resolved
src/jdk.jfr/share/classes/jdk/jfr/internal/instrument/FileChannelImplInstrumentor.java
Outdated
Show resolved
Hide resolved
src/jdk.jfr/share/classes/jdk/jfr/internal/instrument/FileChannelImplInstrumentor.java
Outdated
Show resolved
Hide resolved
src/jdk.jfr/share/classes/jdk/jfr/internal/instrument/FileChannelImplInstrumentor.java
Outdated
Show resolved
Hide resolved
| "Hello", | ||
| "GetFlightRecorder", | ||
| "GetFlightRecorder$TestEvent", | ||
| "jdk/jfr/events/FileReadIOStatisticsEvent", |
There was a problem hiding this comment.
NIT: can you move these "jdk/jfr/..." tests closer to the ones above?
There was a problem hiding this comment.
I moved the tests closer to the other fileEvent tests. Thanks for the suggestion.
| import static jdk.test.lib.Asserts.assertGreaterThanOrEqual; | ||
|
|
||
| /** | ||
| * @test |
There was a problem hiding this comment.
You may need to add the JBS work item ID here.
| </control> | ||
|
|
||
| </configuration> | ||
| </configuration> No newline at end of file |
| @@ -0,0 +1,95 @@ | |||
| /* | |||
| * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. | |||
There was a problem hiding this comment.
People may ask you to adjust the year in the files' header.
There was a problem hiding this comment.
Updated year to 2023. Thanks for catching that.
src/jdk.jfr/share/classes/jdk/jfr/events/FileReadIOStatisticsEvent.java
Outdated
Show resolved
Hide resolved
src/jdk.jfr/share/classes/jdk/jfr/events/FileReadIOStatisticsEvent.java
Outdated
Show resolved
Hide resolved
| totalReadBytesForPeriod.addAndGet(bytesRead); | ||
| } | ||
|
|
||
| // returning rate |
There was a problem hiding this comment.
Thank you for the suggestion. I've added a clear comment as per your feedback.
| if (interval > 0) { | ||
| totalDuration.addAndGet(-interval); | ||
| double intervalInSec = (interval * 1.0 / 1_000_000_000); | ||
| long rRate = (long) (result / intervalInSec); |
There was a problem hiding this comment.
I think the cast may not be needed here.
There was a problem hiding this comment.
@JohnTortugo , The "(result / intervalInSec)" was giving a double and erroring out with "error: incompatible types: possible lossy conversion from double to long". So, I had to explicitly add long to prevent data loss.
…ng the writebytes and read bytes if the events are not enabled, updated year in the description, added code comments
| } | ||
| if (readPeriodicEvent.isEnabled()) { | ||
| long duration = System.nanoTime() - startTime; | ||
| FileReadIOStatisticsEvent.setTotalReadBytesForPeriod(1, duration); |
There was a problem hiding this comment.
I've just realized that in the "read" cases, there's potential to report more than was actually read, in this case we report 1 , but should report using a test '(result < 0) ? 0: 1)'
There was a problem hiding this comment.
Thanks @macarte for catching that. This needs to be fixed at multiple places. I'll make the necessary changes.
… to decrease the error in getting the accumulated bytes number
Summary:
AzDO Work item: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1751674
This pull request introduces code and test cases for incorporating new JDK.JFR (Java Flight Recorder) File I/O events. These events are designed to periodically monitor Read Rate and Write Rate within specified intervals. The goal is to gain valuable insights into JVM performance patterns over time. The implementation is achieved through Instrumentation.
These events are designed to capture byte data statistics (Read Rate (Bytes/Sec), Write Rate((Bytes/Sec))) associated with JDK APIs, specifically those from classes like FileOutputStream, FileInputStream, RandomAccessFile, and sun.nio.ch.FileChannelImpl.
It's important to note that these events do not include byte data related to native file operations. (Native library loads).
By default, the events are disabled in default.jfc and profile.jfc
The events attributes:
Events Screenshots from JMC: