From 6ed0fb4e7c6439356ddc5bf7a442b7cee3274d70 Mon Sep 17 00:00:00 2001 From: Danny Thomas Date: Wed, 25 Oct 2023 16:40:57 +1100 Subject: [PATCH] Add Azul C4 (GPGC) --- .../memory/pool/GarbageCollectorAwareRecycler.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/hollow/src/main/java/com/netflix/hollow/core/memory/pool/GarbageCollectorAwareRecycler.java b/hollow/src/main/java/com/netflix/hollow/core/memory/pool/GarbageCollectorAwareRecycler.java index 4b4d0a97e3..07da822f20 100644 --- a/hollow/src/main/java/com/netflix/hollow/core/memory/pool/GarbageCollectorAwareRecycler.java +++ b/hollow/src/main/java/com/netflix/hollow/core/memory/pool/GarbageCollectorAwareRecycler.java @@ -2,6 +2,11 @@ import java.lang.management.ManagementFactory; +import java.lang.management.MemoryManagerMXBean; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; /** * A {@link ArraySegmentRecycler} that chooses the appropriate recycler based on the garbage collector in use. @@ -10,6 +15,8 @@ * delegate to {@link WastefulRecycler}. Otherwise the default {@link RecyclingRecycler} is used. */ public class GarbageCollectorAwareRecycler implements ArraySegmentRecycler { + private static final List LOW_PAUSE_COLLECTORS = Arrays.asList("GPGC", "Shenandoah", "ZGC"); + private final ArraySegmentRecycler delegate; public GarbageCollectorAwareRecycler() { @@ -19,7 +26,12 @@ public GarbageCollectorAwareRecycler() { public GarbageCollectorAwareRecycler(int log2OfByteSegmentSize, int log2OfLongSegmentSize) { boolean isLowPause = ManagementFactory.getGarbageCollectorMXBeans() .stream() - .anyMatch(bean -> bean.getName().startsWith("Shenandoah") || bean.getName().startsWith("ZGC")); + .map(MemoryManagerMXBean::getName) + .map(name -> name.split(" ")[0]) + .distinct() + .findFirst() + .map(LOW_PAUSE_COLLECTORS::contains) + .orElse(false); delegate = isLowPause ? new WastefulRecycler(log2OfByteSegmentSize, log2OfLongSegmentSize) : new RecyclingRecycler(log2OfByteSegmentSize, log2OfLongSegmentSize); }