Skip to content

Instantly share code, notes, and snippets.

@Obydux
Last active May 10, 2024 00:42
Show Gist options
  • Star 198 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Obydux/55b967f5dcc00633fe895e5a473363d5 to your computer and use it in GitHub Desktop.
Save Obydux/55b967f5dcc00633fe895e5a473363d5 to your computer and use it in GitHub Desktop.
Fabric/Quilt Server Optimization

Fabric/Quilt Server Optimization

This has updated for 1.20.4, all of the optimization mods mentioned here are compatible with each other and don't affect vanilla behaviour by default.

Mods

Lithium - A mod designed to drastically improve the general performance of Minecraft without breaking things.

VMP - A mod designed to improve general server performance at high playercount.

C2ME - A mod designed to improve the performance of chunk generation, I/O, and loading. This is done by taking advantage of multiple CPU cores in parallel.

Starlight - A mod that rewrites the light engine to fix lighting performance and lighting errors. (Only useful if using C2ME).

FerriteCore - A mod that reduces the memory usage of Minecraft in a few different ways.

Krypton - A mod that optimizes the Minecraft networking stack and entity tracker.

Noisium - A mod that optimises world generation performance. The improvements lie between a 20-30% speedup when generating new chunks.

RecipeCooldown - A mod that prevents excessive crafting recipe request from the client to lag out the server.

MC-249136 Fix - A mod that implements a minimal hacky fix for MC-249136, a significant server lag spike that occurs when locating buried treasure structures for shipwreck loot.

Other useful mods

Chunky Pregenerator - A mod which pre-generates chunks, quickly and efficiently.

Spark - A performance profiler mod.

View Distance Fix - A mod that fixes the fog when having a higher render distance on the client than on the server. The server tricks the client into thinking that it has the same render distance as the client.

LibreExpFix - A small mod that fixes experience bug after teleporting across dimensions.

Disable Portal Checks - Disables unnecessary portal checks that causes lag.

Ledger = A logging mod similar to CoreProtect.

Carpet - A mod for vanilla Minecraft that allows you to take full control of what matters from a technical perspective of the game.

Carpet Extra - A mod that adds extra features to the Carpet mod.

Configurations

server.properties

sync-chunk-writes=false
max-chained-neighbor-updates=10000
simulation-distance should ideally be 8 if you want all types farms to work as intended, but lowering it will improve performance

Java optimization

JRE

Since 1.18 Minecraft requires Java 17 to run. If you don't have Java 17 installed already you can get it from here.

Java start-up flags

Generate a start-up script for your server here.
If you're using GraalVM you can try out my set of GraalVM start-up flags.

Hosting

I highly recommend BisectHosting for your server needs. They have 20 server locations, advanced DDoS protection and an user-friendly panel for server management. Use code OBYDUX to get 25% off! BisectHosting

@KistenPM
Copy link

KistenPM commented May 15, 2023

try jemalloc

I will, if only i could have understand what is it and how it works/installing. But i will try somehow. Thanks anyway

@wicivo
Copy link

wicivo commented May 15, 2023

try jemalloc

I will, if only i could have understand what is it and how it works/installing. But i will try somehow. Thanks anyway

One second

@wicivo
Copy link

wicivo commented May 15, 2023

@wicivo
Copy link

wicivo commented May 15, 2023

Look at this, I gave an example of how to use it

@kraoc
Copy link

kraoc commented May 15, 2023

Best flags I've compiled on my own :)

-server -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+AlwaysActAsServerClassMachine -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+DoEscapeAnalysis -XX:+EagerJVMCI -XX:+EliminateLocks -XX:+EnableJVMCI -XX:+EnableJVMCIProduct -XX:+OmitStackTraceInFastThrow -XX:+OptimizeStringConcat -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem -XX:+RangeCheckElimination -XX:+RewriteBytecodes -XX:+RewriteFrequentPairs -XX:+SegmentedCodeCache -XX:+TrustFinalNonStaticFields -XX:+UseAES -XX:+UseAESIntrinsics -XX:+UseCodeCacheFlushing -XX:+UseCompressedOops -XX:+UseCriticalJavaThreadPriority -XX:+UseCriticalJavaThreadPriority -XX:+UseFastJNIAccessors -XX:+UseFastUnorderedTimeStamps -XX:+UseFastUnorderedTimeStamps -XX:+UseFMA -XX:+UseFPUForSpilling -XX:+UseG1GC -XX:+UseInlineCaches -XX:+UseJVMCICompiler -XX:+UseLargePages -XX:+UseLoopPredicate -XX:+UseNUMA -XX:+UseStringDeduplication -XX:+UseThreadPriorities -XX:+UseTransparentHugePages -XX:+UseTransparentHugePages -XX:+UseVectorCmov -XX:+UseVectorCmov -XX:+UseXMMForArrayCopy -XX:AllocatePrefetchStyle=3 -XX:ConcGCThreads=2 -XX:-DontCompileHugeMethods -XX:G1HeapRegionSize=8M -XX:G1HeapWastePercent=5 -XX:G1MaxNewSizePercent=40 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1NewSizePercent=30 -XX:G1ReservePercent=20 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:InitiatingHeapOccupancyPercent=15 -XX:MaxGCPauseMillis=200 -XX:MaxNodeLimit=240000 -XX:MaxTenuringThreshold=1 -XX:NmethodSweepActivity=1 -XX:NodeLimitFudgeFactor=8000 -XX:NonNMethodCodeHeapSize=12M -XX:NonProfiledCodeHeapSize=194M -XX:ParallelGCThreads=8 -XX:ProfiledCodeHeapSize=194M -XX:ReservedCodeCacheSize=400M -XX:SurvivorRatio=32 -XX:ThreadPriorityPolicy=1 -Xlog:async -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/urandom -Djline.terminal=jline.UnsupportedTerminal -Dlog4j2.formatMsgNoLookups=true -Dterminal.ansi=true -Dterminal.jline=false -Djvmci.Compiler=graal -Daikars.new.flags=true -Dusing.aikars.flags=https://mcflags.emc.gs -Dgraal.CompilerConfiguration=enterprise -Dgraal.DetectInvertedLoopsAsCounted=true -Dgraal.EnterprisePartialUnroll=true -Dgraal.InfeasiblePathCorrelation=true -Dgraal.LoopInversion=true -Dgraal.OptDuplication=true -Dgraal.SpeculativeGuardMovement=true -Dgraal.StripMineNonCountedLoops=true -Dgraal.TuneInlinerExploration=1 -Dgraal.TuneInlinerExploration=1 -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.VectorizeHashes=true -Dgraal.VectorizeSIMD=true --add-modules=jdk.incubator.vector

