Skip to content

Commit 0aa6cde

Browse files
committed
Remove stupid MemoryManager settings
No one in their right mind is going to change the defaults for these anyway. All this crap does is overwhelm users with stuff they don't understand. Most of this stuff has no business being modified by non-developers anyway.
1 parent 8f8fe94 commit 0aa6cde

File tree

3 files changed

+16
-56
lines changed

3 files changed

+16
-56
lines changed

resources/pocketmine.yml

-16
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ memory:
5454
#This only affects the main thread. Other threads should fire their own collections
5555
period: 36000
5656

57-
#Fire asynchronous tasks to collect garbage from workers
58-
collect-async-worker: true
59-
60-
#Trigger on low memory
61-
low-memory-trigger: true
62-
6357
#Settings controlling memory dump handling.
6458
memory-dump:
6559
#Dump memory from async workers as well as the main thread. If you have issues with segfaults when dumping memory, disable this setting.
@@ -69,16 +63,6 @@ memory:
6963
#Cap maximum render distance per player when low memory is triggered. Set to 0 to disable cap.
7064
chunk-radius: 4
7165

72-
#Do chunk garbage collection on trigger
73-
trigger-chunk-collect: true
74-
75-
world-caches:
76-
#Disallow adding to world chunk-packet caches when memory is low
77-
disable-chunk-cache: true
78-
#Clear world caches when memory is low
79-
low-memory-trigger: true
80-
81-
8266
network:
8367
#Threshold for batching packets, in bytes. Only these packets will be compressed
8468
#Set to 0 to compress everything, -1 to disable.

src/MemoryManager.php

