
For this reason, if Java finds that there is a reliable RDTSC clock then Java will use this clock for JFR time stamps. The RDTSC clock has much lower overhead and is far faster in retrieving a time stamp than the OS clock. The RDTSC clock is the most precise clock available on the x86 architecture as it is a counter that increments for every clock cycle and stores this number in a register. This clock will always be used by GC logs. The OS clock is the appropriate system clock that your machine supports. The OS clock is guaranteed to be used, while RDTSC will be used if Java determines that you have reliable x86 hardware to support this clock. These clocks are the Read Time-Stamp Counter (RDTSC) clock and the OS clock. Just when things got clearer, I learned that Java could use more than one clock. However, this lag is only consistent if they are using the same clock. For this reason, the start times recorded by GC logs tend to lag behind JFR files by about a fourth of a second. GC logs, on the other hand, record the start time as the event is being printed. JFR defines the start time as the beginning of the event, storing the time to be used later when the event is reported out to the JFR file. How do you define the start time of an event? I thought this would have one simple answer but turns out JFR and GC logging do not agree. Most of these differences do not end up affecting the data received by the end user, except, of course, for timing. For this topic, I am primarily concerned with the RecordedEvent s that deal with garbage collection and their corresponding startTime field.Īlthough both JFR files and GC logs both hold equivalent information about garbage collection, there are a few differences on how they gather and report this information. These events can be retrieved through an API call and cover a variety of information.


In contrast, a JFR file holds binary that correlates to specific Java Objects called a RecordedEvent. A GC log is a text-based file that reports specific garbage collection events line by line with a time stamp at the very beginning of every line. JFR files and GC logs can both be a great source of information on Java’s garbage collection events, however, their approach and format are slightly different. GC Logsįirst on my journey, was to understand Java’s garbage collection tools. What follows is a discussion of what I found. This led me into a deep dive on how GC logging and JFR both acquire and report times. On accident, I discovered that the times these tools reported for corresponding garbage collection events not only differed but diverged over time. Three months ago, I started with a seemingly simple task of investigating the quality of garbage collection information in Java Flight Recorder (JFR) and Garbage Collection (GC) logging.
Onyx for mac os is total garbage how to#
In the end, I am left with a headache of confusion on how to tell time, something I thought I mastered in 2nd grade. The more I learned, the more some things became clearer and the more other things became cloudier. As I wrap up my internship with Microsoft this summer, I have discovered the value in being confused.
