Some people have been experiencing what I call the "hitches of doom," where the game will freeze for a second at a time at semi-regular intervals, with its memory usage pegged at the maximum. These hitches are caused by the garbage collector. Java's default garbage collector is designed to maximize throughput at the expense of interactivity. I MacGuyver'd my launcher to pass -Xincgc, a possibly 1.6-specific option, and it turned the hitches of doom into a far-more-playable occasional framerate drop. Increasing the memory allocation limit from the cramped 256MB (I play on my workstation, which has 16GB of RAM) may further reduce the problem.
More information on garbage collection and performance vs. interactivity in Java is available here:
http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html
I'm not positive, but I think the -Xincgc option enables an experimental garbage collector that's new in 1.6, and that the Concurrent Low-Pause collector (-XX:+UseConcMarkSweepGC) is a better default for Spiral Knights.
-:sigma.SB
The memory-related hitching on Linux (and other OSes?) has a simple fix
Got it: just look for launcher.log in the installation dir and at the end of it you'll find the complete java call getdown uses to start the game. Copy it, replace Xmx256m with the value you want, add Xingc and run it. Starting the application this way will surely skip updates, but you can start it via getdown when you know there is one coming.
Also, I would like to ask a GM if there is a TOS violation here. The way I see it we are only starting the application with a different method, but if this is, never the less, a violation, I shall delete my post.
Yeah, that's the method I used. There's a similar method that can be used to play the Steam version of the game on Mac OS as well.
I tried -Xincgc on the machine of a friend who was getting hitching far worse than mine. It had no effect. Increasing his memory allocation didn't help either. However, -XX:+UseConcMarkSweepGC turned "3-5 second hitches" into barely noticeable (possibly video hardware related) stuttering. I also added -XX:+CMSIncrementalMode for good measure.
-:sigma.SB
After extensive further testing: +XX:+UseConcMarkSweepGC does improve my friend's situation, but he still experienced some stuttering in arenas and "death rooms" when I turned his allocation back down to 256MB. Taking it back to 512MB fixed that, but he got hitches during the King Jelly fight which significantly worsened as the fight went on. I've been using -Xincgc and -Xmx1024M on my workstation and experiencing no hitching, anywhere, ever... more, I expect, due to the extra headroom than to -Xincgc.
-:sigma.SB
UseConcMarkSweepGC does seem to be working pretty good for me (much better than Xingc), no more hitches until now, so thank you for that :D. I also increased the heap to 600mb, that may be helping aswell.
*sigh* my post was lost.
The problem: After playing the game for a few hours, it will freeze for a short time, then will freeze repeatedly until it stops completely. It must be closed and reopened, somewhere between when the freezes become obvious and when it stops completely, for it to return to a playable state.
There is a way to make it stay playable for longer, at least the length of time I have tested it for (a larger number of hours)
The java arguments -XX:+UseConcMarkSweepGC and -Xmx1024M (or similar number depending on available RAM) are required for normal operation of the software.
I, Khonkhortisan, hereby hold you, Three Rings, to this text: "Getdown will allow any arguments to be passed to the underlying JVM, not just a particular set that have been declared acceptable by the application deployment system." http://www.staging.threerings.net/getdownRationale.html
It does not appear that the spiral shell script can be modified to have getdown pass the options on to the program. Either the arguments are applied to getdown itself, or getdown fails with WARNING r.a: Invalid app_dir.
Because getdown is Unfit for this Particular Purpose, I make the claim that I am not held to Terms of Service Sections 6-1 (https://github.com/threerings/getdown) and 6-13 (you leave me no choice) in this very limited case. (nor am I held to 5, playing it outside the web player)
The method of running the shell script to run the updater to run the game to quit the game to save the default arguments in launcher.log to edit those arguments to pass directly to the game requires either bypassing the updater and running it manually when an version mismatch is encountered, or running the game twice - once for an update check, once to run in a playable way.
The method of adding the arguments to getdown.txt, writing the md5sum of getdown.txt into the first line of digest.txt, removing the last line of digest.txt, writing the md5sum of digest.txt into the last line of digest.txt does not require bypassing the updater, but does require power cycling the game when an update happens.
The method of compiling a modified getdown capable of passing arguments (untried) requires a modified md5sum for it in digest.txt, unless a patch is submitted, accepted, and included in a game update.
Please tell me how to start Spiral Knights in such a way that it will not halt, that it may update itself, and that it only needs to be started once per playing session, even when it has updated itself.
Until such a time as there is a final solution, I present a temporary one:
#!/bin/bash
#./spiralwrapper.sh
runspiralknightswithoutchanginganything=false
function testoriginality {
grep ' getdown.txt ' getdown.txt > /dev/null
isoriginal=$?
}
function applyarguments {
sed -i 's/ getdown.txt / getdown.txt.modified /' getdown.txt
sed -i '/jvmarg = -Xmx256M/d' getdown.txt
sed -i '/optimum_jvmarg = -Xmx512M/d' getdown.txt
echo "jvmarg = -XX:+UseConcMarkSweepGC" >> getdown.txt
echo "jvmarg = -Xmx1024M" >> getdown.txt
sed -i "1 c\getdown.txt = `md5sum getdown.txt | awk '{print $1;}'`" digest.txt
sed -i '$ d' digest.txt
echo "digest.txt = `md5sum digest.txt | awk '{print $1;}'`" >> digest.txt
}
function startandwait {
./spiral
clientpid=""
while [ "$clientpid" == "" ]
do
clientpid=$(ps u -C java | grep projectx | awk '{print $2}')
done
}
if $runspiralknightswithoutchanginganything;
then #remove JVM options
testoriginality; if [ $isoriginal == 1 ]
then
echo -n "Last run, restoring JVM arguments... "
echo "Update me!" >> getdown.txt
startandwait
echo "May the ice bring them wisdom."
else
./spiral
fi
else #add JVM options
testoriginality; if [ $isoriginal == 0 ]
then
echo -n "First run, fixing JVM arguments... "
applyarguments
echo "They wish you cold winds." #freedroidrpg
fi
echo -n "Waiting for updater to finish... "
startandwait
echo "Client started."
testoriginality; if [ $isoriginal == 0 ]
then
echo "Files updated, restarting to reapply JVM arguments!"
applyarguments
kill $clientpid
echo -n "Waiting for updater to do nothing... "
startandwait
echo "Started client for real this time."
fi
fi
Yet again, my whitespace is collapsed.
lol after I go through all this trouble I find there IS a way to add options.
extra.txt
http://forums.spiralknights.com/es/node/62691
If you want to know how to block it from redownloading getdown.txt, you have to grab the new MD5 of the file, and overwrite the old entry in the digest file. THEN you have to MD5 the digest file's text, excluding the MD5 for the digest file itself, but up to and including its newline control char. Paste that MD5 of it as the digest file's own MD5 entry in the digest file.
How did you modify the launcher to pass that option? Cause if you modify getdown.txt it will fail at validation and will re-download, and if you modify the "spiral" script all the options will be overriden by the ones in getdown.txt.
More info of what I'm talking about here: http://forums.spiralknights.com/en/node/12849