When using MatchmakerOverride functionality, the Nakama internal code is providing all possible matches for specific matchmaker ticket. Method that is generating this possible matches (tickets combinations) is located here: https://github.com/heroiclabs/nakama/blob/master/server/matchmaker_process.go#L598
As stated in the comment it tries to loop through 1 to 2^length combinations (to be accurate 2^length - 1). This code is universal, since it’ll work for all the cases, but when we increase the number of tickets it’s execution time raises drastically:
- 1 ticket → 1 loop
- 5 tickets → 31 loops
- 10 tickets → 1023 loops
- 25 tickets → 33554431 loops
- 50 tickets → 1,125899907×10¹⁵ loops
As you can see, for not that quite big number of tickets in one matchmaker matching interval window, it gets insanely large and slow. Can we discuss any solution for such cases?
What did come to my mind is to change this method to provide not ALL possible matches, but change the logic to provide from biggest matching number of tickets first (from MAX to MIN). If none match is generated for MAX value, then try MAX-1, etc.
Any thoughts on this matter will be helpfull