Notice that "-XX:ParallelGCThreads=8" is bounded to your physical core and must be adapted.

@FoxieFlakey
Copy link

and here mine tuned for low end processors and small RAM (adapt the number 2 in first three flags to your cores count)

Note:

  1. This only works with OpenJ9 VM
  2. It creates 2 GB shared class cache (this can hugely improve startup on weaker processor by letting OpenJ9 AOT compile methods and saves information about various stuff not just class data)
-Xgcmaxthreads2 -XX:ParallelGCThreads=2 -XcompilationThreads2 -Xgcpolicy:gencon -XX:+IdleTuningGcOnIdle -XX:+UseAggressiveHeapShrink -XX:-OmitStackTraceInFastThrow -XX:+UseFastAccessorMethods -XX:+OptimizeStringConcat -Xshareclasses:allowClasspaths -Xaot -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=256 -Xshareclasses -Xscmx2000M -XX:SharedCacheHardLimit=2000M  -Xtune:virtualized -XX:+TieredCompilation -Dlog4j2.formatMsgNoLookups=true -XX:-DisableExplicitGC -XX:InitiatingHeapOccupancyPercent=60 -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=6 -XX:-ParallelRefProcEnabled -XX:+UseTLAB -XX:ReservedCodeCacheSize=70M -XX:+AdaptiveGCThreading -XX:+UseStringDeduplication -XX:-PortableShareCache -XX:+UseGCStartupHints -XX:+ShareUnsafeClasses -XX:+ShareAnonymousClasses -XX:ShareClassesEnableBCI -Xshareclasses:cacheRetransformed -Xshareclasses:enableBCI 

@KistenPM
Copy link

Look at this, I gave an example of how to use it

Such a big thanks for advices and help. But unfortunately, that doesn't helped me too.. Minecraft Still crashing via out of memory, even if it 16GB. Is it possible to limit somehow speed that generates chunks?

@wicivo
Copy link

wicivo commented May 19, 2023

Look at this, I gave an example of how to use it

Such a big thanks for advices and help. But unfortunately, that doesn't helped me too.. Minecraft Still crashing via out of memory, even if it 16GB. Is it possible to limit somehow speed that generates chunks?

Delete c2me

@wicivo
Copy link

wicivo commented May 19, 2023

Or report your problem to Ishland(c2me developer)

@wicivo
Copy link

wicivo commented May 19, 2023

I think he will try to help you.

@AlitaTeal
Copy link

From the Advancements Debug description: "THIS MOD IS NOT NEEDED ANYMORE AS OF MINECRAFT 1.19.4 - IT FIXED THE BUG."

@Leclowndu93150
Copy link

hi i guess i'll try to do some dark magic but do you think it an oracle server will be able to handle 100 players ?

@NotBadli
Copy link

Should I install those mods only on a server? Or should I also install them on clients?

@Xect0r
Copy link

Xect0r commented Jun 27, 2023

Should I install those mods only on a server? Or should I also install them on clients?

Some of them are client-side only and some are Server-side only (Some are both client and server-side). In some cases, the mod developer will mention whether it's necessary to run it on both ends or not (Some are optional but can help when running on both ends).

@booa12
Copy link

booa12 commented Jul 14, 2023

hello where do i put the flags i have fabric server i want to use those flags but i dont know where in the start.bat

@wicivo
Copy link

wicivo commented Jul 15, 2023

If you're on linux create a start.sh file or start.bat if on Windows and put "java -Xms10G -Xmx10G (insert those flags) -jar fabric-server-launch.jar" inside of it. Replace 10G with the amount of RAM in GB you would like your server to use (don't go above 12GB unless you need to)

