From 3f35909641d1ebd3748e8045b4cdf999426356b9 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 29 Oct 2023 15:04:46 -0500 Subject: [PATCH] Reduce CPU load when moving around the world Should've made this multiple commits, but too late now - Create ConfigThreadPool to remove duplicate thread setup/config code - Move configurable thread pools into their own ThreadPools class - Add a semaphore to limit how many LOD builder/lighting/bufferBuilder threads can be active at once --- .../common/wrappers/worldGeneration/GenerationEvent.java | 4 +++- coreSubProjects | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/GenerationEvent.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/GenerationEvent.java index 7d2521f62..3bee78e77 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/GenerationEvent.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/GenerationEvent.java @@ -27,10 +27,12 @@ import java.util.function.Consumer; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep; import com.seibel.distanthorizons.core.generation.WorldGenerationQueue; +import com.seibel.distanthorizons.core.util.ThreadUtil; import com.seibel.distanthorizons.core.util.objects.UncheckedInterruptedException; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.util.objects.EventTimer; +import com.seibel.distanthorizons.core.util.threading.ThreadPools; import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; import org.apache.logging.log4j.Logger; @@ -121,7 +123,7 @@ public final class GenerationEvent public boolean terminate() { LOGGER.info("======================DUMPING ALL THREADS FOR WORLD GEN======================="); - WorldGenerationQueue.THREAD_FACTORY.dumpAllThreadStacks(); + ThreadPools.WORLD_GEN_THREAD_FACTORY.dumpAllThreadStacks(); this.future.cancel(true); return this.future.isCancelled(); } diff --git a/coreSubProjects b/coreSubProjects index 643112953..446c27409 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 643112953ee891874aefa25327bf7f2b53a63258 +Subproject commit 446c2740942eb4994df8864fbc2fc8defabadd7a