Performance tweaks for the game

186 replies [Last post]
Lufte's picture
Lufte
@zerkenos

Zerkenos you can find the completed command at the end of launcher.log, that way you don't have to replace anything. You just copy it and modify the options you want. For example, I'm having some good results with -XX:+UseConcMarkSweepGC (instead of -Xincgc) and a max heap size of 600mb (-Xmx600M).

Cainvelaquez
my system: OS: Windows XP SP3

my system:

OS: Windows XP SP3 32bits
VGA: GeForce 8800GT 512mb
HD: Samsung 512gb sata2
MEM: 2x 1gb markvision

Im a steam user, what command line can i put the launch options to get better performance? this game is nice, but i very very sad with the performance ... help-me

viper901
Legacy Username
I am running steam on a mac

I am running steam on a mac and thinking about attempting some of these things, but I still have no idea which files to manipulate on the OS x operating system and where they live. Does anybody have any suggestions where to start?

lawlz
Legacy Username
Why do I get an error sound

Why do I get an error sound without any errors when I add -server?

Can someone help me?

I am using:
2.8ghz Dual Core
2gb Ram
Java 6 (latest update)
Windows XP Pro 32bit

Darkiboo
Legacy Username
I agree. If someone could

I agree. If someone could give direct instructions on how to increase performance via steam on a 32-bit OS, it'd be greatly appreciated. I took a good long look over this thread to figure it out myself, but all I get a sense of is that I need to change something in the launch options and change something java-related. I already have JDK downloaded for whatever part that is needed in. But when it comes to everything else, I just can't piece it all together.

Avatarion's picture
Avatarion
Hello balamcab. I would like

Hello balamcab. I would like to improve the performance of our computer for SK, though I would need additional help. Can you, or anyone, step-by-step explain in Layman's term what to do with steps 4-8 (since I have a 32-bit Windows system)? I am not really familiar with these things and I have no idea how to do these. I would really like to know.

Any additional help would be really greatly appreciated, not only for me, but also to those others interested in this.

Ewbtes's picture
Ewbtes
yeah, that would be great!

yeah, that would be great!

Petprincess's picture
Petprincess
Heya, found this topic by

Heya, found this topic by google and stuck these commands in my steam directory's launcher.log file and set to read only, am 95% lag free now.

Figured More people would like to know how to improve their performance.

It's a necro, but is it a bad necro? I think this thread should be continued, honestly. It is interesting and helpful...

Petprincess's picture
Petprincess
By the way, if you prefer

By the way, if you prefer running spiral knights in high priority and use non-steam version but have the game installed, you can stick this into the "Target" to automatically boot it in high priority. No one mentioned that in this thread, so thought I'd add it.

C:\Windows\System32\cmd.exe /c start "runhigh" /high

you stick it before everything else.. change the cmd.exe directory to where it is in your windows install on your computer and should work fine.

Scrum-Lord's picture
Scrum-Lord
Can we at get some control

Can we at get some control over the startup options under the Steam version please?

Eltia's picture
Eltia
Step-by-step layman's tutorials

Tweaking tutorials.

Do it at your own risk, comes with no warranties whatsoever. (Your PC may blow up, dogs may die and Vanaduke may maul you on your next run, etc etc.)

Renpartycat's picture
Renpartycat
You want a performance tweak?

Get rid of Java.

Java code is horrible, and causes frequent memory leaks. And PLEASE don't port it to Source, otherwise the game will become virtually unplayable in the future. Mainly because Source has the tendency to slowly fragment the game with every update. And it's a really old engine.

Honestly we just need a better engine. Oh and less sprites. The main reason why FSC is so laggy is because the shadow flames are sprites.

Sypsy's picture
Sypsy
Can someone summarize what is

Can someone summarize what is relevant for this java tweak?
I have windows 7 64-bit non-steam.

So far, I have re-targeted the java to run the 64-bit. Starting it up like this already seemed faster. I will monitor how things go. So far I noticed that when I switch between a DA & GF, the colour of the previous sword remains and you get a weird orangy blade. Menu's load with a slight lag at first, but then almost instantly after the 2nd or 3rd time.