If you're on linux create a start.sh file or start.bat if on Windows and put "java -Xms10G -Xmx10G (insert those flags) -jar fabric-server-launch.jar" inside of it. Replace 10G with the amount of RAM in GB you would like your server to use (don't go above 12GB unless you need to)

@booa12
Copy link

booa12 commented Jul 15, 2023

If you're on linux create a start.sh file or start.bat if on Windows and put "java -Xms10G -Xmx10G (insert those flags) -jar fabric-server-launch.jar" inside of it. Replace 10G with the amount of RAM in GB you would like your server to use (don't go above 12GB unless you need to)

If you're on linux create a start.sh file or start.bat if on Windows and put "java -Xms10G -Xmx10G (insert those flags) -jar fabric-server-launch.jar" inside of it. Replace 10G with the amount of RAM in GB you would like your server to use (don't go above 12GB unless you need to)

Ty

@booa12
Copy link

booa12 commented Jul 15, 2023

whitch one of thees should i download
image

@booa12
Copy link

booa12 commented Jul 15, 2023

and am i downloading the correct version

@Obydux
Copy link
Author

Obydux commented Jul 15, 2023

and am i downloading the correct version

I would suggest using Adoptium's version of Java : https://adoptium.net/temurin/releases/
Also yes, 17 is correct

@booa12
Copy link

booa12 commented Jul 15, 2023

and am i downloading the correct version

I would suggest using Adoptium's version of Java : https://adoptium.net/temurin/releases/ Also yes, 17 is correct

I want the graalvm i just want to know whitc one of those should i use the JDK or native image

@Obydux
Copy link
Author

Obydux commented Jul 15, 2023

and am i downloading the correct version

I would suggest using Adoptium's version of Java : https://adoptium.net/temurin/releases/ Also yes, 17 is correct

I want the graalvm i just want to know whitc one of those should i use the JDK or native image

Can't guarantee that mods will work correctly on Graal since I faced some issues before but you need the JDK if you want to be able to run the server

@booa12
Copy link

booa12 commented Jul 15, 2023

and am i downloading the correct version

I would suggest using Adoptium's version of Java : https://adoptium.net/temurin/releases/ Also yes, 17 is correct

I want the graalvm i just want to know whitc one of those should i use the JDK or native image

Can't guarantee that mods will work correctly on Graal since I faced some issues before but you need the JDK if you want to be able to run the server

So i need the jdk edition if it dosent work then 💀

@booa12
Copy link

booa12 commented Jul 15, 2023

I cant get the ee version

@booa12
Copy link

booa12 commented Jul 15, 2023

Should i use ce

@Obydux
Copy link
Author

Obydux commented Jul 15, 2023

Should i use ce

You don't need Graal

@booa12
Copy link

booa12 commented Jul 15, 2023

Should i use ce

You don't need Graal

Ok ill use adoptium

@RVZO6
Copy link

RVZO6 commented Aug 15, 2023

The JVM args specified in the guide make my RAM usage on pterodactyl max out, but not in game (using spark). I am very inexperienced in JVM args, so I have absolutely no idea what is wrong lol.

@wicivo
Copy link

wicivo commented Aug 15, 2023

The JVM args specified in the guide make my RAM usage on pterodactyl max out, but not in game (using spark). I am very inexperienced in JVM args, so I have absolutely no idea what is wrong lol.

Because the minimum value is the same as the maximum value

@IshanYe
Copy link

IshanYe commented Oct 18, 2023

What i

and here mine tuned for low end processors and small RAM (adapt the number 2 in first three flags to your cores count)

Note:

  1. This only works with OpenJ9 VM
  2. It creates 2 GB shared class cache (this can hugely improve startup on weaker processor by letting OpenJ9 AOT compile methods and saves information about various stuff not just class data)
-Xgcmaxthreads2 -XX:ParallelGCThreads=2 -XcompilationThreads2 -Xgcpolicy:gencon -XX:+IdleTuningGcOnIdle -XX:+UseAggressiveHeapShrink -XX:-OmitStackTraceInFastThrow -XX:+UseFastAccessorMethods -XX:+OptimizeStringConcat -Xshareclasses:allowClasspaths -Xaot -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=256 -Xshareclasses -Xscmx2000M -XX:SharedCacheHardLimit=2000M  -Xtune:virtualized -XX:+TieredCompilation -Dlog4j2.formatMsgNoLookups=true -XX:-DisableExplicitGC -XX:InitiatingHeapOccupancyPercent=60 -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=6 -XX:-ParallelRefProcEnabled -XX:+UseTLAB -XX:ReservedCodeCacheSize=70M -XX:+AdaptiveGCThreading -XX:+UseStringDeduplication -XX:-PortableShareCache -XX:+UseGCStartupHints -XX:+ShareUnsafeClasses -XX:+ShareAnonymousClasses -XX:ShareClassesEnableBCI -Xshareclasses:cacheRetransformed -Xshareclasses:enableBCI 

How can I use this? And what is it? I'm new to servers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment