I have first encountered timeout using java during MeanMax contest and i was forced to set my margin security time up to 20ms when i was using 5-6ms in the other games.
As i said in my meanmax postmortem, i spent most of the time on JMC optimizing my code to avoid allocating memory as i think only the Garbage Collector doing a major GC can exceed my margin security if it occurs just before i reach my maximum time i set for a turn.
Other players in the top rank have encountered the same problems. Could you investigate and found a solution as it is truly disadvantageous for java developer and demotivating as my score on other games is impacted since this problem occur.
This problem seems to affect all the games. At TRON, before the update, i had a rank between 25 - 30 and never encounter any timeout. Now i’m 57th and i can see a lot of timeout during the last battles. My time margin is set to 6ms so i use 94ms to play and check time to exit of my compute loop when i exceed that time, the margin is used to insure i have enough remaining time to send the answer even if a minor GC occurs (1-1.5ms generally)
You think C++ is better than Java because we have no garbage collector to handle ? If i code in C++ using new and delete everywhere, i can assure you that my code will be slower than your Java code, GC cycle included.
Creating object is slow, this is just by far the slowest thing you can do in your code. Even creating a simple class with no member is slow.
So, what is the solution ? Well, the solution is the same for every languages: create all your objects during the first turns. Use caches and factories. NEVER create and delete an object after the first turn.
The only difference between Java and C++ on this point is that you can’t disable the GC, so you have to take a margin on your timeout. But if you never delete any object (like we do in C++), the GC will never run.
I don’t know if the problem is worse since the last update for Java. For C/C++ we have an other problem. At the first turn, we can timeout at the first turn because of the debugger (the debugger is not started in the arena). But the time used by the debugger seems to count for our execution time. And worse of all, this debugger is not able to provide any stack when we crash
But, langage update put aside, codingame changed the machine used for our codes. Maybe the new machines are just slower.
I’m not interesting at changing codingame rules to balance between languages as for me if you optimize correctly your code like Magus said java can be as quick as c++.
I opened that topic because I noticed a significant decrease of java performance since the last contest that affects all my java code already submitted and decrease my rank in multiplayer games. I just want to raise this problem so codingame members can investigate.
I think something has changed and cause major gc to occur while it was not the case before.
This answer is a common place here at CG… And each time that I read this, it sound like: “If you are not able to do things in the hard way, just get of of here, this is not a platform to get fun, or for noobs… We do not care with you, if you are not a GURU”
IMO, the place for who want to learn about performance, should be the Practice and Optimization challenges. And the multiplayer should not be mandatory to know so deep about this optimizations. It is not easy to do an entire code without the “new” word in Java.
Personally i don’t care about performance and stuff because i mostly code in PHP so I’m out of it, but what said magus was more, “If you really care about performance so you have to learn all the language tricks which is , for example, don’t do the usual way to manipulate object”.
And multiplayer should also be a place where you have to take care of it depending to which one you work on (i think for example to GITC or CB where the perfomance is clearly not the main worry). But i heard about the java problem since the language update where I totally agree that complitely destroy any chance to compete on multiplayer like MM. ( And I hope they will find a solution as the problem of timeout for C/C++ in IDE)
A lot of people try to find the better way to egalize chance between language but it’s just a mess if they try to care of every language problem, and I think the current is a good one, because if you want to really compete about performance then use C/C++ which is normal to be better than others.
And you’re wrong about how sound the magus answer, most of people here like help other, GURU or not, and CG really try, as far as they can, to offer the better platform for everyone but it’s impossible for them to be perfect for everyone.
It could be the case if multiplayers puzzles were not based so much on performances. Actually there’s is some multiplayer puzzles where you can be top 10 without optimizing your code (CodeBuster, Back to the code, Ghost is the cell, Platinum Rift, Game of drone and C4L (RIP)). But you can’t blame players to use performances do resolve a multiplayer puzzle it’s part of the game.
I agree with reviewing if the new Java version is making GC much worse than before (maybe it’s some config), but about the rest I just link a post that reCurse pasted some time ago: http://www.sirlin.net/articles/playing-to-win
Nothing stops you on learning C++ if you think it’s that good. I learned it only for CG. And I know many others are more Java/C# guys that use C++ only for the performance.
There is definitely an issue with Java. I’ll see that we investigate this change of behavior.
Same for the C/C++ stack issue.
I most probably won’t have any news before January.
(see that I didn’t specify which year… just kidding )
About the C++ stack, yes, after the upgrade there are IDE timeouts, and I think runtime errors aren’t showing in many cases.
I have had many runtime error, with only a “Timeout” instead some hint about the problem. Hard to debug because in Visual Studio isn’t giving any issue.
Same problem here for scala (runs on the JVM). I have a lot of random timeout in code that did not timeout before. I suppose that at some point there is a huge GC cycle that takes place, which was not happening before.
Edit:
Beyond timeout issues, scala also faces an issue where the program does not start at all. I had this on WW. I just tested with my GitC bot and it’s the same. I tried to launch my bot 10 times and no game actually started. This code was working before.
I also have noticed the issue with Scala. My CSB bot held the 80thish position for a long time, but now it dropped to 160th and going down because every battle is lost because it times out, when it didn’t before, and no matter how ridiculously low computing time I set, it times out every single time. It just does not start at all. Hope this gets corrected soon because Scala is not an option (a viable one) right now in CodinGame, and I’ve used Scala for almost everything.
I also sincerely hope that scala gets fixed soon. I’ve worked a lot on my WW bot, but I can hardly test it in the arena with all the timeouts. I’m working locally currently, but I would love being able to use the arena again !
Update:
I believe there are two problems with scala:
The GC, which impacts all the JVM languages
Compiler timeout: it seems that if your code is too complex the compiler may take too long and your bot timeouts during the compilation phase. I tried with an older and simpler version and my bot starts almost every time. The scala compiler is known to be dead slow, and it didn’t improve with the most recent versions of the language. Maybe scala could be given a bit more compilation time ?