On Thu, 15 Aug 2024 14:16:11 GMT, Erik Gahlin <egah...@openjdk.org> wrote:

>> src/jdk.jfr/share/classes/jdk/jfr/internal/StringPool.java line 86:
>> 
>>> 84: 
>>> 85:     private static void unpinVirtualThread() {
>>> 86:         if (Thread.currentThread().isVirtual() && 
>>> ContinuationSupport.isSupported()) {
>> 
>> If you are at all concerned about overhead here then pin could return a 
>> boolean to indicate if the pin happened and oyu could then unpin just by 
>> checking that boolean and avoid doing the isVirtual and isSupported checks 
>> again.
>
> Would it be possible to create a boolean in the EventWriter that indicates if 
> it is associated with a carrier thread or a normal thread (which can never be 
> virtual) and then have two methods.
> 
>     long l = this.carrierThread ? StringPool.addPinnedString(s) : 
> StringPool.addString(s);

Thread.currentThread() has an intrinsic, and isVirtual is just a type check. 
ContinuationSupport.isSupported reads a static final so will disappear once 
compiled. The pattern we are using in other areas is for the pin to return a 
boolean (like David suggested).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20588#discussion_r1718489921

Reply via email to