battlecode / galaxy

MIT License
10 stars 3 forks source link

Run the matches of different tournament rounds in parallel #725

Closed n8kim1 closed 6 months ago

n8kim1 commented 6 months ago

As a round finishes, and only a match is left... the tournament runner has to wait for this match to finish, and can't get started early on the next round. This is a painful bottleneck.

It would be cool to run rounds in parallel (eg even if not all first-round matches are done, begin the second round anyways). However, rounds in parallel would be much faster, but also much trickier, as it might have a lot of trickiness and bugs. And, it becomes much harder to reason about the state of our database. Matches in the DB would no longer be naturally "sorted" by round order.

For example, we could when a match is done, query for matches that are newly "open" and have not yet been already entered in DB and fired off to scrim servers. But, you'd have to make sure that two servers don't see the same newly open things and thus create multiple matches in our database for the same tournament match (the same "actual match"). Perhaps this is work-aroundable via locking.

Also, implement whether or not to run in one go as a configurable setting per tournament. Is helpful in case this fast mode breaks.

j-mao commented 6 months ago

I'm not sure the complexity is worth the speed improvement. I recall we made the conscious decision not to do this for this precise reason: it's a minor speed increase but, as you observe, a major increase to code complexity and maintainability. Would advocate not doing this, purely for the sake of "3 years later, some dev will read this code and be utterly confused".

n8kim1 commented 6 months ago

yup (and I chose not to do it, especially in favor of other things that provide speedup and are much easier)

But in fact now that you mention it... what if we explicitly close as "won't do", just to have that decision written down somewhere and make it more visible