Integrated: 8323612: IOVecWrapper should be changed to be TerminatingThreadLocal
Alan Bateman
alanb at openjdk.org
Wed Jan 17 10:58:58 UTC 2024
On Thu, 11 Jan 2024 19:36:59 GMT, Alan Bateman <alanb at openjdk.org> wrote:
> 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.)
This pull request has now been integrated.
Changeset: b8dafa64
Author: Alan Bateman <alanb at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/b8dafa642e6c401039d7561f562c98d46e34e5ab
Stats: 42 lines in 2 files changed: 18 ins; 6 del; 18 mod
8323612: IOVecWrapper should be changed to be TerminatingThreadLocal
Reviewed-by: bpb
-------------
PR: https://git.openjdk.org/jdk/pull/17379
More information about the nio-dev
mailing list