feat: add java optimisation flags
parent
c32741bbc9
commit
640364405f
|
@ -1,2 +1,2 @@
|
||||||
[alias]
|
[alias]
|
||||||
runs = "run -- paper --config data/config --backup data/backups --world data/worlds --jar data/paper.jar"
|
runs = "run -- paper 1.19.4-545 --config data/config --backup data/backups --world data/worlds --jar data/paper.jar"
|
||||||
|
|
|
@ -113,16 +113,57 @@ impl ServerCommand {
|
||||||
let backup_dir = self.backup_dir.canonicalize()?;
|
let backup_dir = self.backup_dir.canonicalize()?;
|
||||||
|
|
||||||
self.accept_eula()?;
|
self.accept_eula()?;
|
||||||
|
let mut cmd = Command::new(&self.java);
|
||||||
|
|
||||||
let child = Command::new(&self.java)
|
// Apply JVM optimisation flags
|
||||||
.current_dir(&config_dir)
|
// https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/
|
||||||
|
cmd.arg(format!("-Xms{}M", self.xms))
|
||||||
|
.arg(format!("-Xmx{}M", self.xmx))
|
||||||
|
.args([
|
||||||
|
"-XX:+UseG1GC",
|
||||||
|
"-XX:+ParallelRefProcEnabled",
|
||||||
|
"-XX:MaxGCPauseMillis=200",
|
||||||
|
"-XX:+UnlockExperimentalVMOptions",
|
||||||
|
"-XX:+DisableExplicitGC",
|
||||||
|
"-XX:+AlwaysPreTouch",
|
||||||
|
"-XX:G1HeapWastePercent=5",
|
||||||
|
"-XX:G1MixedGCCountTarget=4",
|
||||||
|
"-XX:G1MixedGCLiveThresholdPercent=90",
|
||||||
|
"-XX:G1RSetUpdatingPauseTimePercent=5",
|
||||||
|
"-XX:SurvivorRatio=32",
|
||||||
|
"-XX:+PerfDisableSharedMem",
|
||||||
|
"-XX:MaxTenuringThreshold=1",
|
||||||
|
"-Dusing.aikars.flags=https://mcflags.emc.gs",
|
||||||
|
"-Daikars.new.flags=true",
|
||||||
|
]);
|
||||||
|
|
||||||
|
if self.xms > 12 * 1024 {
|
||||||
|
cmd.args([
|
||||||
|
"-XX:G1NewSizePercent=40",
|
||||||
|
"-XX:G1MaxNewSizePercent=50",
|
||||||
|
"-XX:G1HeapRegionSize=16M",
|
||||||
|
"-XX:G1ReservePercent=15",
|
||||||
|
"-XX:InitiatingHeapOccupancyPercent=20",
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
cmd.args([
|
||||||
|
"-XX:G1NewSizePercent=30",
|
||||||
|
"-XX:G1MaxNewSizePercent=40",
|
||||||
|
"-XX:G1HeapRegionSize=8M",
|
||||||
|
"-XX:G1ReservePercent=15",
|
||||||
|
"-XX:InitiatingHeapOccupancyPercent=15",
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.current_dir(&config_dir)
|
||||||
.arg("-jar")
|
.arg("-jar")
|
||||||
.arg(&jar)
|
.arg(&jar)
|
||||||
.arg("--universe")
|
.arg("--universe")
|
||||||
.arg(&world_dir)
|
.arg(&world_dir)
|
||||||
.arg("--nogui")
|
.arg("--nogui")
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped());
|
||||||
.spawn()?;
|
|
||||||
|
let child = cmd.spawn()?;
|
||||||
|
|
||||||
Ok(ServerProcess::new(
|
Ok(ServerProcess::new(
|
||||||
self.type_,
|
self.type_,
|
||||||
|
|
Loading…
Reference in New Issue