└── README.md /README.md: -------------------------------------------------------------------------------- 1 | ### ***v2flags*** is a blazing fast set of arguments for best in class JVM performance. 2 | (though your most likely reading this for Minecraft performance) 3 | 4 | Quick Start 5 | ================= 6 | If you quickly want to get to a specific set of flags, since this list is slightly cluttered. 7 | * [Why not Aikar's flags?](#why-not-just-use-aikars-flags) 8 | * [For Who?](#who-should-use-these-flags) 9 | * [Stability + Risks](#stability--risks) 10 | * [Flags](#flags) 11 | * [Server](#server-zgc) 12 | * [Pterodactyl](#pterodactyl-zgc) 13 | * [High End Client](#high-end-client-zgc) 14 | * [Low End Client](#low-end-client-g1gc) 15 | * [(terrible) Explanation](#explanation) 16 | 17 | ## Why not just use [Aikar](https://github.com/aikar)'s flags? 18 | Their GC is based on G1, it's extremely stable but extremely slow, so why should current gen servers be held back by last gen algorithms? 19 | 20 | I propose to get rid of it in favor of [ZGC](https://github.com/openjdk/zgc), why? It clears memory alongside the server instead of pausing it each time, and it's wicked fast. 21 | 22 | ## Who should use these flags? 23 | Modded servers or large networks will generally benefit the most from performance flags with increased performance and fewer TPS spikes, 24 | 25 | Even smaller servers with weaker hardware can see great performance uplifts, 26 | 27 | Pterodactyl server administrators can also receive an extremely fast egg to run JVM servers with, 28 | 29 | And clients can get multiple orders of magnitude better performance and less hitches with client flags. 30 | 31 | When using these flags you should try to use [GraalVM Community JDK 22](https://www.graalvm.org/downloads/) as your java runtime, 32 |
33 | Whether your a server, or a client. These flags won't see as much of a gain without it as it tweaks this JDK heavily. 34 | 35 | ## Stability + Risks 36 | These flags have been rigorously tested to hell and back on Protobit for 1 year, and no instability problems have occured as a result of these flags being used so far, only uplifts in performance and consistancy. 37 | 38 | 39 | However keep in mind that your experience with these will differ due to various hardware configurations and they haven't been dragged through the slums like Aikar's flags. 40 | 41 | 42 | ***Use them at your own risk.*** You are on your own and Cooperly or anybody involved are not responsible for any damages such as crashes or instability that come as a result of using these flags. 43 | 44 | ## Flags 45 | - [x] [Vanilla](https://www.minecraft.net/en-us/download/server) (Not recommended, use [Leaf](https://github.com/Winds-Studio/Leaf), or at the very least [Paper](https://github.com/PaperMC/Paper).) 46 | - [x] [Leaf](https://github.com/Winds-Studio/Leaf) / [Paper](https://github.com/PaperMC/Paper) 47 | - [x] [Folia](https://github.com/PaperMC/Folia) 48 | - [x] [Fabric](https://github.com/FabricMC) 49 | - [x] [Quilt](https://github.com/QuiltMC) 50 | - [x] [Forge](https://github.com/MinecraftForge/MinecraftForge) 51 | - [x] [NeoForge](https://github.com/neoforged/NeoForge) 52 | - [x] Most JVM server software, even non-minecraft (No guarantee, not recommended.) 53 | 54 | Experiment: 55 |
56 | I've set -XX:AllocatePrefetchStyle to 3 instead of 1 on flags based on ZGC, some people say it's unsupported but it seems to be running okay, so either it's being silently dropped, or it's netting a bit of extra performance 57 | 58 | If you experience any problems, set it back to 1 and create a pull request changing the value, thanks. 59 | 60 | ### ***Server, ZGC:*** 61 | 62 | Use these flags on a server running either bare metal, or in a container. (Not in Pterodactyl, scroll down.) 63 | 64 | *Don't forget to adjust -Xms and -Xmx to your server configuration, along with java path and server.jar if applicable* 65 | 66 | ```java 67 | java -Xms8G -Xmx8G -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+UseZGC -XX:-ZUncommit -XX:-ZProactive -Dterminal.jline=false -Dterminal.ansi=true -Djline.terminal=jline.UnsupportedTerminal -Dlog4j2.formatMsgNoLookups=true -XX:+AlwaysActAsServerClassMachine -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+UseNUMA -XX:NmethodSweepActivity=1 -XX:ReservedCodeCacheSize=400M -XX:NonNMethodCodeHeapSize=12M -XX:ProfiledCodeHeapSize=194M -XX:NonProfiledCodeHeapSize=194M -XX:+PerfDisableSharedMem -XX:+UseFastUnorderedTimeStamps -XX:+UseCriticalJavaThreadPriority -XX:+EagerJVMCI -Dgraal.TuneInlinerExploration=1 -XX:+ParallelRefProcEnabled -XX:InitiatingHeapOccupancyPercent=15 -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=1 -XX:-UseBiasedLocking -XX:+UseStringDeduplication -XX:+UseAES -XX:+UseAESIntrinsics -XX:+UseFMA -XX:+UseLoopPredicate -XX:+RangeCheckElimination -XX:+EliminateLocks -XX:+DoEscapeAnalysis -XX:+UseCodeCacheFlushing -XX:+SegmentedCodeCache -XX:+UseFastJNIAccessors -XX:+OptimizeStringConcat -XX:+UseCompressedOops -XX:+UseThreadPriorities -XX:+OmitStackTraceInFastThrow -XX:+TrustFinalNonStaticFields -XX:ThreadPriorityPolicy=1 -XX:+UseInlineCaches -XX:+RewriteBytecodes -XX:+RewriteFrequentPairs -XX:-DontCompileHugeMethods -XX:+UseFPUForSpilling -XX:AllocatePrefetchStyle=3 -XX:+UseFastStosb -XX:+UseNewLongLShift -XX:+UseVectorCmov -XX:+UseXMMForArrayCopy -XX:+UseXmmI2D -XX:+UseXmmI2F -XX:+UseXmmLoadAndClearUpper -XX:+UseXmmRegToRegMoveAll -XX:+UseLargePages -XX:LargePageSizeInBytes=2M -DPaper.IgnoreJavaVersion=true -Dfile.encoding=UTF-8 -Xlog:async -Djava.security.egd=file:/dev/urandom --add-modules jdk.incubator.vector -jar server.jar –-nogui 68 | ``` 69 | 70 | ### ***Pterodactyl, ZGC:*** 71 | 72 | Use these flags on Pterodactyl Panel, This is primarily for administrators, customers usually cannot change their server image or flags, however you could ask and link your host's support team to this repository if you really wish to persist for some reason. 73 | 74 | Get the [GraalVM Template](https://github.com/Cooperly/v2flags/releases/download/v1.0e/Pterodactyl.json) egg and add your server.jar manually 75 | 76 | Adjust CUTDOWN in startup settings to how much memory you want to reserve to the system to prevent OOMKilling, usually 1-4G should be enough depending on the load. 77 | 78 | If you wish to not reserve memory to the OS for some reason, (i paid for all my ram sticks boy) at least adjust swap accordingly, preferably to -1 (you could net some performance loss) 79 | 80 | ```java 81 | java -Xms$(({{SERVER_MEMORY}} - ({{CUTDOWN}})))M -Xmx$(({{SERVER_MEMORY}} - ({{CUTDOWN}})))M -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+UseZGC -XX:-ZUncommit -XX:-ZProactive -Dterminal.jline=false -Dterminal.ansi=true -Djline.terminal=jline.UnsupportedTerminal -Dlog4j2.formatMsgNoLookups=true -XX:+AlwaysActAsServerClassMachine -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+UseNUMA -XX:NmethodSweepActivity=1 -XX:ReservedCodeCacheSize=400M -XX:NonNMethodCodeHeapSize=12M -XX:ProfiledCodeHeapSize=194M -XX:NonProfiledCodeHeapSize=194M -XX:+PerfDisableSharedMem -XX:+UseFastUnorderedTimeStamps -XX:+UseCriticalJavaThreadPriority -XX:+EagerJVMCI -XX:+ParallelRefProcEnabled -XX:InitiatingHeapOccupancyPercent=15 -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=1 -XX:+UseStringDeduplication -XX:+UseAES -XX:+UseAESIntrinsics -XX:+UseFMA -XX:+UseLoopPredicate -XX:+RangeCheckElimination -XX:+EliminateLocks -XX:+DoEscapeAnalysis -XX:+UseCodeCacheFlushing -XX:+SegmentedCodeCache -XX:+UseFastJNIAccessors -XX:+OptimizeStringConcat -XX:+UseCompressedOops -XX:+UseThreadPriorities -XX:+OmitStackTraceInFastThrow -XX:+TrustFinalNonStaticFields -XX:ThreadPriorityPolicy=1 -XX:+UseInlineCaches -XX:+RewriteBytecodes -XX:+RewriteFrequentPairs -XX:-DontCompileHugeMethods -XX:+UseFPUForSpilling -XX:AllocatePrefetchStyle=3 -XX:+UseFastStosb -XX:+UseNewLongLShift -XX:+UseXmmI2D -XX:+UseXmmI2F -XX:+UseXmmLoadAndClearUpper -XX:+UseXmmRegToRegMoveAll -XX:+UseVectorCmov -XX:+UseXMMForArrayCopy -XX:+UseLargePages -XX:LargePageSizeInBytes=2M -DPaper.IgnoreJavaVersion=true -Dfile.encoding=UTF-8 -Xlog:async -Djava.security.egd=file:/dev/urandom --add-modules jdk.incubator.vector -jar {{SERVER_JARFILE}} --nogui 82 | ``` 83 | 84 | ### ***High End Client, ZGC:*** 85 | 86 | Stupidly CPU intensive, you will lose a lot of performance if you are not equipped with a modernish CPU. 87 |
88 | Use these flags on a high end client that wants additional performance and less hitches, especially while using mods like ViveCraft. 89 |
90 | These are not as rigorously tested as the server flags, but no additional issues should arise under normal circumstances. 91 | 92 | You may also need to include -Xms6G and -Xmx6G (or whatever memory you want allocated) if you are running this on the vanilla launcher, (use Prism) This is primarily made for MultiMC based launchers (such as Prism) which disallow those values being present. 93 | 94 | ```java 95 | -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+UseZGC -XX:-ZUncommit -XX:-ZProactive -Dterminal.jline=false -Dterminal.ansi=true -Djline.terminal=jline.UnsupportedTerminal -Dlog4j2.formatMsgNoLookups=true -XX:+AlwaysActAsServerClassMachine -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+UseNUMA -XX:NmethodSweepActivity=1 -XX:ReservedCodeCacheSize=400M -XX:NonNMethodCodeHeapSize=12M -XX:ProfiledCodeHeapSize=194M -XX:NonProfiledCodeHeapSize=194M -XX:+PerfDisableSharedMem -XX:+UseFastUnorderedTimeStamps -XX:+UseCriticalJavaThreadPriority -XX:+EagerJVMCI -XX:+ParallelRefProcEnabled -XX:InitiatingHeapOccupancyPercent=15 -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=1 -XX:+UseStringDeduplication -XX:+UseAES -XX:+UseAESIntrinsics -XX:+UseFMA -XX:+UseLoopPredicate -XX:+RangeCheckElimination -XX:+EliminateLocks -XX:+DoEscapeAnalysis -XX:+UseCodeCacheFlushing -XX:+SegmentedCodeCache -XX:+UseFastJNIAccessors -XX:+OptimizeStringConcat -XX:+UseCompressedOops -XX:+UseThreadPriorities -XX:+OmitStackTraceInFastThrow -XX:+TrustFinalNonStaticFields -XX:ThreadPriorityPolicy=1 -XX:+UseInlineCaches -XX:+RewriteBytecodes -XX:+RewriteFrequentPairs -XX:-DontCompileHugeMethods -XX:+UseFPUForSpilling -XX:AllocatePrefetchStyle=3 -XX:+UseFastStosb -XX:+UseNewLongLShift -XX:+UseXmmI2D -XX:+UseXmmI2F -XX:+UseXmmLoadAndClearUpper -XX:+UseXmmRegToRegMoveAll -XX:+UseVectorCmov -XX:+UseXMMForArrayCopy -XX:+UseLargePages -XX:LargePageSizeInBytes=2M -Dfile.encoding=UTF-8 -Xlog:async -Djava.security.egd=file:/dev/urandom --add-modules jdk.incubator.vector 96 | ``` 97 | 98 | ### ***Low End Client, G1GC:*** 99 | 100 | Use these flags on a weaker client that wants a bit of additional performance, but simply don't have the power to run ZGC. 101 |
102 | These won't give you as much of an impact as Performance Focused, and are not suggested for using mods like ViveCraft. 103 | 104 | You may also need to include -Xms2G and -Xmx2G (or whatever memory you want allocated) if you are running this on the vanilla launcher, (use Prism) This is primarily made for MultiMC based launchers (such as Prism) which disallow those values being present. 105 | 106 | ```java 107 | -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -Dterminal.jline=false -Dterminal.ansi=true -Djline.terminal=jline.UnsupportedTerminal -Dlog4j2.formatMsgNoLookups=true -XX:+AlwaysActAsServerClassMachine -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+UseNUMA -XX:AllocatePrefetchStyle=3 -XX:NmethodSweepActivity=1 -XX:ReservedCodeCacheSize=400M -XX:NonNMethodCodeHeapSize=12M -XX:ProfiledCodeHeapSize=194M -XX:NonProfiledCodeHeapSize=194M -XX:+PerfDisableSharedMem -XX:+UseFastUnorderedTimeStamps -XX:+UseCriticalJavaThreadPriority -XX:+EagerJVMCI -Dgraal.CompilerConfiguration=community -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:InitiatingHeapOccupancyPercent=15 -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=1 -XX:+UseStringDeduplication -XX:+UseAES -XX:+UseAESIntrinsics -XX:+UseFMA -XX:+UseLoopPredicate -XX:+RangeCheckElimination -XX:+EliminateLocks -XX:+DoEscapeAnalysis -XX:+UseCodeCacheFlushing -XX:+SegmentedCodeCache -XX:+UseFastJNIAccessors -XX:+OptimizeStringConcat -XX:+UseCompressedOops -XX:+UseThreadPriorities -XX:+OmitStackTraceInFastThrow -XX:+TrustFinalNonStaticFields -XX:ThreadPriorityPolicy=1 -XX:+UseInlineCaches -XX:+RewriteBytecodes -XX:+RewriteFrequentPairs -XX:-DontCompileHugeMethods -XX:+UseFPUForSpilling -XX:+UseFastStosb -XX:+UseNewLongLShift -XX:+UseXmmI2D -XX:+UseXmmI2F -XX:+UseXmmLoadAndClearUpper -XX:+UseXmmRegToRegMoveAll -XX:+UseVectorCmov -XX:+UseXMMForArrayCopy -XX:+UseLargePages -XX:LargePageSizeInBytes=2M -Dfile.encoding=UTF-8 -Xlog:async -Djava.security.egd=file:/dev/urandom --add-modules jdk.incubator.vector 108 | ``` 109 | 110 | 111 | > Warning `Option UseBiasedLocking was deprecated in version 15.0 and will likely be removed in a future release.` can be completely ignored without consequences, it won't effect anything and is unlikely to be removed anytime soon. 112 | 113 | **Using more than 16GB is generally over-overkill 99.99% of the time unless your in a heavily modded environment** 114 | 115 | ## Explanation 116 | 117 | ***Please try not to rely on these explanations, do your own research as I don't know how to explain things due to lacking social experience*** 118 | 119 | > [!NOTE] 120 | > For most of the flags below `-XX:+UnlockExperimentalVMOptions` and/or `-XX:+UnlockDiagnosticVMOptions` are required. 121 | 122 |
123 | 124 | > -Xmx8G 125 | 126 | Specifies the maximum amount of memory the JVM may use in gigabytes 127 | 128 |
129 | 130 | > -Xms8G 131 | 132 | Specifies the initial heap size for the JVM in gigabytes 133 | 134 |
135 | 136 | > [!NOTE] 137 | > Setting both -Xms and Xmx to the same size is recommended to improve predictability, and to have less GC cycles. 138 | 139 |
140 | 141 | > -XX:+UseZGC 142 | 143 | Tells the JVM to use the ZGC garbage collector 144 | 145 |
146 | 147 | > -XX:-ZUncommit 148 | 149 | Stops ZGC from returning memory back to the OS. This can help improve speed as it doesn't have to wait for the OS to reallocate the memory but may also result on undesirably high memory usage and may negatively impact environments where multiple applications are running 150 | 151 |
152 | 153 | > -XX:MaxGCPauseMillis=200 154 | 155 | Tells JVM to try and keep it's GC (Garbage collector) pauses to or under this specified amount of time. However this only a target and not a guarantee. Doesn't work with `-XX:+UseZGC` 156 | 157 |
158 | 159 | > -XX:+UseG1GC -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:MaxGCPauseMillis=200 160 | 161 | Tells java while using stability flags to use G1GC and make short pauses instead of long ones. 162 | 163 |
164 | 165 | > -XX:+AlwaysActAsServerClassMachine 166 | 167 | Forces java to use garbage collection that would be used with "Server class" hardware. Should show benefits on systems with higher core count CPUs as garbage can be passed of to another thread. `ParallelGC`, `CMS` (Concurrent Mark Sweep) or `G1GC` will be used instead of SerialGC 168 | 169 |
170 | 171 | > -XX:+AlwaysPreTouch 172 | 173 | Pre-touches memory during allocation, causing them to be loaded into physical memory. Can reduce delays accessing newly allocated memory. 174 | 175 |
176 | 177 | > -XX:+DisableExplicitGC 178 | 179 | Prevents forced GC calls (By a plugin, or other code), only allowing one's by the JVM itself 180 | 181 |
182 | 183 | > -XX:+UseNUMA 184 | 185 | Tells JVM that the system uses Non-uniform Memory Access (NUMA), increasing the use of lower latency memory on multi-node topologies (Caches or RAM). Only available when used with `-XX:+UseParallelGC` 186 | 187 |
188 | 189 | > -XX:AllocatePrefetchStyle=3 190 | 191 | Enables pre-fetching and set's the prefetch style 192 |
193 | 0 - Disables any pre-fetching 194 |
195 | 1 (Default) - Prefetches object fields (Increasing access speed as the fields likely are already loaded into cache) 196 |
197 | 2 - Prefetches data right before allocation (Thus reducing latency for access to non-cached data) 198 |
199 | 3 - Prefetches data after allocation (Potentially making access to a objects fields faster) 200 |
201 | Setting to "3" has been recommend for use with Minecraft as it improves performance 202 | 203 |
204 | 205 | > -XX:+PerfDisableSharedMem 206 | 207 | Disables a section of shared memory (A memory mapped file) used for performance statistics. This is done synchronously and can cause performance impacts 208 | 209 |
210 | 211 | > XX:+ParallelRefProcEnabled 212 | 213 | Allows for parallel reference processing whenever possible. 214 | 215 |
216 | 217 | > -XX:-UseBiasedLocking 218 | 219 | Improves performance of un-contended synchronization, also spits an error on startup about depreciation which you ***should ignore*** 220 | 221 |
222 | 223 | > -XX:+UseStringDeduplication 224 | 225 | Saves some memory by referencing similar string objects instead of keeping duplicates. 226 | 227 |
228 | 229 | > XX:+UseAES -XX:+UseAESIntrinsics -XX:+UseFMA 230 | 231 | Enables AES/FMA which very slightly improves performance however is incompatible on >2009 CPUS. Unintentionally also fixes a [Geyser bug](https://github.com/GeyserMC/Geyser/issues/3490) 232 | 233 |
234 | 235 | > -XX:+UseCodeCacheFlushing 236 | 237 | Removes old methods from cache 238 | 239 |
240 | 241 | > -XX:+UseThreadPriorities 242 | 243 | Allows a JVM app like minecraft or mods/plugins to set priority of a thread, good for Folia, C2ME or DimThread 244 | 245 |
246 | 247 | > -jar server.jar 248 | 249 | Tells java what the name of the jar executable is 250 | 251 |
252 | 253 | > –-nogui 254 | 255 | Forces games like minecraft to not display the funky gui, does not matter in non graphical enviroments. 256 | 257 |
258 | 259 | > -Dterminal.jline=false -Dterminal.ansi=true -Djline.terminal=jline.UnsupportedTerminal Dlog4j2.formatMsgNoLookups=true -XX:NmethodSweepActivity=1 -XX:ReservedCodeCacheSize=400M -XX:NonNMethodCodeHeapSize=12M -XX:ProfiledCodeHeapSize=194M -XX:NonProfiledCodeHeapSize=194M -XX:+UseFastUnorderedTimeStamps -XX:+UseCriticalJavaThreadPriority -XX:+EagerJVMCI -Dgraal.TuneInlinerExploration=1 -Dgraal.CompilerConfiguration=enterprise -XX:InitiatingHeapOccupancyPercent=15 -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=1 -XX:+UseLoopPredicate -XX:+RangeCheckElimination -XX:+EliminateLocks -XX:+DoEscapeAnalysis -XX:+SegmentedCodeCache -XX:+UseFastJNIAccessors -XX:+OptimizeStringConcat -XX:+UseCompressedOops -XX:+OmitStackTraceInFastThrow XX:+TrustFinalNonStaticFields -XX:+UseInlineCaches -XX:+RewriteBytecodes -XX:+RewriteFrequentPairs -XX:-DontCompileHugeMethods -XX:+UseFPUForSpilling -XX:+UseVectorCmov -XX:+UseXMMForArrayCopy Dfile.encoding=UTF-8 -Xlog:async -Djava.security.egd=file:/dev/urandom --add-modules jdk.incubator.vector -XX:+UseLargePages -XX:LargePageSizeInBytes=2M -XX:ThreadPriorityPolicy=1 -XX:+UseFastStosb -XX:+UseNewLongLShift -XX:+UseXmmI2D -XX:+UseXmmI2F -XX:+UseXmmLoadAndClearUpper -XX:+UseXmmRegToRegMoveAll 260 | 261 | These flags are generally either [GraalVM](https://www.graalvm.org/) specific optimizations which optimize performance, or they make such little difference in how a JVM app works that they don't deserve documentation on this page for the sake of my own sanity, do your own research. 262 | 263 |
264 | 265 | > [!NOTE] 266 | > Not all values and flags may have been explained properly, as information was extremely hard to come by and especially in an explainable format, You may get more correct information from other sources. 267 | --------------------------------------------------------------------------------