On Thu, 14 Nov 2024 13:28:46 GMT, Axel Boldt-Christmas <abold...@openjdk.org> wrote:
> This seem to handle excessive allocations when churning around an empty list > by keeping the head node always allocated. Realistically, the list is almost never empty: there is a `Cleaner` instance itself recorded in the list. The only (?) state when the list is fully empty is when `Cleaner` itself is also dead, AFAICS. We pre-allocate head node for the implementation simplicity: if `head` is always available, we don't need to null-check it, for example. > I wonder if there is any worth adding some hysteresis if it churns around a > multiple of the `NODE_CAPACITY`, by for example pooling one node. I don't think we should care about this case: it seems the rare benefit does not outweigh the cost for common case? The goal for this implementation is to avoid wasting more space than necessary. Caching a node would take another bunch of KBs per Cleaner, at very least. ------------- PR Comment: https://git.openjdk.org/jdk/pull/22043#issuecomment-2476419160