On Thu, 9 May 2024 14:25:27 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:

>> Erik Gahlin has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   Move methods
>
> src/java.base/share/classes/java/io/FileInputStream.java line 63:
> 
>> 61:     private static final int DEFAULT_BUFFER_SIZE = 8192;
>> 62: 
>> 63:     // Flag that determines if file reads should be traced by JFR
> 
> It could be good to also note what will modify this flag - here and in other 
> classes.
> I'm going to guess that the purpose of this flag is purely performance, to 
> avoid even loading the event class, `FileReadEvent` here, during 
> startup/bootstrap and when JFR is not enabled, as read and write methods are 
> highly performance sensitive? Otherwise the flag could live in the event 
> class itself? Is it substantially faster to check this flag compared to 
> `FileReadEvent.enabled()`?

Its purpose is to avoid loading the FileReadEvent class. When the class is 
loaded, JFR will add fields and in some circumstances do other things. I don't 
think the cost is high, but it may add up if the number of events increases. 
Most Java applications don't run with JFR enabled, so this is to prevent them 
from seeing a negative impact.

I can update the text.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19129#discussion_r1595570427

Reply via email to