Question about using virtual thread

Attila Kelemen attila.kelemen85 at gmail.com
Sat Sep 2 17:17:22 UTC 2023


An update on the situation: Now even H2 is Loom friendly (I have also
independently verified that it is the case now). The first version of the
VT friendly H2 is "com.h2database:h2:2.2.222". So, one less excuse to go
for virtual threads :)

Attila Kelemen <attila.kelemen85 at gmail.com> ezt írta (időpont: 2023. jún.
28., Sze, 1:17):

>
>>
>> I have a question regarding H2. Not all pinning due to synchronized is
>> harmful; in fact, most uses of synchronized are benign and need not (and
>> perhaps should not) be replaced with ReentrantLock. It is when pinning is
>> *both* frequent and long-running that it adversely affects virtual threads’
>> scalability. Obviously, if you make the DB sleep inside a synchronized
>> block that would qualify as a problem, but since H2 is an in-memory
>> database, did you also detect a problem with H2 and more realistic uses?
>>
>>
> To be honest, you are right, I'm a bit exaggerating the issue given how H2
> is often used. Though it is possible to show the pinning issue (just easier
> to make it obvious with a sleep). The simplest way to do it is to require
> H2 to lock tables. For example, by running concurrent INSERTs, etc. on the
> same table. In that case, H2 with all the synchronized will be magnitudes
> slower (than my no synchronized modification). Also, there is a server mode
> for H2 (not that I tested it, or ever heard anyone using it ...).
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230902/8782fd86/attachment-0001.htm>


More information about the loom-dev mailing list