I also did the tweaks up to point 6 in the OP.
6. Change the way the java garbage collector works and minimize the small random lockups the game had while playing (incremental garbage collector).
"C:\Program Files\Java\jre6\bin\javaw.exe" -server -Xincgc -Xms1024m -Xmx2048m -jar getdown-pro.jar .

I didn't think the stuff after that was needed. I also had no idea what it did.
I also read the rest of the thread and was thoroughly confused.

Evilduck's picture
Evilduck
@Sypsy I'm pretty sure the

@Sypsy I'm pretty sure the DA/GF blending thing is a result of one of the recent updates - I expect it was the graphical change to the DA. I get this too and I've been on 64 bit java since I started in February.

Kirnan's picture
Kirnan
Tweaks Done, these ok?

I am using Windows 7 steam, changed over java to 64 bit as needed per the directions, and then added the command parameters in Launch Options as such:

-server -Xms1g -Xmx3g -Xms1024m -Xmx2048m

Is this about correct? Should it look differently? If so, how should it look?

Kirnan's picture
Kirnan
sooo....

anyone?

Geekfox's picture
Geekfox
An unexpected error occurred on the server.

Java doesn't seem to recognize the -Xms parameters, at least on Java 7 64-bit. You'll know when you launch the game and check the chat logs.

I redirected Spiral Knights's launch of Java by using symbolic link to Java 7 64-bit I already installed on another folder. The advantage experienced was gaining twice the framerate and a working surround sound audio.

The disadvantage is that Java 64-bit doesn't launch without disabling Steam Overlay first.

Freeze lag still happen as usual, but it seems to be a shorter lag time.

Starlinvf's picture
Starlinvf
The Steam overlay won't work

The Steam overlay won't work with 64-bit java.. seems like the overlay process can't figure out how to hook into it.

-Xmx is by far the most useful of the tweks (unless someone found a better garbage collector), but these tweks won't work in Steam without a few cleaver tricks and a bat2exe converter. The main issue is getting the projectx launch to use custom parameters. But since those are defined by getdown, and can't be changed without invalidating the related files, the patcher simply fixes it before proceeding. Global parameters won't work because it doesn't use the system java install, you need to use a bat2exe converter to make a file containing the parameters you want. Rename javaw.exe to something else, use the custom file to take its place. When steam tries to launch the game, it uses the converted bat file and executes accordingly.

The downside... the patcher won't work correctly if you specified it to launch projectx directly. You can get around this if you set it up to accept arguments, but I'm not sure if that a specific function that needs to supported in the converter, or if it'll work regardless.

Eltia's picture
Eltia
@Starlinvf

Agree with the part that the culprit of the whole stuttering on Steam is due to our inability to weak JVM properly (thanks to little file called getdown).

Can OOO actually look into this and at least revise the setting in getdown, so that Steam users can have the Xms and Xmx parameters set to something more suitable for modern hardware please?

Nicoya-Kitty's picture
Nicoya-Kitty
I'm not sure if something

I'm not sure if something changed with the commandline parsing, but passing the -Xmx flags from the steam launcher doesn't seem to not work (double-negative intended).

launcher.log shows the flag getting passed into the java process, and there's no errors reported that I can see.

Aljevoias's picture
Aljevoias
I'm a steam user and have

I'm a steam user and have been working with the information in this threat to improve performance. OOO really should put some of these things in the in-game configuration options or otherwise make them less obtuse, the default settings are great for low-end computers but shouldn't restrict everyone to that level of performance.

Alternately, they could provide a method of uncoupling steam accounts, so we can log in from the standalone client without using Steam. Getting these tweaks to work when launching SK directly seems to be much easier.

Eltia's picture
Eltia
@Aljevoias

+1 to both of your points. Strongly agree.

Or we just have to keep doing Ghetto relog without penalties (which is a hack).

Bluescreenofdeath's picture
Bluescreenofdeath
@Renpartycat Source games on

@Renpartycat

Source games on Steam have a built in defrag feature. It is crazy fast to do. Source is long in the tooth, but it is a very sold engine that I would take over java any day.

Corsa's picture
Corsa
Oh hey...

I wrote a response addressing some of the posts that have been made since this thread's unholy awakening, but it started looking like an essay instead. I'll just post a not-so-long-tl;dr (for now?!).

The getdown-pro.jar package passes up to 16 arguments to the actual game client. Only 13 of these arguments are required for proper execution of the game. This gives us 3 arguments to try and optimize the game's performance without modifying any of the game's files or using a homebrewed launcher.

For steam users, these settings will provide the best improvement in performance under the given constraints:
-server -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode
Just plop that into SK's launch options in the steam library and you're good to go. If you've chosen to use the 64-bit Java VM, swap the "-server" option for "-XX:+ExplicitGCInvokesConcurrent" and it might give you a tiny improvement. I don't know anything about the game's code specifically to determine how much this setting will help.

Corsa's picture
Corsa
Oh hey... (cont.)

The -server option probably has the greatest effect, though it depends on the overall complexity of the game's code. It sets a bunch of the JVM's options to higher performance presets typically required of server applications. The tradeoff is slightly higher startup and load times and more memory usage. The 64-bit JVM enables this option by default so we get an extra parameter to work with when using it.

I did not agree with the suggestion to use the -Xmx option the first time this topic was discussed. It's obvious that the game already uses more than the 256M requested by the default launcher. Even with that, the stalls that occurred usually took over an hour to start for me. I used (badly, I guess) the example of firefox 2 to point out that a program allocating a lot of memory on a system with a lot of memory does not mean that the program is performing well. In the case of firefox 2, this is due to various memory leaks. This is not the case with Spiral Knights. If the game actually contained memory leaks, we would be experiencing total crashes not intermittent stalls.

The stalls are caused by the very mechanism that prevents the game from having memory leaks, the garbage collector (GC). In very simple terms, the GC allows programmers to manipulate data without worrying about how much memory it'll use by allocating and freeing memory automatically. It works similar to real life garbage collectors who pick up your trash once a week, saving you a trip to the dump.

By default the JVM uses a GC that minimizes processor usage by waiting to do all the garbage collection at specified times. The GC does not cause the main program to slow down while it is not collecting, however when it comes time to collect any unused objects, it must take full control of the processor. The game stalls we experience are due to these "stop-the-world" events. The -xincgc option that was suggested three months ago alleviates the stall time by breaking up the GC process into smaller chunks. The GC will incrementally check if memory is ready to be cleaned in smaller steps during which it siezes full control, but for shorter periods of time compared to the default GC. There may still be noticeable stalls depending on the size of total memory when using the incremental GC.

The second option, -XX:+UseConcMarkSweepGC, uses a different strategy to collect garbage. The concurrent mark-and-sweep (CMS) GC will constantly check what parts of memory are being used while the main program is running. The CMS uses more processing power than the default and incremental GC but it doesn't require any prolonged stop in execution. There are two necessary pauses, but they are brief. Essentially, the CMS requires that no memory is modified while it checks object usage (marking) or deletes unused memory (sweeping) so it will pause the main program execution during these phases. -XX:+CMSIncrementalMode further optimizes the CMS by breaking up the marking and sweeping steps in a similar fashion to the improvements brought by the incremental GC to the default GC.

-XX:+ExplicitGCInvokesConcurrent is marginally useful in case one of OOO Tree Rings' developers decided to explicitly call for GC at some point in the game's code. Normally, an explicit call to the GC would use the default GC strategy. As you may have guessed, this option will use the CMS instead to reduce the stall time, even if the total time to clear the memory is longer.

Finally, we return to my objection to -Xmx. Typically, a larger memory size increases each stall time. Using more memory may delay the time until the first garbage collection, but it increases the length of the stop-the-world event by about twice the increase in memory in the default GC and by about 1/6 with the CMS. Increasing memory size from 256M to 1024M extends the stall by 8 times with default GC and 4/3 times with CMS.

Sypsy's picture
Sypsy
Confused

So... for non-steam 64-bit windows 7 you would recommend:

"C:\Program Files\Java\jre6\bin\javaw.exe" -server -XX:+ExplicitGCInvokesConcurrent -jar getdown-pro.jar .

?

Corsa's picture
Corsa
Clarification

I didn't do any digging to find exactly how steam passes launch options to the launcher to make it pass them forward to the game. Simply adding extra command line flags to the launcher shortcut does not work. I'm sorry I can't help any more with that part.

I can clarify the 3 recommended options for 64-bit users though:
-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+ExplicitGCInvokesConcurrent

Silphius's picture
Silphius
I would like to thank you for

I would like to thank you for your unprovoked niceness in taking the time in getting the game running better for all of us. thanks.

Maybe this should get stickied.

Corsa's picture
Corsa
Wow I'm stupid.

I've figured out how steam passes arguments through the launcher to the game. In the process of discovering this, I finally realized something I should have noticed 4 days ago. The order of the arguments in launcher.log when setting launch options in steam imply that the launch options are parameters for the game, not the JVM. This explains why I couldn't profile the GC. I don't even feel like sharing the parameter passing syntax now.

So as it stands, making a custom launcher script is the only way to tweak the JVM's performance and steam users are reconfirmed to be untweakable.

Sypsy's picture
Sypsy
Thanks Corsa! I think you

Thanks Corsa! I think you have explained things well enough for someone with very very limited knowledge like myself could understand.

To summarize for non-Steam 64-bit Windows 7 Users:
First, 64-bit Java should be installed and the SK client should be re-directed to run it as it runs the 32-bit by default. (This is reflected in the below, assuming a default installation and discussed in the OP.)
The client can only have an additional 3 arguments added to it.
The source of the largest stalls is the garbage collector, and to minimize the stalls the following arguments are optimal:

"C:\Program Files\Java\jre6\bin\javaw.exe" -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+ExplicitGCInvokesConcurrent -jar getdown-pro.jar .

I have done this and will monitor for the next little while! =)

Corsa's picture
Corsa
Well, why not

Maybe someone else can do something useful with this information.

You can use the following syntax to make the non-Steam launcher pass arguments to the game the same way Steam does:
java -jar getdown-pro.jar . client arg0 arg1 arg2

So using Sypsy's example in #60 of this thread, you would have:
"C:\Program Files\Java\jre6\bin\javaw.exe" -jar getdown-pro.jar . client -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+ExplicitGCInvokesConcurrent

This gives the same result as running the Steam version with the launch options set to -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+ExplicitGCInvokesConcurrent

Of course, as I already mentioned, this doesn't actually pass the arguments to the game's JVM but to the game itself. The game does nothing useful with JVM arguments passed to it in this way.

Volebamus's picture
Volebamus
For reference (non-Steam

For reference (non-Steam 64bit), I've tested several switch configs presented here aside that from #80, but none of them seemed to do anything for me. In FSC, I still had times when my screen froze for a second or two that strung towards another half a dozen or so freezes.

Now have #80 in place to see how that works.

Eltia's picture
Eltia
Can OOO look into performance issue on Steam SK client please?

The current setting for Steam SK is not optimal. Please tweak it for us and patch that getdown file please?

Sypsy's picture
Sypsy
@Volebamus I think I will try

@Volebamus

I think I will try what Corsa typed out in #81.
Not sure what the difference is though. maybe #80 and earlier doesn't actually apply the arguments.
Please confirm knowledgeable ones! xD

Volebamus's picture
Volebamus
Yeah, tried out the one you

Yeah, tried out the one you had in post #80, but didn't seem to do the trick for me. Trying #81 as well.

Sypsy's picture
Sypsy
#81 was weird. The username

#81 was weird.
The username when I opened it was "-XX:+ExplicitGCInvokesConcurrent", then it was something non-sensical. FSC run seemed standard with all the normal stalls.

Gonna go back to #80.

I'm thinking it's just my C drive being sluggish. Perhaps that long-overdue windows re-install will make things better. =\

Eltia's picture
Eltia
Some positive results

I'm on Windows 7 x64, Steam SK and Java 32 Bit. I get some good results by using "-Xmx1g -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+ExplicitGCInvokesConcurrent". If people wonder how I did this, I wrote a little stub program in C to replace javaw.exe, so it would pass the required parameters into JVM (instead of passing it into SK). Everything else is unchanged (including the Steam login process). Graphic is set to maximum and running at 1080p.

The incremental garbage collector (GC) definitely works better under Steam. Before the switch, my SK would lag after an hour sitting in town. Yesterday I managed to cruise around Haven, Bazaar and Arcade for hours without needing to relog. I have tested it in Roar and JK levels. There were still a few pauses (about 3 hiccups for whole night of gameplay) but I managed without any relog for the whole night.

The drawback of this tweak seems to be that SK takes longer to load maps. I think this is a fair trade off. It's much better than stuttering every 5 steps when you are fighting in Clockworks.

Profiling results suggest that SK uses roughly 450-500MB of memory at peaks. So I'm more inclined to support the view that more memory doesn't necessary mean better performance. But we definitely need more than 256MB on Steam SK (which is the default setting on Steam SK). Also, due to the current configuration in Steam SK, the maximum memory I can assign is 1GB. (JVM won't start if I assign more as it seems to conflict with the default setting OOO provided.)

In conclusion, I strongly suggest OOO to take a look at this tweaking option for Steam users. Evidences tend to support that the stuttering on Steam SK is due to inappropriate tweaking of JVM. The default GC seems to be the culprit.

Bluescreenofdeath's picture
Bluescreenofdeath
Yeah, I'm kinda annoyed with

Yeah, I'm kinda annoyed with how poorly this game seems to be coded. I am running 8 gigs of DDR3 on my mobo and 1 gig with my GPU (GTX 285) so there is no reason for my machine to studder while running this game, but it does.

I am also running Win7Pro64bit and Steam. I have done the Java 32 bit hack which seems to have helped a little, but I would be really interested in your custom javaw.exe file, Eltia. It has been waaay to long since I have touched any C+ programing so I don't think I could do it myself.

I take it that those parameters can't be achieved by plugging that stuff into Steam's launch options for SK? I use this function to tweak other games like CS:S.

Norfair's picture
Norfair
symlinks blah blah

Hey guys, I just linked to my /jre7 folder directly, calling the link java_vm. This way, Java will stay updated etc etc. Seems to work fine. I'm on win7, but the instructions are the same:

http://www.howtogeek.com/howto/windows-vista/using-symlinks-in-windows-v...

C:\Program Files (x86)\Steam\steamapps\common\spiral knights>mklink /J "C:\Progr
am Files (x86)\Steam\steamapps\common\spiral knights\java_vm" "C:\Program Files\
Java\jre7"
Junction created for C:\Program Files (x86)\Steam\steamapps\common\spiral knight
s\java_vm <<===>> C:\Program Files\Java\jre7

Shortnstubby's picture
Shortnstubby
@Eltia Is there anyway

@Eltia

Is there anyway possible that you could upload the source and maybe a compiled version of your stub javaw.exe you don't have to support it in any way, just im the same as Bluescreenofdeath, Its been so long since ive played in C that it would take me a while to make something work. If you could how ever release your source, maybe we could even set it up so that anyone could use it and pull parameters from a cfg file in the future. it seams to me as if there is no plan from OOO or Steam to help us on this issue so its us the players that must create something that will allow us to optimize our client. Wish that I would of known to not link my account with steam before I started playing...Thank you.

Eltia's picture
Eltia
@Bluescreenofdeath and Shortnstubby

I thought about just copy-and-pasting the source code (in C) to this thread. Thing is that I read the forum rules and this could be in violation of the rules relating to exploit. So I rather not risk it because I do not want to get banned. (The forum rules do not prevent me to discuss results that I discovered on my own.)

Use this code to locate the source: 66y5bt5. Good luck compiling and let us know of your results. For people who are on Mac, this may work also as long as you get it compiled.

Shortnstubby's picture
Shortnstubby
Thank you I will try and find

Thank you I will try and find where that code leads to and see what I can come up with. Just gotta try and figure out where it could be lol.

Edit: ok, ive done searched everywhere and cant seam to come across where that code leads to..thanks anyways. atleast I know its possible to do will code one myself lol. would love to minimize the spikes i encounter on a 30 second or less basis while trying to play. certain areas are kind of impossible especially sometimes in fsc when im running next thing i know im on fire and in spikes...

Eltia's picture
Eltia
Hint: URL shortener

It's not that bad to code it yourself. I spent about an afternoon to get it working. Half of the time went to figuring out why SK complains about multiple instances running. >.>

Alternatively, you can use a batch file compiler as suggested by another poster earlier. I didn't go for this solution because I do not know which batch file compiler is safe and it's very easy to get a keylogger (or other malwares) attached if you just randomly pick one off the Web. So I decided to write the stub myself. This way I know what can go wrong and where to look.

Heimdallr's picture
Heimdallr
--

Got it, nevermind.

Geekfox's picture
Geekfox
SYMBOLIC LINK

You're a geek if you created directory junction to redirect Spiral Knights's JRE to an updated JRE in your Program Files.

I've been having smooth frame rates for a week now since I used Java x64 on Spiral Knights. Of course I've used directory junction before to split Steam game folders between physical hard drives.

Shortnstubby's picture
Shortnstubby
@eltia thanks got it, i was

@eltia thanks got it, i was searching everywhere but that exact one lol. thanks again.

Eltia's picture
Eltia
More results

Some interesting results:

  • went through FSC tonight with a 4 people party. I only experienced a 1 second pause for the whole trip. The Core did not lag. I'm using an Intel Core 2 Duo E8500 CPU and two Geforce GTX 460 (but only one GPU got used by SK);
  • a guildmate of mine who went on the same trip above, using the same tool, reported slightly more pauses (about 3 according to my recollection). The Core did not lag. He is using an Intel Core 2 Quad 2600 CPU and a Geforce 8600 GT.

I'm suspecting the incremental collector uses more CPU cycles. And since SK does not appear to support quad core, the core speed matters more than number of cores.

Also, I do not think the -Xmx flag does anything useful in my case, because it gets overridden by OOO's default setting (which initializes the maximum heap memory to 256MB).

Shortnstubby's picture
Shortnstubby
More Results

So to add to Eltia's findings, I used the same exact tool, keep in mind we are steam client users. This is my summery after opening Spiral Knights and never once logging out or restarting my client. I did not monitor ram or cpu usage, I was more into finally being able to enjoy the game and not have to try and predict next time I would freeze/pause and end up in spikes or fire.

In order of completion:

  • Jelly King - 0 pauses, normally throughout the whole tier 2 run I would encounter random 1 to 3 second pauses every 30 to 60 seconds.
  • Roarmulus Twins - wow what a difference here, usually I encounter the normal 1 to 3 second pauses through out the tier till i hit depth 15 and 16, depth 15 I would encounter 1 second pauses every 15 seconds approximately, depth 16 would be totally unplayable until I would end task on javaw.exe and reopen my client making my party wait and holding everyone up. With the tool I never once had a pause throughout the whole run. It was very nice to be able to do Roarmulus Twins with out it acting like paper mario.
  • FSC run - yet again 0 pauses, usually i would encounter pauses every 30 to 60 seconds that would last 1 to 3 seconds as well.
  • So now system specs,
    Asus G73JH-X2 Laptop
    Intel I7 720qm
    8GB DDR3 1333 RAM
    1GB HD5870 Dedicated Video Card
    Win 7 64bit
    The 32bit version of java that comes with the game through steam (I like my overlay).

    Parameters Used:
    -Xmx1g (stated in post #97 this is believed to not do anything how ever I cannot say weather it does or not)
    -XX:+UseConcMarkSweepGC
    -XX:+CMSIncrementalMode
    -XX:+ExplicitGCInvokesConcurrent

    So to conclude this writeup, im very thankful for Eltia and his time that he has invested to helping out steam users with this tool. I believe OOO should look over these findings and adjust the way some things are handled, If OOO is reading this, if there is a way to recode how steam handles the "Set launch options" under properties of SK in steam library to hook into javaw.exe instead of SK its self that would help solve a good portion of our issues.

    Kirnan's picture
    Kirnan
    Soo....

    For us non-coders (I only know HTML, CSS and some XML), could you post a tutorial on how to go about modding the javaw.exe file to get the three XX parameters to work? And if not possible here, maybe from your Steam page? Please?? Honestly, I would love to have less stutters and pauses in this game, as a lot of the time, they can be death.

    Shortnstubby's picture
    Shortnstubby
    @kirnan

    from post 87 on should be enough information to have you covered, google is your best friend. its all we can do for now. i figured it out from the posts, just read carefully.