Attempt to prevent thread starvation due to world gen
Hopefully this should help prevent issues on low end machines not loading in LODs
This commit is contained in:
+18
-1
@@ -47,7 +47,15 @@ public class GeneratedFullDataSourceProvider extends FullDataSourceProviderV2 im
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
public static final int MAX_WORLD_GEN_REQUESTS_PER_THREAD = 20;
|
||||
/**
|
||||
* Having this number too high causes the system to become overwhelmed by
|
||||
* world gen requests and other jobs won't be done. <br>
|
||||
* IE: LODs won't update or render because world gen is hogging the CPU.
|
||||
* <br><br>
|
||||
* TODO this should be dynamically allocated based on CPU load
|
||||
* and abilities.
|
||||
*/
|
||||
public static final int MAX_WORLD_GEN_REQUESTS_PER_THREAD = 2;
|
||||
|
||||
|
||||
private final AtomicReference<IFullDataSourceRetrievalQueue> worldGenQueueRef = new AtomicReference<>(null);
|
||||
@@ -172,6 +180,15 @@ public class GeneratedFullDataSourceProvider extends FullDataSourceProviderV2 im
|
||||
}
|
||||
|
||||
|
||||
ThreadPoolExecutor fileExecutor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (fileExecutor == null || fileExecutor.getQueue().size() >= MAX_UPDATE_TASK_COUNT / 2)
|
||||
{
|
||||
// don't queue additional world gen requests if the file handler is overwhelmed,
|
||||
// otherwise LODs may not load in properly
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int maxQueueCount = MAX_WORLD_GEN_REQUESTS_PER_THREAD * Config.Client.Advanced.MultiThreading.numberOfWorldGenerationThreads.get();
|
||||
|
||||
if (this.delayedFullDataSourceSaveCache.getUnsavedCount() >= maxQueueCount)
|
||||
|
||||
Reference in New Issue
Block a user