From d7338a7bb712342a3ff42e5a846e41dc57df140e Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 16 Mar 2023 07:26:08 -0500 Subject: [PATCH] update world gen queue comments --- .../com/seibel/lod/core/generation/BatchGenerator.java | 2 +- .../seibel/lod/core/generation/WorldGenerationQueue.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/seibel/lod/core/generation/BatchGenerator.java b/core/src/main/java/com/seibel/lod/core/generation/BatchGenerator.java index d0af00772..048db4b60 100644 --- a/core/src/main/java/com/seibel/lod/core/generation/BatchGenerator.java +++ b/core/src/main/java/com/seibel/lod/core/generation/BatchGenerator.java @@ -136,7 +136,7 @@ public class BatchGenerator implements IDhApiWorldGenerator @Override public boolean isBusy() { - return this.generationGroup.getEventCount() > Math.max(Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get().intValue(), 1) * 40; // TODO the multiplier here should change dynamically based on how fast the generator is vs the queuing thread, this is too high and may cause issues when moving, but keeps the generator threads fed + return this.generationGroup.getEventCount() > Math.max(Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get().intValue(), 1) * 40; // TODO the multiplier here should change dynamically based on how fast the generator is vs the queuing thread, if this is too high it may cause issues when moving, but if it is too low the generator threads won't have enough tasks to work on } diff --git a/core/src/main/java/com/seibel/lod/core/generation/WorldGenerationQueue.java b/core/src/main/java/com/seibel/lod/core/generation/WorldGenerationQueue.java index 7a19d84c9..be649c1dc 100644 --- a/core/src/main/java/com/seibel/lod/core/generation/WorldGenerationQueue.java +++ b/core/src/main/java/com/seibel/lod/core/generation/WorldGenerationQueue.java @@ -45,11 +45,15 @@ public class WorldGenerationQueue implements Closeable /** If not null this generator is in the process of shutting down */ private volatile CompletableFuture generatorClosingFuture = null; - // TODO this logic isn't great and can cause a limit to how many thread could be used for world generation, - // however it won't cause duplicate request or concurrency issues, so it will be good enough for now + // TODO this logic isn't great and can cause a limit to how many threads could be used for world generation, + // however it won't cause duplicate requests or concurrency issues, so it will be good enough for now. + // A good long term fix may be to either: + // 1. allow the generator to deal with larger sections (let the generator threads split up larger tasks into smaller one + // 2. batch requests better. instead of sending 4 individual tasks of detail level N, send 1 task of detail level n+1 private final ExecutorService queueingThread = ThreadUtil.makeSingleThreadPool("World Gen Queue"); private boolean generationQueueStarted = false; private DhBlockPos2D generationTargetPos = DhBlockPos2D.ZERO; + /** can be used for debugging how many tasks are currently in the queue */ private int numberOfTasksQueued = 0; /** * Settings this to true will cause the system to queue the first generation request it can find,