Java - Random timeouts due to

it solved my Java timeout on CR for me. NTR.

Please also update the FAQ which still points to java 11.

1 Like

I also doubt there is 768 MB memory available since the JVM is started with the following parameters: [-Xms64m, -Xmx450m, -Xverify:none, -Djava.awt.headless=true, -ea].

I just submitted my solution to “The Labyrinth” written in Clojure and got timeouts on random testcases each time I submitted. Removing all error output solved it for me. Having just a single error output as the first statement brings back the same problem.

1 Like

Thanks for this information. We’ll modify the Clojure stub to add a debug function and an output function which flushes.

@MarvinTheMartian it seems though that the timeouts that you experienced are not linked to that since you used flush in your code

since the JVM is started with the following parameters: [-Xms64m, -Xmx450m,

Do you know for a fact that these are the parameters used? It would be a good idea if we could have the -Xms and -Xmx set to the same values (and why not -Xmx768M?). This will eliminate the JVM having to resize the heap (costly) and should reduce the number of times the GC has to run.

I am not sure if this is the correct place for this, but my problems seem related.

I recently experienced random timeout errors trying to code the MimeType puzzle in Groovy. The puzzle isn’t exactly rocket science so I was surprised at the timeouts. My Java solution worked fine but the exact same code running as Groovy would result in timeouts on about 50% of the runs. For those not familiar with Groovy it is basically a superset of Java and 99% of valid Java code is also valid Groovy code. So I could use my Java solution as-is and run it as Groovy.

I did some instrumenting using the tips above and found the following:

  1. For Groovy code the JIT compiler didn’t settle down until about 1K iterations.
  2. Calls to System.out were the real culprit.

I was able to solve my timeout issue by writing to a buffer (StringBuilder) and then producing all output with a single call to println() rather than calling println() every iteration. Once I submitted a solution that scored 100% I was able able to view the other Groovy solutions and the two l tried exhibited the same time out problems. So something has changed in later versions of Groovy, but I can’t imagine what.

1 Like

Hi @HaywoodSlap, your problem is not related to the java timeouts as your simple groovy code times out always on the MimeType puzzle whereas the Java issue is about a timeout that occurs randomly while submitting in multiplayer games (especially when using java 11 which we rolledback)

Nevertheless this is a quite valid issue that we could reproduce and we’ll investigate.

1 Like

Hi, if there are two java Players, do they run in the same JVM? It seems so from quick code skim.

I know GC can kill my code, that is why I don’t waste a single object - but what if my openen’t doesn’t care?