-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConstrainableInputStream pins virtual threads (Java-21) #2054
Comments
Thanks for raising this. After first review, a few notes:
It's kind of annoying that we can't just supply a lock object in the Buffered constructor, and keep the rest as-is. We could use the multi-jar support to do that if it were a new constructor option. |
OK, fixed! It would be great if you could validate this by running a test on 1.17.1-SNAPSHOT. (git pull; mvn install). I verified that the pin warnings from Jsoup.connect.get() are gone when hitting a remote URL. It would be good to identify a way to have a integration test for this. |
Thanks a ton for addressing this so timely. I will validate the patch this weekend and come back here.
I think that might be related to another limitation in Loom. Some FS operations might not unload a blocking call. I don't remember where I read that, but a keyword was the missing io_uring support in the JDK. Here's an article hinting that (under "Blocking and unmounting").
I had also that thought. There are JFR events to help that, but it would be nice (if possible at all) if a testing framework would provide such assertions. I will give it a thought and maybe raise an issue at another place, so that everybody can benefit from that. Thanks again for the fix. |
Here's my promised updated: I can confirm that 1.17.1-SNAPSHOT fixed the issue. No more thread pinning events. Thanks a ton. |
That's great, thanks for confirming! |
(Ah the way that BufferedInputStream is effectively locked for extension past Java 21 is bugging me. As part of #2186 I want to be able to replace the |
Sample to reproduce:
Running that with
-Djdk.tracePinnedThreads=full
in Java-21(on a virtual thread) will give the following print:BufferedInputStream
was refactored to be virtual thread friendly, however with a caveat: It becomes unfriendly when inherited (whichConstrainableInputStream
does):With Loom gaining popularity with the latest LTS release, do you want to reconsider
ConstrainableInputStream
inheriting fromBufferedInputStream
? A possible mitigation might be to use composition instead, i.e. inherit fromFilterInputStream
and use a new instance ofBufferedInputStream
as source:The text was updated successfully, but these errors were encountered: