I easily make the system requirements, I have a Quadcore 2.40 GHz processor and yet I get massive lag spikes. During these lags I notice that java's CPU usage goes up to 100%. Otherwise, not during a lag, the CPU usage is 40-70%.
Is there anything I can do to make the CPU usage go down and let me play normally?
Huge lag due to 100% CPU usage
The easiest solution is to close other processes and increase java priority. It'll still reach 100% but may not hang as much.
No, absolutely not, that's just senseless brute force. It's 6 threads almost locking down all 6 cores and I can't tell what the rest of the threads would do if there were more cores. There's bound to be something that has sort of "infinite cpu usage" for a few seconds and then times out. This happens for up to 15 Seconds... which means if it's NOT time-dependant, your solution might with some luck reduce the freezes to something acceptable on a machine with 33 cores @10ghz (with no bottlenecks) but not on anything anyone of us has at home :P
Reducing the amount of cores java can use and lowering its priority seems to help a little. Limiting it to just one core, I didn't encounter the problem at all, but my machine is too slow for that (very low fps etc) and I'm not sure this is the right way to go, so I didn't test any of this for long.
edit: WTH!? - I attached strace to several of the threads to see if there's something wrong with my Hardware or something... and since then, the freezes haven't happened. Only played trough the normal daily mission so it could still be a weird coincidence, but I when I tried the same thing yesterday without strace attached it was almost unplayable. This is a dodgy little bug, I hate it already. It's hiding from me :3. If this isn't coincidence: I'm piping the output to a terminal which is way to sluggish, so might be slowing some of the threads down. No adverse side effects so far.
Same here. What's the preferred way to debug this?
Spiral Knights working propperly:
$ top -Hp 14172
top - 21:56:20 up 2 days, 12:49, 10 users, load average: 1,74, 2,03, 1,47
Threads: 33 total, 1 running, 32 sleeping, 0 stopped, 0 zombie
%Cpu(s): 10,1 us, 0,8 sy, 0,2 ni, 87,8 id, 0,5 wa, 0,3 hi, 0,3 si, 0,0 st
KiB Mem: 8169776 total, 7007248 used, 1162528 free, 516832 buffers
KiB Swap: 24563380 total, 232488 used, 24330892 free, 3206784 cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
14224 user 5 0 3444m 647m 48m R 66,3 8,1 6:56.26 java
14197 user 3 0 3444m 647m 48m S 13,3 8,1 0:03.03 java
14196 user 3 0 3444m 647m 48m S 6,6 8,1 0:33.79 java
14172 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.00 java
14174 user 1 0 3444m 647m 48m S 0,0 8,1 0:03.72 java
14175 user 1 0 3444m 647m 48m S 0,0 8,1 0:25.87 java
14176 user 1 0 3444m 647m 48m S 0,0 8,1 0:18.51 java
14177 user 1 0 3444m 647m 48m S 0,0 8,1 0:18.39 java
14178 user 1 0 3444m 647m 48m S 0,0 8,1 0:25.96 java
14179 user 1 0 3444m 647m 48m S 0,0 8,1 0:25.77 java
14180 user 1 0 3444m 647m 48m S 0,0 8,1 0:25.81 java
14181 user 1 0 3444m 647m 48m S 0,0 8,1 0:01.16 java
14182 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.11 java
14183 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.18 java
14184 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.00 java
14185 user 1 0 3444m 647m 48m S 0,0 8,1 0:22.74 java
14186 user 1 0 3444m 647m 48m S 0,0 8,1 0:18.25 java
14187 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.00 java
14188 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.37 java
14189 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.15 java
14192 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.02 java
14193 user 1 0 3444m 647m 48m S 0,0 8,1 0:01.54 java
14195 user 1 0 3444m 647m 48m S 0,0 8,1 0:03.74 threaded-ml
14221 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.04 java
14222 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.00 java
14223 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.00 java
14233 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.00 java
14674 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.01 java
15354 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.82 java
15925 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.09 java
15926 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.00 java
15927 user 1 0 3444m 647m 48m S 0,0 8,1 0:01.07 java
15930 user 1 0 3444m 647m 48m S 0,0 8,1 0:00.76 java
Aaaand that's how it looks during those freezes:
$ top -Hp 14172
top - 21:52:16 up 2 days, 12:45, 9 users, load average: 2,75, 1,75, 1,21
Threads: 33 total, 7 running, 26 sleeping, 0 stopped, 0 zombie
%Cpu(s): 21,2 us, 78,6 sy, 0,0 ni, 0,0 id, 0,0 wa, 0,2 hi, 0,1 si, 0,0 st
KiB Mem: 8169776 total, 6959828 used, 1209948 free, 516244 buffers
KiB Swap: 24563380 total, 232504 used, 24330876 free, 3204180 cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
14176 user 7 0 3455m 652m 48m R 91,2 8,2 0:13.06 java
14178 user 7 0 3455m 652m 48m R 90,9 8,2 0:13.09 java
14180 user 6 0 3455m 652m 48m R 90,9 8,2 0:13.01 java
14175 user 6 0 3455m 652m 48m R 88,9 8,2 0:13.00 java
14179 user 7 0 3455m 652m 48m R 88,9 8,2 0:12.89 java
14177 user 7 0 3455m 652m 48m R 88,2 8,2 0:12.86 java
14195 user 1 0 3455m 652m 48m S 0,3 8,2 0:02.52 threaded-ml
14196 user 1 0 3455m 652m 48m R 0,3 8,2 0:22.22 java
14172 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.00 java
14174 user 1 0 3455m 652m 48m S 0,0 8,2 0:03.72 java
14181 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.96 java
14182 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.09 java
14183 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.17 java
14184 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.00 java
14185 user 1 0 3455m 652m 48m S 0,0 8,2 0:20.78 java
14186 user 1 0 3455m 652m 48m S 0,0 8,2 0:16.70 java
14187 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.00 java
14188 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.25 java
14189 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.15 java
14192 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.02 java
14193 user 1 0 3455m 652m 48m S 0,0 8,2 0:01.04 java
14197 user 1 0 3455m 652m 48m S 0,0 8,2 0:01.81 java
14221 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.02 java
14222 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.00 java
14223 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.00 java
14224 user 1 0 3455m 652m 48m S 0,0 8,2 4:22.19 java
14233 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.00 java
14674 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.01 java
15354 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.82 java
15925 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.07 java
15926 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.00 java
15927 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.06 java
15930 user 1 0 3455m 652m 48m S 0,0 8,2 0:00.01 java
Didn't manage to get any useful info about the threads, because I've never worked with java and I have no idea what I'm doing. Hints are appreciated:
$ sudo jstack -F 14176
Attaching to process ID 14176, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 23.2-b09
Deadlock Detection:
java.lang.RuntimeException: Unable to deduce type of thread from address 0x00007f8f18006000 (expected type JavaThread,
CompilerThread, ServiceThread, JvmtiAgentThread, or SurrogateLockerThread)
at sun.jvm.hotspot.runtime.Threads.createJavaThreadWrapper(Threads.java:152)
at sun.jvm.hotspot.runtime.Threads.first(Threads.java:140)
at sun.jvm.hotspot.runtime.DeadlockDetector.createThreadTable(DeadlockDetector.java:149)
at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:56)
at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:39)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:52)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at sun.tools.jstack.JStack.runJStackTool(JStack.java:136)
at sun.tools.jstack.JStack.main(JStack.java:102)
Caused by: sun.jvm.hotspot.types.WrongTypeException: No suitable match for type of address 0x00007f8f18006000
at sun.jvm.hotspot.runtime.InstanceConstructor.newWrongTypeException(InstanceConstructor.java:62)
at sun.jvm.hotspot.runtime.VirtualConstructor.instantiateWrapperFor(VirtualConstructor.java:80)
at sun.jvm.hotspot.runtime.Threads.createJavaThreadWrapper(Threads.java:148)
... 15 more
Can't print deadlocks:Unable to deduce type of thread from address 0x00007f8f18006000 (expected type JavaThread,
CompilerThread, ServiceThread, JvmtiAgentThread, or SurrogateLockerThread)
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at sun.tools.jstack.JStack.runJStackTool(JStack.java:136)
at sun.tools.jstack.JStack.main(JStack.java:102)
Caused by: java.lang.RuntimeException: Unable to deduce type of thread from address 0x00007f8f18006000 (expected type
JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread, or SurrogateLockerThread)
at sun.jvm.hotspot.runtime.Threads.createJavaThreadWrapper(Threads.java:152)
at sun.jvm.hotspot.runtime.Threads.first(Threads.java:140)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:65)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
... 6 more
Caused by: sun.jvm.hotspot.types.WrongTypeException: No suitable match for type of address 0x00007f8f18006000
at sun.jvm.hotspot.runtime.InstanceConstructor.newWrongTypeException(InstanceConstructor.java:62)
at sun.jvm.hotspot.runtime.VirtualConstructor.instantiateWrapperFor(VirtualConstructor.java:80)
at sun.jvm.hotspot.runtime.Threads.createJavaThreadWrapper(Threads.java:148)
... 12 more