ScopedValue performance declines as number of dynamic bindings increases

Robert Engels robaho at me.com
Tue Jun 24 16:35:26 UTC 2025


The reason in the difference in the compile times is related to the number of error messages generated.

If you compile using —enable-preview you will see that the compile times are nearly identical.

> On Jun 24, 2025, at 11:08 AM, Aleksey Shipilev <shipilev at amazon.de> wrote:
> 
> On 24.06.25 18:01, Johan Sjolen wrote:
>> Oooh, that could explain the issue completely. I didn't think about that at all.
>> The issue basically disappears when compiling first, let me see what happens with a JMH benchmark as well.
> 
> I predict JMH would show the same thing.
> 
> javac is not very fast when cold; this is also why we use it as go-to example in AOT cache studies. I would also expect compiling deeply nested lambdas (like in ScopedTest.java) makes the javac code fairly recursive, which again plays interestingly with JIT compilation. It is still actionable/interesting to figure out what can be improved there. Looks fairly weird we spend >3 seconds compiling a seemingly "easy" source. Submit a tools/javac RFE, let compiler folks have fun with it?
> 
> -Aleksey
> 
> 
> 
> Amazon Web Services Development Center Germany GmbH
> Tamara-Danz-Str. 13
> 10243 Berlin
> Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
> Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
> Sitz: Berlin
> Ust-ID: DE 365 538 597



More information about the loom-dev mailing list