RFR: 8324972: (bf) Make DirectByteBuffer.Deallocator idempotent [v4]
Mark Sheppard
msheppar at openjdk.org
Mon Feb 19 11:32:56 UTC 2024
On Thu, 8 Feb 2024 10:58:05 GMT, Per Minborg <pminborg at openjdk.org> wrote:
>> This PR proposes to make deallocators and unmappers for memory regions idempotent. This is to prevent (likely very rare) duplicate invocations.
>>
>> There are no unit tests but it should be noted that the idempotent behavior (now correct) is similar to the intended behavior before cf74b8c2a32f33019a13ce80b6667da502cc6722 but where idempotency was not guaranteed in a multi-threaded environment.
>>
>> Passes tier1, 2, and 3 tests.
>
> Per Minborg has updated the pull request incrementally with two additional commits since the last revision:
>
> - Use existing UNSAFE static variable
> - Remove unused import
which by inference means that change https://bugs.openjdk.org/browse/JDK-8316337 was not required, also.
No need for threads safety or safe publication if there is no concurrency involved
I can close it but I don't agree with the conclusion. The Deallocator should convey whether the native memory block has been freed or not, and maintained its idempotent characteristic, irrespective of concurrency or at most once semantics. The latter being wholely dependent on correct execution of Cleaner mechanism. At most once semantics should come from the implementation and the current implementation does not exhibit at most once semantics, while the original logic did provide at most once semantics for serial execution. But not for concurrent execution
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17647#issuecomment-1952255025
More information about the nio-dev
mailing list