> DirectByteBuffers are still using old `jdk.internal.ref.Cleaner` 
> implementation. That implementation carries a doubly-linked list, and so 
> makes DBB suffer from the same issue fixed for generic 
> `java.lang.ref.Cleaner` users with 
> [JDK-8343704](https://bugs.openjdk.org/browse/JDK-8343704). See the bug for 
> the reproducer.
> 
> We can migrate DBBs to use `java.lang.ref.Cleaner`.
> 
> There are two pecularities during this rewrite.
> 
> First, the old ad-hoc `Cleaner` implementation used to exit the VM when 
> cleaning action failed. I presume it was to avoid memory leak / accidental 
> reuse of the buffer. I moved the relevant block to `Deallocator` directly. 
> Unfortunately, I cannot easily test it.
> 
> Second is quite a bit hairy. Old DBB cleaning code was hooked straight into 
> `Reference` processing loop. This was possible because we could infer that 
> the weak references we are processing were DBB cleaning actions, since old 
> `Cleaner` was the only use of this code. With standard `Cleaner`, we have 
> lost this association, and so we cannot really do this from the reference 
> processing loop. With the patched version, we now rely on normal `Cleaner` 
> thread to do cleanups for us.
> 
> Because of this, there is a new outpacing opportunity window where reference 
> processing might have been over, but cleaner thread has not reacted yet. This 
> is why we need another way to check progress that involves checking if 
> cleaner has acted.
> 
> Additional testing:
>  - [x] Linux x86_64 server fastdebug, `java/nio java/io`
>  - [x] Linux AArch64 server fastdebug, `java/nio java/io`
>  - [x] Linux x86_64 server fastdebug, `all`
>  - [x] Linux AArch64 server fastdebug, `all`

Aleksey Shipilev has updated the pull request with a new target base due to a 
merge or a rebase. The incremental webrev excludes the unrelated changes 
brought in by the merge/rebase. The pull request contains 18 additional commits 
since the last revision:

 - Minor post-review adjustments
 - Introduce explicit lock instead of relying on Bits.class
 - Merge branch 'master' into JDK-8344332-dbb-cleaner
 - Revert waitForReferenceProcessing removals, see JDK-8305186
 - Merge branch 'master' into JDK-8344332-dbb-cleaner
 - No instantiation for BufferCleaner, javadocs
 - Remove hasReferencePendingList
 - Revert test exclusion, moved to JDK-8348301
 - Alan's review
 - Remove vestigial reference to waitForReferenceProcessing in tests
 - ... and 8 more: https://git.openjdk.org/jdk/compare/bfcfce2e...a6ffce2e

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/22165/files
  - new: https://git.openjdk.org/jdk/pull/22165/files/dc3dab7f..a6ffce2e

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=22165&range=11
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=22165&range=10-11

  Stats: 49548 lines in 2079 files changed: 26691 ins; 11892 del; 10965 mod
  Patch: https://git.openjdk.org/jdk/pull/22165.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22165/head:pull/22165

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

Reply via email to