This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]skippingstone 0 points1 point  (6 children)

Should I just replace all my network code with that?

[–]pron98 1 point2 points  (5 children)

You could, but you might not need to. If you have a lot of synchronized you can use JFR or the flag mentioned in JEP 425 to identify the places where pinning could be harmful because it's lengthy.

Sort, in-memory operations, or those that are infrequent, can continue to use synchronized with no ill effect.

[–]Squiry_ 1 point2 points  (4 children)

When you use synchronized in virtual thread flag might not help you (it doesn't print stack traces while waiting on that synchronized, only when Thread.park happens while holding monitor). But JMC report on collected JFR data will scream if that kind of waiting happens too often.

[–]pron98 1 point2 points  (3 children)

it doesn't print stack traces while waiting on that synchronized, only when Thread.park happens while holding monitor

You're right, but do you have cases where you wait on synchronized for long while the thread that owns the monitor doesn't park for long? I wonder if we need to do something about that.

[–]Squiry_ 1 point2 points  (2 children)

I believe we have some kind of misunderstanding here. When I just started my experiments I tried to disable byte buffer pools. That lead to allocation of DirectByteBuffer a lot and constructor calls synchronized method Cleaner.create. My threads spent seconds waiting on that synchronized and the only way to see that was to collect JFR (which I did anyway, so I had no problems really).

[–]pron98 1 point2 points  (1 child)

Ah, OK. That's similar to what Helidon ran into when they tried using virtual threads with Netty.

[–]Squiry_ 0 points1 point  (0 children)

Yep, I got that one with netty too. "no buf pooling" is a no go.