resource optimization work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-25 20:46:39 -04:00
parent 349986788b
commit f49e87261a
4 changed files with 26 additions and 11 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": "-Xmx6G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=5G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.hprof\"", "vmArgs": "-Xmx8G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=7G -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": "-Xmx6G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=5G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.hprof\"", "vmArgs": "-Xmx8G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=7G -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": "-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", "vmArgs": "-Xmx8G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=7G -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": "-Xmx6G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=5G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.hprof\"", "vmArgs": "-Xmx8G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=7G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.hprof\"",
"projectName": "Renderer" "projectName": "Renderer"
}, },
{ {

View File

@ -1994,6 +1994,8 @@ Performance improvements
- Client leverages block chunk short pool - Client leverages block chunk short pool
- Client doesn't load physics on entities by default - Client doesn't load physics on entities by default
- Block chunk disk map writes files without allocating a buffer - Block chunk disk map writes files without allocating a buffer
- Increase memory limit 6GB->8GB
- Server block chunk disk map writes directly to output stream instead of inbetween buffer
Increase human move speed Increase human move speed
LOD components re-attach physics LOD components re-attach physics
VectorPool->JomlPool VectorPool->JomlPool

View File

@ -3,6 +3,7 @@ package electrosphere.server.physics.block.diskmap;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ShortBuffer; import java.nio.ShortBuffer;
import java.util.HashMap; import java.util.HashMap;
@ -216,11 +217,10 @@ public class ServerBlockChunkDiskMap {
fileName = BLOCK_DATA_DIR + chunkKey + "b.dat"; fileName = BLOCK_DATA_DIR + chunkKey + "b.dat";
} }
//compress //compress
ByteArrayOutputStream out = new ByteArrayOutputStream();
DeflaterOutputStream deflaterOutStream = new DeflaterOutputStream(out);
DataOutputStream dataOut = new DataOutputStream(deflaterOutStream);
try { try {
OutputStream out = FileUtils.getBinarySavePathOutputStream(Globals.serverState.currentSave.getName(), fileName);
DeflaterOutputStream deflaterOutStream = new DeflaterOutputStream(out);
DataOutputStream dataOut = new DataOutputStream(deflaterOutStream);
//generate binary for the file //generate binary for the file
short[] type = chunkData.getType(); short[] type = chunkData.getType();
@ -244,11 +244,10 @@ public class ServerBlockChunkDiskMap {
dataOut.writeShort(chunkData.getHomogenousValue()); dataOut.writeShort(chunkData.getHomogenousValue());
} }
//flush and close
dataOut.flush(); dataOut.flush();
dataOut.close(); dataOut.close();
//write to disk
FileUtils.saveBinaryToSavePath(Globals.serverState.currentSave.getName(), fileName, out.toByteArray());
//save to the map of filenames //save to the map of filenames
worldPosFileMap.put(chunkKey,fileName); worldPosFileMap.put(chunkKey,fileName);
} catch (IOException e) { } catch (IOException e) {

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable; import java.io.Serializable;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.SeekableByteChannel; import java.nio.channels.SeekableByteChannel;
@ -401,6 +402,19 @@ public class FileUtils {
} }
} }
/**
* Opens an output straem to a binary file in a save directory
* @param saveName The save name
* @param pathName The path name to the file
* @return The output stream
*/
public static OutputStream getBinarySavePathOutputStream(String saveName, String pathName) throws IOException {
String sanitizedFilePath = FileUtils.sanitizeFilePath(pathName);
File file = FileUtils.getSaveFile(saveName,sanitizedFilePath);
Files.createDirectories(file.getParentFile().toPath());
return Files.newOutputStream(file.toPath());
}
/** /**
* Checks if a given file exists in a given save * Checks if a given file exists in a given save
* @param saveName the name of the save * @param saveName the name of the save