On Wed, 13 Nov 2024 20:33:25 GMT, Aleksey Shipilev <sh...@openjdk.org> wrote:
>> See the bug for more discussion and reproducer. This PR replaces the ad-hoc >> linked list with the `ArrayList` wrapper that manages synchronization, >> search and replacements efficiently. Arrays are easy targets for GC. There >> are possible improvements here, most glaring is parallelism that is >> currently knee-capped by global synchronization. The synchronization scheme >> follows what we have in original code, and I think it is safer to continue >> with it right now. >> >> I'll put performance data in a separate comment. >> >> Additional testing: >> - [x] Original reproducer improves drastically >> - [x] New microbenchmark shows no regression on "churning" tests, which >> covers insertion/removal perf >> - [x] New microbenchmark shows improvement on Full GC times (crude, but >> repeatable), serves as a proxy for reproducer >> - [x] `java/lang/ref` tests in release >> - [x] `all` tests in fastdebug > > Aleksey Shipilev has updated the pull request incrementally with one > additional commit since the last revision: > > Review feedback: make sure trimming actually works, stylistic changes src/java.base/share/classes/jdk/internal/ref/CleanerImpl.java line 236: > 234: static final class PhantomCleanableList { > 235: private static final int MIN_CAPACITY = 16; > 236: private final Object lock = new Object(); Why use another lock object when identity of this list is not escaped elsewhere? src/java.base/share/classes/jdk/internal/ref/CleanerImpl.java line 311: > 309: // want to cause an immediate resize on next insertion. > 310: if ((size < arr.length / 4) && (size > MIN_CAPACITY)) { > 311: int newLen = ArraysSupport.newLength(size, 1, size); This code isn't immediately clear that it's trying to half the array size, as you are using the size computation method for array growth. Can you add a remark for so? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22043#discussion_r1841375400 PR Review Comment: https://git.openjdk.org/jdk/pull/22043#discussion_r1841378770