performance tweaks (zgc, sysctl, jvmopts, etc)
All checks were successful
Activate Homelab Configuration / rebuild (push) Successful in 59s

This commit is contained in:
Satria 2026-05-08 16:33:02 +07:00
commit 37867492a9

View file

@ -1,6 +1,5 @@
{ inputs, lib, pkgs, ... }: let { inputs, lib, pkgs, ... }: let
ram-allocation = "10240M"; ram-allocation-mb = 12288;
# auth-server = "https://mc.satr14.my.id"; # TODO: self hosted drasl server
modpack = let modpack = let
commit = "667aadf36aac9b0689289f4988a76b924bbb9cbc"; commit = "667aadf36aac9b0689289f4988a76b924bbb9cbc";
in pkgs.fetchPackwizModpack { in pkgs.fetchPackwizModpack {
@ -11,6 +10,12 @@ in {
imports = [ inputs.mc.nixosModules.minecraft-servers ]; imports = [ inputs.mc.nixosModules.minecraft-servers ];
nixpkgs.overlays = [ inputs.mc.overlay ]; nixpkgs.overlays = [ inputs.mc.overlay ];
powerManagement.cpuFreqGovernor = "schedutil";
boot.kernel.sysctl = {
"vm.nr_hugepages" = 6656;
"vm.swappiness" = 10;
};
services.minecraft-servers = { services.minecraft-servers = {
enable = true; enable = true;
eula = true; eula = true;
@ -21,54 +26,34 @@ in {
enable = true; enable = true;
autoStart = true; autoStart = true;
restart = "always"; restart = "always";
enableReload = false; # NOTE: development phase, disable in production enableReload = true; # NOTE: development phase, disable in production
package = pkgs.fabricServers.fabric-1_21_11.override { package = pkgs.fabricServers.fabric-1_21_11.override {
jre_headless = pkgs.javaPackages.compiler.temurin-bin.jre-25; jre_headless = pkgs.javaPackages.compiler.temurin-bin.jdk-25;
loaderVersion = "0.19.2"; loaderVersion = "0.19.2";
}; };
jvmOpts = let jvmOpts = let flags = [
flags = [ "-Xms${toString ram-allocation-mb}M"
"-Xms${ram-allocation}" "-Xmx${toString ram-allocation-mb}M"
"-Xmx${ram-allocation}"
# Exposes SIMD instructions (requires full JDK, useful with performance mods)
"--add-modules=jdk.incubator.vector" "--add-modules=jdk.incubator.vector"
# Custom auth server # ZGC flags (requires Java v25+, 8+ CPU cores, 10GB+ RAM)
# "-Dminecraft.api.env=custom" "-XX:+UseZGC"
# "-Dminecraft.api.auth.host=${auth-server}/auth" "-XX:+UseLargePages"
# "-Dminecraft.api.account.host=${auth-server}/account"
# "-Dminecraft.api.profiles.host=${auth-server}/account"
# "-Dminecraft.api.session.host=${auth-server}/session"
# "-Dminecraft.api.services.host=${auth-server}/services"
# Aikar's GC flags (tuned for 10GB)
"-XX:+UseG1GC"
"-XX:+ParallelRefProcEnabled"
"-XX:MaxGCPauseMillis=200"
"-XX:+UnlockExperimentalVMOptions"
"-XX:+DisableExplicitGC"
"-XX:+AlwaysPreTouch" "-XX:+AlwaysPreTouch"
"-XX:G1HeapWastePercent=5" "-XX:+DisableExplicitGC"
"-XX:G1MixedGCCountTarget=4"
"-XX:InitiatingHeapOccupancyPercent=15"
"-XX:G1MixedGCLiveThresholdPercent=90"
"-XX:G1RSetUpdatingPauseTimePercent=5"
"-XX:SurvivorRatio=32"
"-XX:+PerfDisableSharedMem" "-XX:+PerfDisableSharedMem"
"-XX:MaxTenuringThreshold=1" "-XX:+UseCompactObjectHeaders"
"-Dusing.aikars.flags=https://mcflags.emc.gs" "-XX:ZAllocationSpikeTolerance=5"
"-Daikars.new.flags=true" "-XX:SoftMaxHeapSize=${toString (ram-allocation-mb - 2048)}M"
"-XX:G1NewSizePercent=30" ]; in lib.concatStringsSep " " flags;
"-XX:G1MaxNewSizePercent=40"
"-XX:G1HeapRegionSize=8M"
"-XX:G1ReservePercent=20"
];
in lib.concatStringsSep " " flags;
serverProperties = { serverProperties = {
server-port = 25565; server-port = 25565;
server-name = "Digit Association"; server-name = "Minecraft Server";
motd = "§lSeason 3 TESTING§r - §dExplorers Creativity 🔥"; motd = "§lSeason 3 TESTING§r - §dExplorers Creativity 🔥";
difficulty = "normal"; difficulty = "normal";
@ -88,7 +73,7 @@ in {
# resource-pack-sha1 = "e0958dcef5755286f390c22280700c471ec34a65"; # resource-pack-sha1 = "e0958dcef5755286f390c22280700c471ec34a65";
# resource-pack-enforce = false; # resource-pack-enforce = false;
simulation-distance = 16; simulation-distance = 12;
view-distance = 4; view-distance = 4;
enable-rcon = true; enable-rcon = true;