Skip to content

Comments

JFR-1751674: Add new JFR Events: FileReadIOStatisticsEvent, FileWriteIOStatisticsEvent #24

Draft
kthatipally wants to merge 19 commits intokthatipally-testing/JFR-FileIOStatisticsEventsfrom
kthatipally/JFR-Internal-1751674-PeriodicFileIOInstrumentationEvents
Draft

JFR-1751674: Add new JFR Events: FileReadIOStatisticsEvent, FileWriteIOStatisticsEvent #24
kthatipally wants to merge 19 commits intokthatipally-testing/JFR-FileIOStatisticsEventsfrom
kthatipally/JFR-Internal-1751674-PeriodicFileIOInstrumentationEvents

Conversation

@kthatipally
Copy link

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:

FileReadIO Statistics FileWriteIO Statistics Description
Start Time (default) Start Time (default) The start time of the event record.
Duration (default) Duration (default) startTime - endTime
End Time (default) End Time (default) The end time of the event record
Event Thread (default) Event Thread (default) JFR Periodic Thread
Read Rate (Bytes/sec) Write Rate (Bytes/sec) Rate at which the bytes are written/Read from the file operations.
Total Accumulated Read Bytes Total Accumulated Write Bytes Total bytes accumulated by the end of the JVM Process

Events Screenshots from JMC:

image

image

@kthatipally kthatipally requested a review from macarte August 30, 2023 19:17
"Hello",
"GetFlightRecorder",
"GetFlightRecorder$TestEvent",
"jdk/jfr/events/FileReadIOStatisticsEvent",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: can you move these "jdk/jfr/..." tests closer to the ones above?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the tests closer to the other fileEvent tests. Thanks for the suggestion.

import static jdk.test.lib.Asserts.assertGreaterThanOrEqual;

/**
* @test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to add the JBS work item ID here.

</control>

</configuration>
</configuration> No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: missing end of line.

@@ -0,0 +1,95 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People may ask you to adjust the year in the files' header.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated year to 2023. Thanks for catching that.

totalReadBytesForPeriod.addAndGet(bytesRead);
}

// returning rate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: improve comment?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the cast may not be needed here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Keerthi Thatipally added 2 commits September 5, 2023 16:53
…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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @macarte for catching that. This needs to be fixed at multiple places. I'll make the necessary changes.

Keerthi Thatipally added 2 commits September 7, 2023 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants