increase memory budget
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-03-30 16:44:56 -04:00
parent 86b0de24e6
commit 9c6333108d
6 changed files with 43 additions and 14 deletions

8
.vscode/launch.json vendored
View File

@ -6,7 +6,7 @@
"name": "Launch Current File", "name": "Launch Current File",
"request": "launch", "request": "launch",
"mainClass": "${file}", "mainClass": "${file}",
"vmArgs": "-Xmx4G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=3G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.hprof\"", "vmArgs": "-Xmx6G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=5G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.hprof\"",
"preLaunchTask": "Install Native Lib" "preLaunchTask": "Install Native Lib"
}, },
{ {
@ -14,7 +14,7 @@
"name": "Launch Main", "name": "Launch Main",
"request": "launch", "request": "launch",
"mainClass": "electrosphere.engine.Main", "mainClass": "electrosphere.engine.Main",
"vmArgs": "-Xmx4G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=3G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.hprof\"", "vmArgs": "-Xmx6G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=5G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.hprof\"",
"projectName": "Renderer", "projectName": "Renderer",
"preLaunchTask": "Install Native Lib" "preLaunchTask": "Install Native Lib"
}, },
@ -23,7 +23,7 @@
"name": "Launch Main (Debug Memory)", "name": "Launch Main (Debug Memory)",
"request": "launch", "request": "launch",
"mainClass": "electrosphere.engine.Main", "mainClass": "electrosphere.engine.Main",
"vmArgs": "-Xmx4G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=3G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.hprof\" -javaagent:./lwjglx-debug-1.0.0.jar=t;o=trace.log", "vmArgs": "-Xmx6G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=5G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.hprof\" -javaagent:./lwjglx-debug-1.0.0.jar=t;o=trace.log",
"projectName": "Renderer", "projectName": "Renderer",
"preLaunchTask": "Install Native Lib" "preLaunchTask": "Install Native Lib"
}, },
@ -35,7 +35,7 @@
"env": { "env": {
"ALSOFT_LOGLEVEL": 4 "ALSOFT_LOGLEVEL": 4
}, },
"vmArgs": "-Xmx4G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=3G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.hprof\"", "vmArgs": "-Xmx6G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=5G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.hprof\"",
"projectName": "Renderer" "projectName": "Renderer"
}, },
{ {

View File

@ -1392,6 +1392,8 @@ TransvoxelModelGeneration allocation reduction
More allocation reduction More allocation reduction
Vector pooling Vector pooling
Simplify WorldOctTree to reduce lag with large node counts Simplify WorldOctTree to reduce lag with large node counts
Increase memory allowance, mostly fixed latency while walking around
AssetManager streaming budget

View File

@ -78,6 +78,11 @@ public class AssetManager {
//assets queued to be loaded //assets queued to be loaded
ReentrantLock queuedAssetLock = new ReentrantLock(); ReentrantLock queuedAssetLock = new ReentrantLock();
List<QueuedAsset<?>> queuedAssets = new LinkedList<QueuedAsset<?>>(); List<QueuedAsset<?>> queuedAssets = new LinkedList<QueuedAsset<?>>();
/**
* Maximum number of queued assets that can be loaded per frame
*/
public static final int MAX_ASSETS_PER_FRAME = 50;
@ -174,15 +179,27 @@ public class AssetManager {
LoggerInterface.loggerEngine.DEBUG_LOOP("AssetManager - Load queued assets"); LoggerInterface.loggerEngine.DEBUG_LOOP("AssetManager - Load queued assets");
Globals.profiler.beginCpuSample("AssetManager.loadAssetsInQueue - Load queued assets"); Globals.profiler.beginCpuSample("AssetManager.loadAssetsInQueue - Load queued assets");
queuedAssetLock.lock(); queuedAssetLock.lock();
for(QueuedAsset<?> queuedAsset : queuedAssets){ if(queuedAssets.size() > MAX_ASSETS_PER_FRAME){
queuedAsset.load(); for(int i = 0; i < MAX_ASSETS_PER_FRAME; i++){
if(queuedAsset.get() instanceof Model){ QueuedAsset<?> queuedAsset = queuedAssets.remove(0);
this.modelsLoadedIntoMemory.put(queuedAsset.getPromisedPath(),(Model)queuedAsset.get()); queuedAsset.load();
} else if(queuedAsset.get() instanceof Texture){ if(queuedAsset.get() instanceof Model){
this.texturesLoadedIntoMemory.put(queuedAsset.getPromisedPath(),(Texture)queuedAsset.get()); this.modelsLoadedIntoMemory.put(queuedAsset.getPromisedPath(),(Model)queuedAsset.get());
} else if(queuedAsset.get() instanceof Texture){
this.texturesLoadedIntoMemory.put(queuedAsset.getPromisedPath(),(Texture)queuedAsset.get());
}
} }
} else {
for(QueuedAsset<?> queuedAsset : queuedAssets){
queuedAsset.load();
if(queuedAsset.get() instanceof Model){
this.modelsLoadedIntoMemory.put(queuedAsset.getPromisedPath(),(Model)queuedAsset.get());
} else if(queuedAsset.get() instanceof Texture){
this.texturesLoadedIntoMemory.put(queuedAsset.getPromisedPath(),(Texture)queuedAsset.get());
}
}
queuedAssets.clear();
} }
queuedAssets.clear();
queuedAssetLock.unlock(); queuedAssetLock.unlock();
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();

View File

@ -9,7 +9,6 @@ import electrosphere.logger.LoggerInterface;
import electrosphere.util.annotation.Exclude; import electrosphere.util.annotation.Exclude;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;

View File

@ -5,6 +5,7 @@ import electrosphere.entity.state.AnimationPriorities;
import electrosphere.game.data.common.treedata.TreeDataAnimation; import electrosphere.game.data.common.treedata.TreeDataAnimation;
import electrosphere.game.data.creature.type.bonegroups.BoneGroup; import electrosphere.game.data.creature.type.bonegroups.BoneGroup;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.mem.VectorPool;
import electrosphere.renderer.OpenGLState; import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState; import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.actor.ActorUniformMap.UniformValue; import electrosphere.renderer.actor.ActorUniformMap.UniformValue;
@ -738,8 +739,9 @@ public class Actor {
} }
Globals.profiler.beginAggregateCpuSample("Actor.isWithinFrustumBox"); Globals.profiler.beginAggregateCpuSample("Actor.isWithinFrustumBox");
Sphered sphere = model.getBoundingSphere(); Sphered sphere = model.getBoundingSphere();
Vector3d modelPosition = model.getModelMatrix().getTranslation(new Vector3d()); Vector3d modelPosition = model.getModelMatrix().getTranslation(VectorPool.getD());
boolean check = renderPipelineState.getFrustumIntersection().testSphere((float)(sphere.x + modelPosition.x), (float)(sphere.y + modelPosition.y), (float)(sphere.z + modelPosition.z), (float)sphere.r); boolean check = renderPipelineState.getFrustumIntersection().testSphere((float)(sphere.x + modelPosition.x), (float)(sphere.y + modelPosition.y), (float)(sphere.z + modelPosition.z), (float)sphere.r);
VectorPool.release(modelPosition);
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
return check; return check;
} }

View File

@ -609,7 +609,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
Collection<ServerDataCell> groundCells = this.groundDataCells.values(); Collection<ServerDataCell> groundCells = this.groundDataCells.values();
boolean runMicroSim = Globals.microSimulation != null && Globals.microSimulation.isReady(); boolean runMicroSim = Globals.microSimulation != null && Globals.microSimulation.isReady();
for(ServerDataCell cell : groundCells){ for(ServerDataCell cell : groundCells){
if(runMicroSim){ if(runMicroSim && this.shouldSimulate(cell)){
Globals.microSimulation.simulate(cell); Globals.microSimulation.simulate(cell);
} }
@ -639,6 +639,15 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
} }
/**
* Checks if a server data cell should be simulated or not
* @param cell The cell
* @return true if it should be simulated, false otherwise
*/
private boolean shouldSimulate(ServerDataCell cell){
return cell.getPlayers().size() > 0;
}
/** /**
* Gets the server terrain manager for this realm if it exists * Gets the server terrain manager for this realm if it exists