From 8a42cccabe1043901138541ba82dc2198d80fb8a Mon Sep 17 00:00:00 2001 From: jedrek0429 <64475360+jedrek0429@users.noreply.github.com> Date: Fri, 5 Apr 2024 19:56:07 +0200 Subject: [PATCH 1/2] Make thread count configurable for `UpdateLiveData` --- .../main/java/net/pl3x/map/core/configuration/Config.java | 6 ++++++ .../net/pl3x/map/core/renderer/task/UpdateLiveData.java | 4 ++-- core/src/main/java/net/pl3x/map/core/world/World.java | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/net/pl3x/map/core/configuration/Config.java b/core/src/main/java/net/pl3x/map/core/configuration/Config.java index a0c4a2cae..600835e20 100644 --- a/core/src/main/java/net/pl3x/map/core/configuration/Config.java +++ b/core/src/main/java/net/pl3x/map/core/configuration/Config.java @@ -118,6 +118,12 @@ How many scroll pixels (as reported by L.DomEvent.getWheelDelta) mean for security reasons. But you do you, boo boo.""") public static boolean HTTPD_FOLLOW_SYMLINKS = false; + @Key("settings.performance.live-update-threads") + @Comment(""" + The number of process-threads to use for for real-time marker updates on the map. + Value of -1 will use 50% of the available cpu-threads. (recommended)""") + public static int LIVE_UPDATE_THREADS = -1; + @Key("settings.performance.render-threads") @Comment(""" The number of process-threads to use for loading and scanning chunks. diff --git a/core/src/main/java/net/pl3x/map/core/renderer/task/UpdateLiveData.java b/core/src/main/java/net/pl3x/map/core/renderer/task/UpdateLiveData.java index e03b11bc4..794fcc22c 100644 --- a/core/src/main/java/net/pl3x/map/core/renderer/task/UpdateLiveData.java +++ b/core/src/main/java/net/pl3x/map/core/renderer/task/UpdateLiveData.java @@ -45,8 +45,8 @@ public class UpdateLiveData extends AbstractDataTask { .build(); private Map> liveUpdateFutures; - public UpdateLiveData(@NotNull World world) { - super(1, true, world, "Pl3xMap-LiveData", 2); + public UpdateLiveData(@NotNull World world, int threads) { + super(1, true, world, "Pl3xMap-LiveData", threads); this.liveUpdateFutures = new HashMap<>(); } diff --git a/core/src/main/java/net/pl3x/map/core/world/World.java b/core/src/main/java/net/pl3x/map/core/world/World.java index aa1cfc4f0..7fc4e7145 100644 --- a/core/src/main/java/net/pl3x/map/core/world/World.java +++ b/core/src/main/java/net/pl3x/map/core/world/World.java @@ -43,6 +43,7 @@ import javax.imageio.ImageIO; import net.pl3x.map.core.Keyed; import net.pl3x.map.core.Pl3xMap; +import net.pl3x.map.core.configuration.Config; import net.pl3x.map.core.configuration.PlayersLayerConfig; import net.pl3x.map.core.configuration.SpawnLayerConfig; import net.pl3x.map.core.configuration.WorldBorderLayerConfig; @@ -128,7 +129,7 @@ public World(@NotNull String name, long seed, @NotNull Point spawn, @NotNull Typ this.regionModifiedState = new RegionModifiedState(this); //this.regionFileWatcher = new RegionFileWatcher(this); this.markerTask = new UpdateMarkerData(this); - this.liveDataTask = new UpdateLiveData(this); + this.liveDataTask = new UpdateLiveData(this, Config.LIVE_UPDATE_THREADS); } protected void init() { From 45b2be300be53046067b8ec447015f4f2cf14a12 Mon Sep 17 00:00:00 2001 From: jedrek0429 <64475360+jedrek0429@users.noreply.github.com> Date: Fri, 5 Apr 2024 19:57:09 +0200 Subject: [PATCH 2/2] Fix typo --- core/src/main/java/net/pl3x/map/core/configuration/Config.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/net/pl3x/map/core/configuration/Config.java b/core/src/main/java/net/pl3x/map/core/configuration/Config.java index 600835e20..88ee80025 100644 --- a/core/src/main/java/net/pl3x/map/core/configuration/Config.java +++ b/core/src/main/java/net/pl3x/map/core/configuration/Config.java @@ -120,7 +120,7 @@ How many scroll pixels (as reported by L.DomEvent.getWheelDelta) mean @Key("settings.performance.live-update-threads") @Comment(""" - The number of process-threads to use for for real-time marker updates on the map. + The number of process-threads to use for real-time marker updates on the map. Value of -1 will use 50% of the available cpu-threads. (recommended)""") public static int LIVE_UPDATE_THREADS = -1;