RFR: 8321594: NativeThreadSet should use placeholder for virtual threads
Alan Bateman
alanb at openjdk.org
Mon Dec 11 09:54:37 UTC 2023
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.
-------------
Commit messages:
- constant should be static
- remove(-1) would be no-op
- Initial commit
Changes: https://git.openjdk.org/jdk/pull/17034/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17034&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8321594
Stats: 77 lines in 3 files changed: 21 ins; 25 del; 31 mod
Patch: https://git.openjdk.org/jdk/pull/17034.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/17034/head:pull/17034
PR: https://git.openjdk.org/jdk/pull/17034
More information about the nio-dev
mailing list