From 6805a597365c80a209491c65b89159c8f8d3f561 Mon Sep 17 00:00:00 2001 From: PolyacovYury Date: Fri, 8 Jan 2021 16:38:40 +0300 Subject: [PATCH] Revert "Add max-chunk-lifetime setting used by chunk gc (#3167) - fixed (#3206)" This reverts commit a0a54282 --- .../bridge/world/chunk/ChunkBridge.java | 4 ---- .../common/config/category/WorldCategory.java | 14 ------------ .../mixin/core/world/chunk/ChunkMixin.java | 11 ---------- .../world/gen/ChunkProviderServerMixin.java | 22 ++++--------------- .../spongepowered/common/util/Constants.java | 1 - 5 files changed, 4 insertions(+), 48 deletions(-) diff --git a/src/main/java/org/spongepowered/common/bridge/world/chunk/ChunkBridge.java b/src/main/java/org/spongepowered/common/bridge/world/chunk/ChunkBridge.java index 0b3a18c1bf4..ecef2407bd1 100644 --- a/src/main/java/org/spongepowered/common/bridge/world/chunk/ChunkBridge.java +++ b/src/main/java/org/spongepowered/common/bridge/world/chunk/ChunkBridge.java @@ -106,10 +106,6 @@ public interface ChunkBridge { boolean bridge$isQueuedForUnload(); - long bridge$getLastSaveTime(); - - boolean bridge$isChunkDirty(); - void bridge$markChunkDirty(); boolean bridge$isActive(); diff --git a/src/main/java/org/spongepowered/common/config/category/WorldCategory.java b/src/main/java/org/spongepowered/common/config/category/WorldCategory.java index 29702c66b37..dddabe42af2 100644 --- a/src/main/java/org/spongepowered/common/config/category/WorldCategory.java +++ b/src/main/java/org/spongepowered/common/config/category/WorldCategory.java @@ -94,16 +94,6 @@ public class WorldCategory extends ConfigCategory { + "and increases the chance for a drop in tps. (Default: 100)") private int maxChunkUnloads = 100; - @Setting(value = "max-chunk-lifetime", comment = "" - + "The number of ticks a chunk will stay in memory without saving.\n" - + "Note: this setting only applies to chunks gc forcibly saving chunks\n" - + "(controlled by 'chunk-gc-tick-interval' and 'chunk-gc-load-threshold')\n" - + "Note: Useless if 'auto-save-interval' is enabled and less than this value\n" - + "Note: 'auto-save-interval' becomes mostly useless if both are enabled and\n" - + "it is bigger than this value\n" - + "(Default: 0)") - private int maxChunkLifetime = 0; - @Setting(value = "chunk-gc-load-threshold", comment = "" + "The number of newly loaded chunks before triggering a forced cleanup.\n" + "Note: When triggered, the loaded chunk threshold will reset and start incrementing.\n" @@ -238,10 +228,6 @@ public int getMaxChunkUnloads() { return this.maxChunkUnloads; } - public int getMaxChunkLifetime() { - return this.maxChunkLifetime; - } - public double getItemMergeRadius() { return this.itemMergeRadius; } diff --git a/src/main/java/org/spongepowered/common/mixin/core/world/chunk/ChunkMixin.java b/src/main/java/org/spongepowered/common/mixin/core/world/chunk/ChunkMixin.java index 36e778e48d8..175233402b3 100644 --- a/src/main/java/org/spongepowered/common/mixin/core/world/chunk/ChunkMixin.java +++ b/src/main/java/org/spongepowered/common/mixin/core/world/chunk/ChunkMixin.java @@ -121,7 +121,6 @@ public abstract class ChunkMixin implements ChunkBridge, CacheKeyBridge { @Shadow private boolean loaded; @Shadow private boolean dirty; @Shadow public boolean unloadQueued; - @Shadow private long lastSaveTime; @Shadow @Nullable public abstract TileEntity getTileEntity(BlockPos pos, net.minecraft.world.chunk.Chunk.EnumCreateEntityType p_177424_2_); @Shadow public abstract void generateSkylightMap(); @@ -156,21 +155,11 @@ public abstract class ChunkMixin implements ChunkBridge, CacheKeyBridge { this.dirty = true; } - @Override - public boolean bridge$isChunkDirty() { - return this.dirty; - } - @Override public boolean bridge$isQueuedForUnload() { return this.unloadQueued; } - @Override - public long bridge$getLastSaveTime() { - return this.lastSaveTime; - } - @Override public boolean bridge$isPersistedChunk() { return this.impl$persistedChunk; diff --git a/src/main/java/org/spongepowered/common/mixin/core/world/gen/ChunkProviderServerMixin.java b/src/main/java/org/spongepowered/common/mixin/core/world/gen/ChunkProviderServerMixin.java index 3583c898fbd..97e1ee23906 100644 --- a/src/main/java/org/spongepowered/common/mixin/core/world/gen/ChunkProviderServerMixin.java +++ b/src/main/java/org/spongepowered/common/mixin/core/world/gen/ChunkProviderServerMixin.java @@ -83,7 +83,6 @@ public abstract class ChunkProviderServerMixin implements ChunkProviderServerBri private boolean impl$forceChunkRequests = false; private long impl$chunkUnloadDelay = Constants.World.DEFAULT_CHUNK_UNLOAD_DELAY; private int impl$maxChunkUnloads = Constants.World.MAX_CHUNK_UNLOADS; - private int impl$maxChunkLifetime = Constants.World.MAX_CHUNK_LIFETIME; @Shadow @Final private WorldServer world; @Shadow @Final private IChunkLoader chunkLoader; @@ -109,7 +108,6 @@ public abstract class ChunkProviderServerMixin implements ChunkProviderServerBri this.impl$denyChunkRequests = worldCategory.getDenyChunkRequests(); this.impl$chunkUnloadDelay = worldCategory.getChunkUnloadDelay() * 1000; this.impl$maxChunkUnloads = worldCategory.getMaxChunkUnloads(); - this.impl$maxChunkLifetime = worldCategory.getMaxChunkLifetime(); } @Override @@ -270,14 +268,10 @@ public boolean tick() final Iterator iterator = this.loadedChunks.values().iterator(); int chunksUnloaded = 0; final long now = System.currentTimeMillis(); - final long world_time = this.world.getTotalWorldTime(); while (chunksUnloaded < this.impl$maxChunkUnloads && iterator.hasNext()) { final Chunk chunk = iterator.next(); final ChunkBridge spongeChunk = (ChunkBridge) chunk; - if (chunk == null || spongeChunk.bridge$isPersistedChunk()) { - continue; - } - if (chunk.unloadQueued) { + if (chunk != null && chunk.unloadQueued && !spongeChunk.bridge$isPersistedChunk()) { if (this.bridge$getChunkUnloadDelay() > 0) { if ((now - spongeChunk.bridge$getScheduledForUnload()) < this.impl$chunkUnloadDelay) { continue; @@ -285,19 +279,11 @@ public boolean tick() spongeChunk.bridge$setScheduledForUnload(-1); } chunk.onUnload(); - } - // max lifetime only applies to chunks that should stay loaded but still need saving once in a while - else if (this.impl$maxChunkLifetime <= 0 // if setting is disabled - || !spongeChunk.bridge$isChunkDirty() // no need to save non-dirty chunks - || world_time - spongeChunk.bridge$getLastSaveTime() < this.impl$maxChunkLifetime) { - continue; // don't save chunk data - } - this.saveChunkData(chunk); - this.saveChunkExtraData(chunk); - if (chunk.unloadQueued) { // chunks not queued to unload stay loaded + this.saveChunkData(chunk); + this.saveChunkExtraData(chunk); iterator.remove(); + chunksUnloaded++; } - chunksUnloaded++; } ((WorldServerBridge) this.world).bridge$getTimingsHandler().doChunkUnload.stopTiming(); } diff --git a/src/main/java/org/spongepowered/common/util/Constants.java b/src/main/java/org/spongepowered/common/util/Constants.java index f7311db6c28..b507e051830 100644 --- a/src/main/java/org/spongepowered/common/util/Constants.java +++ b/src/main/java/org/spongepowered/common/util/Constants.java @@ -396,7 +396,6 @@ public static final class World { public static final UUID INVALID_WORLD_UUID = java.util.UUID.fromString("00000000-0000-0000-0000-000000000000"); public static final int DEFAULT_CHUNK_UNLOAD_DELAY = 15000; public static final int MAX_CHUNK_UNLOADS = 100; - public static final int MAX_CHUNK_LIFETIME = 0; public static final String GENERATE_BONUS_CHEST = "GenerateBonusChest"; public static final int CHUNK_UNLOAD_DELAY = 30000; public static final int END_DIMENSION_ID = 1;