RFR: 8323612: IOVecWrapper should be changed to be TerminatingThreadLocal

Alan Bateman alanb at openjdk.org
Mon Jan 15 08:59:30 UTC 2024


Scatter/gather ops use a native iovec structure that is cached in a thread-local and registered with a Cleaner so it may be freed sometime after the thread has terminated. The change proposed here is to change it to a TerminatingThreadLocal so that it is freed when the thread terminates. In addition, to allow a virtual thread be preempted while it has a reference to iovec structure, IOVecWrapper.get is changed to "remove" the iovec from the cache, a new release method will re-add it to the cache. The changes mean this cache is consistent with the cache of direct buffers. The original plan was to also change IOVecWrapper but it somehow got forgotten.

(The changes proposed here have been in the loom repo for some time. In the loom repo, preemption is possible when doing scatter/gather ops where the array of buffers includes heap buffers. More specifically, the iovec is obtained before substitution of heap buffers so it's possible that direct memory is exhausted and the thread has to wait for reference processing.)

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

Commit messages:
 - Initial commit

Changes: https://git.openjdk.org/jdk/pull/17379/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17379&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8323612
  Stats: 42 lines in 2 files changed: 18 ins; 6 del; 18 mod
  Patch: https://git.openjdk.org/jdk/pull/17379.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17379/head:pull/17379

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


More information about the nio-dev mailing list