riddlesio / issues

Bug reports and starter bot submissions for the Riddles.io platform
0 stars 0 forks source link

Timeout problem #96

Closed oscarnava closed 6 years ago

oscarnava commented 6 years ago

I'm having periodic timeouts in my programs, but this only happens online, because when I use the AI Bot Workspace it never timeout. I don't know if this could be related to the language I'm using (Kotlin) but I have this problem with two different bots: GOLAD and TicTacToe.

In my TicTacToe bot I had to reduce my turn time from 100ms to 40ms; this reduces my timeouts, but not completely. At first I thought it was some obscure bug with my bot, but when this began happening also with GOLAD, I thought this could be related to the site.

For example, you can see in this match log that the bot doesn't even take the whole turn time (I'm reducing it by 10% to prevent this problem, but keeps appearing) for most of the turns, and suddenly apparently it stops, because the log shows it takes more than the 10s time bank.

https://starapple.riddles.io/competitions/game-of-life-and-death/matches/f488afa7-2d41-482a-86ba-0adf5be0713c

f488afa7-2d41-482a-86ba-0adf5be0713c_36f3b314-db79-4338-8f75-bc76aff61ad1_output_log.txt

Of course, as you can guess, this is having a negative impact in my scores :-S

BTW, my user is Monstruo. Thanks!

JimVanEeden commented 6 years ago

I can think of two things that could be happening:

oscarnava commented 6 years ago

Reporting my findings, it seems this was an issue of garbage collector halting my program enough time to cause this timeout, so effectively it was some flavor of the second cause yo mention. I solved it, for the time being, with a call to System.gc() after sending my output on every turn. This worked for both bots (GOLAD and TicTacToe), but I think I should try to optimize my use of resources.

Thanks for the response!

jmerle commented 6 years ago

A little note about the workspace: When running bots in the workspace, it's not run in a sandbox like on the Riddles.io servers, and it's memory is not limited neither. Therefore, performance in the workspace will probably never be the same as on the Riddles.io servers.

P.S. When working with a JVM language, you can prevent the garbage collector from running too often by simply not creating new objects all the time, but rather re-using existing objects (you could keep a pool of references to un-used objects, and take objects out of this pool instead of creating new ones when you need them).

JimVanEeden commented 6 years ago

I'm going to close this issue then.