Skip to content

Commit

Permalink
Add config value QUEUE_POP_TIME_MIN to set lower bound for pop timers
Browse files Browse the repository at this point in the history
  • Loading branch information
Askaholic committed Apr 20, 2024
1 parent 2b159d6 commit dde9b46
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def __init__(self):
self.MAP_POOL_RATING_SELECTION = "mean"
# The maximum amount of time in seconds to wait between pops
self.QUEUE_POP_TIME_MAX = 90
# The minimum amount of time in seconds to wait between pops
self.QUEUE_POP_TIME_MIN = 15
# The number of possible matches we would like to have when the queue
# pops. The queue pop time will be adjusted based on the current rate of
# players queuing to try and hit this number.
Expand Down
8 changes: 8 additions & 0 deletions server/matchmaker/pop_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ def time_until_next_pop(self, num_queued: int, time_queued: float) -> float:
next_pop_time, self.queue.name, config.QUEUE_POP_TIME_MAX
)
return config.QUEUE_POP_TIME_MAX

if next_pop_time < config.QUEUE_POP_TIME_MIN:
self._logger.warning(
"Required time (%.2fs) for %s is lower than min pop time (%ds). ",
next_pop_time, self.queue.name, config.QUEUE_POP_TIME_MIN
)
return config.QUEUE_POP_TIME_MIN

return next_pop_time

def cancel(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_pop_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_queue_pop_time_moving_average_size(queue_factory):
t1.time_until_next_pop(100, 1)

# The rate should be extremely high, meaning the pop time should be low
assert t1.time_until_next_pop(100, 1) < 1
assert t1.time_until_next_pop(100, 1) == config.QUEUE_POP_TIME_MIN

for _ in range(config.QUEUE_POP_TIME_MOVING_AVG_SIZE):
t1.time_until_next_pop(0, 100)
Expand Down

0 comments on commit dde9b46

Please sign in to comment.