RFR: 8358750: JFR: EventInstrumentation MASK_THROTTLE* constants should be computed in longs

Andrey Turbanov aturbanov at openjdk.org
Mon Jun 30 19:48:41 UTC 2025


On Fri, 27 Jun 2025 20:49:37 GMT, Erik Gahlin <egahlin at openjdk.org> wrote:

> Could I have a review of a fix to the throttling mechanism added in JDK 25? Long values should be shifted instead of integer values when creating the masks.
> 
> During debugging, I found several issues, and I also strengthened the test.
> 
> - The start time of the event needs to be stored if the event is being throttled. The reason is that the timestamp is reused later to determine if the event should be throttled or not. This happens with events that lack an end time.
> 
> - The duration value that is written to the buffer must remove the mask if it is throttled. This is handled by`getDuration(blockCodeBuilder)`.
> 
> - I added a clarifying comment that when duration is compared to 0, it also prevents a new duration from being calculated if the event has been throttled (for an instant event).
> 
> The test now checks that the duration is not negative, that the start time is not before the test starts, and that the duration is not unreasonably large. The reason I multiply the recording duration by two is to give the test some slack in case we run into clock issues where the time taken for the event doesn't match the recording. Purpose of the check is to make sure we don't end up with the mask being added to the duration.
> 
> Testing:  
> test/jdk/jdk/jfr + tier1
> 
> I validated manually that the throttle rate works using a small test program I have (which can't be checked in due to stability issues).

test/jdk/jdk/jfr/api/metadata/annotations/TestThrottle.java line 55:

> 53: public class TestThrottle {
> 54: 
> 55:     public static class UnthrottledEvent extends Event  {

Suggestion:

    public static class UnthrottledEvent extends Event {

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26028#discussion_r2175776993


More information about the hotspot-jfr-dev mailing list