Integrated: 8321594: NativeThreadSet should use placeholder for virtual threads

Alan Bateman alanb at openjdk.org
Tue Dec 12 07:58:23 UTC 2023


On Fri, 8 Dec 2023 14:54:34 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> FileChannel has a supporting class named NativeThreadSet to track the threads doing I/O on the channel. It supports the signalling of native threads that are blocked in file I/O and also supports waiting for all threads to finish I/O operations. The signalling part is problematic as it's not feasible on all platforms. It's also problematic for virtual threads because the native thread handle may change, e.g. there is ongoing work on monitors where the native thread handle when blocking on monitorenter may be different to when the thread continues. There is a longer term work required to re-examine if FileChannel needs to continue to be interruptible. The change proposed here to not signal virtual threads so the behavior is similar to Windows and other ports where it's not feasible to preempt file I/O operations. This aligns the behavior with what we've had in the loom repo for some time.
> 
> The implementation change are straight forward, might be more than they initially seem as "elts" is renamed. The main change is that NativeThreadSet keeps count of non-native threads rather than putting a placeholder in the array. The array is also created lazily.
> 
> Testing: tier1-3, FileChannel tests with JTREG_TEST_THREAD_FACTORY=Virtual.

This pull request has now been integrated.

Changeset: b8c0b2fd
Author:    Alan Bateman <alanb at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/b8c0b2fd8c1331692f4ee397f1115ed48d8940d1
Stats:     77 lines in 3 files changed: 21 ins; 25 del; 31 mod

8321594: NativeThreadSet should use placeholder for virtual threads

Reviewed-by: bpb

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

PR: https://git.openjdk.org/jdk/pull/17034


More information about the nio-dev mailing list