Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(policy): compute desired number of matches before rooms #654

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

hspedro
Copy link
Collaborator

@hspedro hspedro commented Jan 7, 2025

If we first divide the number of running matches per maxMatches we might end up with a number between 0 and 1, which is quirky when using math.Ceil because it would propagate the error to when computing number of desired rooms. To simplify and fix this, instead we now compute how many matches is the desired and then convert the final number to the amount of rooms/instances/pods needed to provide this number of matches:

  1. How many running matches we have?
  • Get the value from the redis: scheduler:<scheduler_name>:occupancy
  1. How many matches do we need to have based on readyTarget?
  • Divide running matches by 1 - readyTarget
  1. How many game rooms are needed to provide this amount of matches?
  • Get the desired number of matches and divide by the max number of matches per room as defined in the scheduler

If we first divide the number of running matches per maxMatches
we might end up with a number between 0 and 1, which is quirky
when using math.Ceil because it would propagate the error to when
computing number of desired rooms. To simplify and fix this, instead
we now compute how many matches is the desired and then convert
the final number to the amount of rooms/instances/pods needed to
provide this number of matches:

1. How many running matches we have?
* Get the value from the redis: scheduler:<scheduler_name>:occupancy
2. How many matches do we need to have based on readyTarget?
* Divide running matches by 1 - readyTarget
3. How many game rooms are needed to provide this amount of matches?
* Get the desired number of matches and divide by the max number of matches
per room as defined in the scheduler
@hspedro hspedro requested a review from reinaldooli January 7, 2025 18:03
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (feature/multiple-matches@6dac23b). Learn more about missing BASE report.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@                     Coverage Diff                     @@
##             feature/multiple-matches     #654   +/-   ##
===========================================================
  Coverage                            ?   62.02%           
===========================================================
  Files                               ?      141           
  Lines                               ?    12111           
  Branches                            ?        0           
===========================================================
  Hits                                ?     7512           
  Misses                              ?     4281           
  Partials                            ?      318           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@reinaldooli reinaldooli merged commit feb104a into feature/multiple-matches Jan 7, 2025
12 checks passed
@reinaldooli reinaldooli deleted the fix/multiple-matches-ceil branch January 7, 2025 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants