Don't count time spent in Python towards the player#148
Don't count time spent in Python towards the player#148joshuagruenstein merged 1 commit intobattlecode:masterfrom
Conversation
|
Correct me if I'm wrong, but as |
|
No, it doesn't -- self time doesn't count time spent in the kernel, waiting. It would count time spent in other threads, so if there are such this might be a bad idea. Moving |
|
Yeah, if I introduce a mid_time_python, Gotta be the line buffering that's the problem. |
|
Cool, looks good. Just merged this. We'll look over #149 a lil more and do some testing before merging it. |
We're seeing a lot of time spent in Python (inefficient IO?) rather than in the player in our profiles. When I add a debug print in the python time measuring code to also count Python processor self time, I get measurements like the following:
where "Turn time" is the value we measure from
clock()in our C++ code, the first value of "times" is what the Python code currently measures, and the second value of "times" is the difference intime.process_time()for the same block of code that Python measures (lines sometimes appear in the wrong order due to buffering). It's clear that most time is spent in Python, and that the first value minus the second is a much better approximation of the time used by the bot than the current one. I get similar values outside of docker, there typically with less time spent in Python I think (but it might also just have been different maps).This will hopefully address timeouts due to large numbers of units in upcoming tournaments. Optimizing the Python code (I'm sort of suspecting the line-buffered IO??) is left as future work. :)