From b6b362bbfddfe50beead7eadda1f6edd2b0bcabc Mon Sep 17 00:00:00 2001 From: Fernando Takagi Date: Tue, 4 Apr 2023 09:01:56 -0300 Subject: [PATCH] Matchmaker ticket processing improvement. (#1007) --- server/matchmaker.go | 5 +++++ server/matchmaker_test.go | 27 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/server/matchmaker.go b/server/matchmaker.go index 71ea6e02e..05942fbab 100644 --- a/server/matchmaker.go +++ b/server/matchmaker.go @@ -342,6 +342,11 @@ func (m *LocalMatchmaker) Process() { } } + // This ticket may already have found a match in a previous iteration. + if _, found := selectedTickets[activeIndex.Ticket]; found { + continue + } + activeIndex.Intervals++ lastInterval := activeIndex.Intervals >= m.config.GetMatchmaker().MaxIntervals || activeIndex.MinCount == activeIndex.MaxCount if lastInterval { diff --git a/server/matchmaker_test.go b/server/matchmaker_test.go index 9b85d193f..4bb5beb67 100644 --- a/server/matchmaker_test.go +++ b/server/matchmaker_test.go @@ -2438,26 +2438,31 @@ func BenchmarkMatchmakerProcessTickets100_min2_max2(b *testing.B) { benchmarkMatchmakerProcessTickets(100, 50, 2, 2, b) } func BenchmarkMatchmakerProcessTickets500_min2_max2(b *testing.B) { - benchmarkMatchmakerProcessTickets(500, 5000, 2, 2, b) + benchmarkMatchmakerProcessTickets(500, 250, 2, 2, b) } func BenchmarkMatchmakerProcessTickets1_000_min2_max2(b *testing.B) { - benchmarkMatchmakerProcessTickets(1_000, 5000, 2, 2, b) -} -func BenchmarkMatchmakerProcessTickets10_000_min2_max2(b *testing.B) { - benchmarkMatchmakerProcessTickets(10_000, 5000, 2, 2, b) + benchmarkMatchmakerProcessTickets(1_000, 100, 2, 2, b) } +//func BenchmarkMatchmakerProcessTickets10_000_min2_max2(b *testing.B) { +// benchmarkMatchmakerProcessTickets(10_000, 5000, 2, 2, b) +//} + /*func BenchmarkMatchmakerProcessTickets100_000_min2_max2(b *testing.B) { benchmarkMatchmakerProcessTickets(100_000, 2, 2, b) }*/ -//func BenchmarkMatchmakerProcessTickets100_min4_max4(b *testing.B) { -// benchmarkMatchmakerProcessTickets(100, 4, 4, b) -//} -//func BenchmarkMatchmakerProcessTickets1_000_min4_max4(b *testing.B) { -// benchmarkMatchmakerProcessTickets(1_000, 4, 4, b) -//} +func BenchmarkMatchmakerProcessTickets100_min4_max10(b *testing.B) { + benchmarkMatchmakerProcessTickets(100, 10, 4, 10, b) +} +func BenchmarkMatchmakerProcessTickets500_min4_max10(b *testing.B) { + benchmarkMatchmakerProcessTickets(500, 50, 4, 10, b) +} +func BenchmarkMatchmakerProcessTickets1_000_min4_max10(b *testing.B) { + benchmarkMatchmakerProcessTickets(1_000, 100, 4, 10, b) +} + //func BenchmarkMatchmakerProcessTickets10_000_min4_max4(b *testing.B) { // benchmarkMatchmakerProcessTickets(10_000, 4, 4, b) //} -- GitLab