SHOW:
|
|
- or go back to the newest paste.
1 | #!/bin/bash | |
2 | # This line is for starting from mac os icon double click | |
3 | cd "$( dirname "$0" )" | |
4 | ||
5 | # Configurables: | |
6 | # -d32 is for heap size up to 2.5gb. | |
7 | - | # Change to -d64 if you use more. |
7 | + | # Change to "-d64 XX:+UseCompressedOops" if you use more. |
8 | # ** Mention that flag specifically, do not rely on it being autoset. | |
9 | # ** Known and documented JVM bug -- https://forums.oracle.com/forums/thread.jspa?messageID=10017916 | |
10 | ||
11 | # CMSInitiatingOccupancyFraction: Determine how frequently to do a full CMS | |
12 | # sweep. Lines like: | |
13 | # 1308.811: [Full GC (System) ... | |
14 | # indicate "CMS failure". This means a full "pause the app and full GC". | |
15 | # Too many: Lower the percentage. | |
16 | # Too low a percentage: More CMS full sweeps (looks like:) | |
17 | # 171.808: [GC [1 CMS-initial-mark: 212329K(367040K)] ... | |
18 | # and usually many, many more lines after that, ending with | |
19 | # 173.156: [CMS-concurrent-reset: 0.003/0.003 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] | |
20 | # Note the time stamps between those. | |
21 | ||
22 | # -XX:+UseAdaptiveGCBoundary -- apparently, adjust the boundary between new and tenured as needed. | |
23 | # Nice to see; did not know about it before. | |
24 | ||
25 | # -XX:+CMSIncrementalMode: Tells the garbage collector to break the job into many small parts. | |
26 | # May result in better performance. Essential on systems with few cores. | |
27 | ||
28 | # Memory tuning: | |
29 | # Command line controls total heap, and "new". "Tenured" is the difference. | |
30 | # Bigger "new": Less frequent collections. | |
31 | ||
32 | # These numbers are in "Megabytes", the java "m" suffix. | |
33 | ||
34 | # The rule of memory tuning: | |
35 | # SurvivorSpace * (SurvivorRatio + 2) = New | |
36 | # ("SurvivorSpace" is twice the actual surviving threshold.) | |
37 | # SurvivorSpace * SurvivorRatio = Eden. | |
38 | # Two additional survivor spaces are used to copy surviving objects across minor collections. | |
39 | ||
40 | # MAX: Maximum heap space used. | |
41 | # Does not include permanent (byte/compiled code) | |
42 | # Does not include JVM overhead | |
43 | MAX=800 | |
44 | ||
45 | # Tenured: Desired long-term storage space | |
46 | # Will vary based on mods, and "loaded chunks" | |
47 | # -- how many parties of players close to each other. | |
48 | # | |
49 | # Starting assumption: 250 for 1 person, plus 50 per group | |
50 | # of players near each other. | |
51 | # | |
52 | # That is a guess. Please report what numbers work for your server. | |
53 | Tenured=350 | |
54 | ||
55 | # Most important tuning number. Survivor. | |
56 | # Making this higher: Fewer full collections, but more wasted space. | |
57 | # During startup, expect this to overflow frequently. | |
58 | # Dynamic maps wants this at least 100, preferrably 125. | |
59 | # Actual space allocated is 2 spaces, each one twice this size. | |
60 | # "waste/overhead" will be two about to three times this number. | |
61 | # *** Maximum of 1/6rd of "new" | |
62 | # Pay attention to the tenuring distribution logs. | |
63 | # *** This should be enough for generation 3 95%+ of the time. *** | |
64 | # ** TOO SMALL WILL KILL YOUR GARBAGE COLLECTION ** | |
65 | # ** TOO BIG WILL WASTE SPACE ** | |
66 | SurvivorCopySize=12 | |
67 | ||
68 | ## Notes on "SurvivorCopySize": | |
69 | # Flying around in creative mode, in already generated chunks will want | |
70 | # at least 30-35, preferrably 40 meg. | |
71 | # Standing around, single player, can be happy with less than 1. | |
72 | # Even in Mystcraft, with massive amounts of decay everywhere, 95% of the time 1 meg suffices. | |
73 | # Moving around a little, doing basic building/digging, about 3. | |
74 | # | |
75 | # The rule: You want to see "new threshold 4 (max 4)" most of the time. | |
76 | # The total value at age three -- | |
77 | # - age 3: 36712 bytes, 5897520 total | |
78 | # should be less than this 95% of the time. | |
79 | # 12 meg is more than enough for one person with EBXL, Mystcraft, Twilight Forest, | |
80 | # and Custom Ore Gen. Even in EBXL's extreme jungle with Mystcraft's decay littering the ground. | |
81 | # | |
82 | # The single biggest factor is chunks loaded; that will depend more on parties than on players, | |
83 | # and the speed at which they move. Adjust to your server, and your mods. | |
84 | # | |
85 | # Single player won't need that much. Really. | |
86 | ||
87 | # Second most important tuning. Eden. | |
88 | # Making this bigger means less frequent small collections. | |
89 | # General rule: Make this as big as your memory can handle. | |
90 | # Must be at least 2x SurvivorCopySize. Java requires it to be | |
91 | # an integer multiple of that value. | |
92 | ||
93 | desiredEden=100 | |
94 | ||
95 | # Summary: Approximately desiredEden, plus 4 times SurvivorCopySpace, | |
96 | # plus 100, will be used by java to start the heap. Up to a max of MAX. | |
97 | # Script will attempt to ensure at least Tenured space exist; | |
98 | # should exit with a message if it cannot. | |
99 | # | |
100 | # In theory, Java will allocate extra space to new or tenured as needed. | |
101 | # In practice, I've never seen it increase "new". | |
102 | # ** Update! Just found a config flag conflict, and updated. | |
103 | # I suspect I've now gotten it to increase "new" as demand goes up. | |
104 | # | |
105 | # See the bottom of the config section for more. | |
106 | ||
107 | # If your shell cannot do math, replace these with an appropriate constant | |
108 | ||
109 | MaxNew=$(($MAX - $Tenured)) | |
110 | ||
111 | Survivor=$((2 * $SurvivorCopySize)) | |
112 | ||
113 | sanityTest=$((3 * $Survivor)) | |
114 | if [ $sanityTest -gt $MaxNew ] | |
115 | then | |
116 | echo Memory config error >& 2 | |
117 | exit 1 | |
118 | fi | |
119 | ||
120 | # We cannot use more than MaxNew. | |
121 | ||
122 | # The idea: | |
123 | # 1. Find the multiple of Survivor that is bigger than S and less than MN. | |
124 | # 2. Determine survivor ratio from that. Subtract 2 (java.) | |
125 | # 3. Specify -Xmn for new, and survivor ratio, to set eden and new. | |
126 | ||
127 | # "New" will be Eden plus 2* Survivor. | |
128 | ||
129 | MaxRatio=$(($MaxNew / $Survivor - 2 )) | |
130 | desiredRatio=$(($desiredEden / $Survivor)) | |
131 | ||
132 | # SurvivorSpace * (SurvivorRatio + 2) = New | |
133 | ||
134 | desiredNew=$(($Survivor * ($desiredRatio + 2) )) | |
135 | biggerNew=$(($Survivor * ($MaxRatio + 2) )) | |
136 | ||
137 | echo Debug: Max ratio $MaxRatio, desiredRatio $desiredRatio, Max new $MaxNew | |
138 | echo Debug: desired eden $desiredEden, survivor $Survivor | |
139 | echo Debug: desiredNew: $desiredNew, bigger new: $biggerNew. Compare to eden/max. | |
140 | ||
141 | # desiredNew: Gives an eden up to, not bigger, than desiredEden. | |
142 | # biggerNew: Gives an eden at least as big as desiredEden. | |
143 | # FIXME: DesiredNew / ratio should be smallest at least as big as desiredEden | |
144 | # This means, if less, then add 1 to ratio and add to new. | |
145 | # | |
146 | # "Bigger" assigns ALL non-tenured memory to new. | |
147 | ||
148 | # Q: Desired numbers? Bigger/Max numbers? | |
149 | ||
150 | # Choose one of these pairs | |
151 | ||
152 | # New space is small -- specified eden. | |
153 | NEW=$desiredNew | |
154 | RATIO=$desiredRatio | |
155 | ||
156 | # Tenured is small -- specified tenured space. | |
157 | - | START=$(($NEW + 100)) |
157 | + | |
158 | # In theory, Java should now adjust new as neeed. | |
159 | #NEW=$biggerNew | |
160 | #RATIO=$MaxRatio | |
161 | ||
162 | START=$(($NEW + 50)) | |
163 | ||
164 | ## TESTME: Does "MaxNewSize" matter if we have adaptive GC boundary? Does it hurt? | |
165 | ||
166 | exec java \ | |
167 | -d32 -server \ | |
168 | -Xms${START}m -Xmx${MAX}m \ | |
169 | -XX:NewSize=${NEW}m -XX:MaxNewSize=${MaxNew}m \ | |
170 | -XX:+UseAdaptiveGCBoundary \ | |
171 | -XX:SurvivorRatio=$RATIO \ | |
172 | -XX:CompileThreshold=3000 \ | |
173 | -XX:CMSInitiatingOccupancyFraction=95 \ | |
174 | \ | |
175 | -XX:MaxPermSize=150m \ | |
176 | -XX:+UseConcMarkSweepGC -XX:+UseParNewGC \ | |
177 | -XX:MaxHeapFreeRatio=20 \ | |
178 | -XX:MinHeapFreeRatio=12 \ | |
179 | -XX:MaxTenuringThreshold=4 \ | |
180 | -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution \ | |
181 | -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -Xloggc:GC.log \ | |
182 | -jar new_server.jar nogui |