configuration for cache size
This commit is contained in:
@@ -24,8 +24,9 @@ public class VoxyConfig {
|
||||
public boolean ingestEnabled = true;
|
||||
//public int renderDistance = 128;
|
||||
public int serviceThreads = Math.max(Runtime.getRuntime().availableProcessors()/2, 1);
|
||||
public float subDivisionSize = 128;
|
||||
public int secondaryLruCacheSize = 4096;
|
||||
public String defaultSaveConfig;
|
||||
public int subDivisionSize = 128;
|
||||
//public int renderQuality = 256;//Smaller is higher quality
|
||||
|
||||
|
||||
|
||||
@@ -66,12 +66,17 @@ public class VoxyConfigScreenFactory implements ModMenuApi {
|
||||
.setDefaultValue(DEFAULT.ingestEnabled)
|
||||
.build());
|
||||
|
||||
category.addEntry(entryBuilder.startIntSlider(Text.translatable("voxy.config.general.subDivisionSize"), config.subDivisionSize, 25, 256)
|
||||
category.addEntry(entryBuilder.startIntSlider(Text.translatable("voxy.config.general.subDivisionSize"), (int) config.subDivisionSize, 25, 256)
|
||||
.setTooltip(Text.translatable("voxy.config.general.subDivisionSize.tooltip"))
|
||||
.setSaveConsumer(val -> config.subDivisionSize = val)
|
||||
.setDefaultValue(DEFAULT.subDivisionSize)
|
||||
.setDefaultValue((int) DEFAULT.subDivisionSize)
|
||||
.build());
|
||||
|
||||
category.addEntry(entryBuilder.startIntSlider(Text.translatable("voxy.config.general.lruCacheSize"), config.secondaryLruCacheSize, 16, 1<<13)
|
||||
.setTooltip(Text.translatable("voxy.config.general.lruCacheSize.tooltip"))
|
||||
.setSaveConsumer(val ->{if (config.secondaryLruCacheSize != val) reload(); config.secondaryLruCacheSize = val;})
|
||||
.setDefaultValue(DEFAULT.secondaryLruCacheSize)
|
||||
.build());
|
||||
|
||||
category.addEntry(entryBuilder.startIntSlider(Text.translatable("voxy.config.general.serviceThreads"), config.serviceThreads, 1, Runtime.getRuntime().availableProcessors())
|
||||
.setTooltip(Text.translatable("voxy.config.general.serviceThreads.tooltip"))
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ContextSelectionSystem {
|
||||
}
|
||||
|
||||
public WorldEngine createEngine(ServiceThreadPool serviceThreadPool) {
|
||||
return new WorldEngine(this.createStorageBackend(), serviceThreadPool);
|
||||
return new WorldEngine(this.createStorageBackend(), serviceThreadPool, VoxyConfig.CONFIG.secondaryLruCacheSize);
|
||||
}
|
||||
|
||||
//Saves the config for the world selection or something, need to figure out how to make it work with dimensional configs maybe?
|
||||
|
||||
@@ -112,8 +112,9 @@ public class ActiveSectionTracker {
|
||||
var cache = this.loadedSectionCache[index];
|
||||
synchronized (cache) {
|
||||
if (section.trySetFreed()) {
|
||||
if (cache.remove(section.key).obj != section) {
|
||||
throw new IllegalStateException("Removed section not the same as the referenced section in the cache");
|
||||
var cached = cache.remove(section.key);
|
||||
if (cached.obj != section) {
|
||||
throw new IllegalStateException("Removed section not the same as the referenced section in the cache: cached: " + cached.obj.key + "got: " + section.key);
|
||||
}
|
||||
|
||||
//Add section to secondary cache while primary is locked
|
||||
|
||||
@@ -39,16 +39,16 @@ public class WorldEngine {
|
||||
public Mapper getMapper() {return this.mapper;}
|
||||
|
||||
|
||||
public WorldEngine(StorageBackend storageBackend, ServiceThreadPool serviceThreadPool) {
|
||||
this(storageBackend, serviceThreadPool, MAX_LOD_LAYERS);
|
||||
public WorldEngine(StorageBackend storageBackend, ServiceThreadPool serviceThreadPool, int cacheCount) {
|
||||
this(storageBackend, serviceThreadPool, MAX_LOD_LAYERS, cacheCount);
|
||||
}
|
||||
|
||||
private WorldEngine(StorageBackend storageBackend, ServiceThreadPool serviceThreadPool, int maxMipLayers) {
|
||||
private WorldEngine(StorageBackend storageBackend, ServiceThreadPool serviceThreadPool, int maxMipLayers, int cacheCount) {
|
||||
this.maxMipLevels = maxMipLayers;
|
||||
this.storage = storageBackend;
|
||||
this.mapper = new Mapper(this.storage);
|
||||
//4 cache size bits means that the section tracker has 16 separate maps that it uses
|
||||
this.sectionTracker = new ActiveSectionTracker(4, this::unsafeLoadSection, 1<<12);//1 gb of cpu section cache
|
||||
this.sectionTracker = new ActiveSectionTracker(4, this::unsafeLoadSection, cacheCount);
|
||||
|
||||
this.savingService = new SectionSavingService(this, serviceThreadPool);
|
||||
this.ingestService = new VoxelIngestService(this, serviceThreadPool);
|
||||
|
||||
Reference in New Issue
Block a user