RFR: 8351594: JFR: Rate-limited sampling of Java events [v2]
Markus Grönlund
mgronlun at openjdk.org
Mon Jun 2 10:14:52 UTC 2025
On Sun, 1 Jun 2025 13:07:50 GMT, Erik Gahlin <egahlin at openjdk.org> wrote:
>> src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java line 256:
>>
>>> 254: // }
>>> 255: getEventConfiguration(codeBuilder);
>>> 256: codeBuilder.aload(0);
>>
>> Can issue a dup() here if you want to avoid the second aload(0).
>
> I don't think it will work because the result of the first getField (startTime) will be on the stack, when we issue the next getField (duration).
No big deal, we can look into the details later.
>> src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java line 261:
>>
>>> 259: getfield(codeBuilder, eventClassDesc, ImplicitFields.FIELD_DURATION);
>>> 260: Bytecode.invokevirtual(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_THROTTLE);
>>> 261: int result = codeBuilder.allocateLocal(TypeKind.LONG);
>>
>> Do we really need to store the result in a local? Can't we just dup it on the expression stack and store it directly into the field after another aload, or dup? Perhaps dup twice to then issue the mask operation?
>
> We could do an aload(0) at the beginning, before getEventConfiguration(codeBuilder), to have "this" for putfield(duration) later, but then we would need to do a getfield(this.duration) to have it on the stack for the mask.
>
> We can't do a dup() on duration because we need "this" on the stack to store it in this.duration. I thought using a local variable would be faster than accessing this.duration. It also reduces the chance of the value being changed by another thread.
No big deal, we can look into this later if the need arises.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25559#discussion_r2120675164
PR Review Comment: https://git.openjdk.org/jdk/pull/25559#discussion_r2120676832
More information about the net-dev
mailing list