+16-34
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,11 @@ class MemoryManager{
9999

100100
private int $garbageCollectionPeriod;
101101
private int $garbageCollectionTicker = 0;
102-
private bool $garbageCollectionTrigger;
103-
private bool $garbageCollectionAsync;
104102

105103
private int $cycleCollectionThreshold = self::GC_THRESHOLD_DEFAULT;
106104
private int $cycleCollectionTimeTotalNs = 0;
107105

108106
private int $lowMemChunkRadiusOverride;
109-
private bool $lowMemChunkGC;
110-
111-
private bool $lowMemDisableChunkCache;
112-
private bool $lowMemClearWorldCache;
113107

114108
private bool $dumpWorkers = true;
115109

@@ -157,14 +151,8 @@ private function init(ServerConfigGroup $config) : void{
157151
$this->continuousTriggerRate = $config->getPropertyInt(Yml::MEMORY_CONTINUOUS_TRIGGER_RATE, self::DEFAULT_CONTINUOUS_TRIGGER_RATE);
158152

159153
$this->garbageCollectionPeriod = $config->getPropertyInt(Yml::MEMORY_GARBAGE_COLLECTION_PERIOD, self::DEFAULT_TICKS_PER_GC);
160-
$this->garbageCollectionTrigger = $config->getPropertyBool(Yml::MEMORY_GARBAGE_COLLECTION_LOW_MEMORY_TRIGGER, true);
161-
$this->garbageCollectionAsync = $config->getPropertyBool(Yml::MEMORY_GARBAGE_COLLECTION_COLLECT_ASYNC_WORKER, true);
162154

163155
$this->lowMemChunkRadiusOverride = $config->getPropertyInt(Yml::MEMORY_MAX_CHUNKS_CHUNK_RADIUS, 4);
164-
$this->lowMemChunkGC = $config->getPropertyBool(Yml::MEMORY_MAX_CHUNKS_TRIGGER_CHUNK_COLLECT, true);
165-
166-
$this->lowMemDisableChunkCache = $config->getPropertyBool(Yml::MEMORY_WORLD_CACHES_DISABLE_CHUNK_CACHE, true);
167-
$this->lowMemClearWorldCache = $config->getPropertyBool(Yml::MEMORY_WORLD_CACHES_LOW_MEMORY_TRIGGER, true);
168156

169157
$this->dumpWorkers = $config->getPropertyBool(Yml::MEMORY_MEMORY_DUMP_DUMP_ASYNC_WORKER, true);
170158
}
@@ -177,8 +165,11 @@ public function getGlobalMemoryLimit() : int{
177165
return $this->globalMemoryLimit;
178166
}
179167

168+
/**
169+
* @deprecated
170+
*/
180171
public function canUseChunkCache() : bool{
181-
return !$this->lowMemory || !$this->lowMemDisableChunkCache;
172+
return !$this->lowMemory;
182173
}
183174

184175
/**
@@ -194,26 +185,19 @@ public function getViewDistance(int $distance) : int{
194185
public function trigger(int $memory, int $limit, bool $global = false, int $triggerCount = 0) : void{
195186
$this->logger->debug(sprintf("%sLow memory triggered, limit %gMB, using %gMB",
196187
$global ? "Global " : "", round(($limit / 1024) / 1024, 2), round(($memory / 1024) / 1024, 2)));
197-
if($this->lowMemClearWorldCache){
198-
foreach($this->server->getWorldManager()->getWorlds() as $world){
199-
$world->clearCache(true);
200-
}
201-
ChunkCache::pruneCaches();
188+
foreach($this->server->getWorldManager()->getWorlds() as $world){
189+
$world->clearCache(true);
202190
}
191+
ChunkCache::pruneCaches();
203192

204-
if($this->lowMemChunkGC){
205-
foreach($this->server->getWorldManager()->getWorlds() as $world){
206-
$world->doChunkGarbageCollection();
207-
}
193+
foreach($this->server->getWorldManager()->getWorlds() as $world){
194+
$world->doChunkGarbageCollection();
208195
}
209196

210197
$ev = new LowMemoryEvent($memory, $limit, $global, $triggerCount);
211198
$ev->call();
212199

213-
$cycles = 0;
214-
if($this->garbageCollectionTrigger){
215-
$cycles = $this->triggerGarbageCollector();
216-
}
200+
$cycles = $this->triggerGarbageCollector();
217201

218202
$this->logger->debug(sprintf("Freed %gMB, $cycles cycles", round(($ev->getMemoryFreed() / 1024) / 1024, 2)));
219203
}
@@ -289,14 +273,12 @@ public function check() : void{
289273
public function triggerGarbageCollector() : int{
290274
Timings::$garbageCollector->startTiming();
291275

292-
if($this->garbageCollectionAsync){
293-
$pool = $this->server->getAsyncPool();
294-
if(($w = $pool->shutdownUnusedWorkers()) > 0){
295-
$this->logger->debug("Shut down $w idle async pool workers");
296-
}
297-
foreach($pool->getRunningWorkers() as $i){
298-
$pool->submitTaskToWorker(new GarbageCollectionTask(), $i);
299-
}
276+
$pool = $this->server->getAsyncPool();
277+
if(($w = $pool->shutdownUnusedWorkers()) > 0){
278+
$this->logger->debug("Shut down $w idle async pool workers");
279+
}
280+
foreach($pool->getRunningWorkers() as $i){
281+
$pool->submitTaskToWorker(new GarbageCollectionTask(), $i);
300282
}
301283

302284
$cycles = gc_collect_cycles();

src/YmlServerProperties.php

-6
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,14 @@ private function __construct(){
7575
public const MEMORY_CONTINUOUS_TRIGGER = 'memory.continuous-trigger';
7676
public const MEMORY_CONTINUOUS_TRIGGER_RATE = 'memory.continuous-trigger-rate';
7777
public const MEMORY_GARBAGE_COLLECTION = 'memory.garbage-collection';
78-
public const MEMORY_GARBAGE_COLLECTION_COLLECT_ASYNC_WORKER = 'memory.garbage-collection.collect-async-worker';
79-
public const MEMORY_GARBAGE_COLLECTION_LOW_MEMORY_TRIGGER = 'memory.garbage-collection.low-memory-trigger';
8078
public const MEMORY_GARBAGE_COLLECTION_PERIOD = 'memory.garbage-collection.period';
8179
public const MEMORY_GLOBAL_LIMIT = 'memory.global-limit';
8280
public const MEMORY_MAIN_HARD_LIMIT = 'memory.main-hard-limit';
8381
public const MEMORY_MAIN_LIMIT = 'memory.main-limit';
8482
public const MEMORY_MAX_CHUNKS = 'memory.max-chunks';
8583
public const MEMORY_MAX_CHUNKS_CHUNK_RADIUS = 'memory.max-chunks.chunk-radius';
86-
public const MEMORY_MAX_CHUNKS_TRIGGER_CHUNK_COLLECT = 'memory.max-chunks.trigger-chunk-collect';
8784
public const MEMORY_MEMORY_DUMP = 'memory.memory-dump';
8885
public const MEMORY_MEMORY_DUMP_DUMP_ASYNC_WORKER = 'memory.memory-dump.dump-async-worker';
89-
public const MEMORY_WORLD_CACHES = 'memory.world-caches';
90-
public const MEMORY_WORLD_CACHES_DISABLE_CHUNK_CACHE = 'memory.world-caches.disable-chunk-cache';
91-
public const MEMORY_WORLD_CACHES_LOW_MEMORY_TRIGGER = 'memory.world-caches.low-memory-trigger';
9286
public const NETWORK = 'network';
9387
public const NETWORK_ASYNC_COMPRESSION = 'network.async-compression';
9488
public const NETWORK_ASYNC_COMPRESSION_THRESHOLD = 'network.async-compression-threshold';

0 commit comments

Comments
 (0)