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

Config option to set worker cap #1659

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions server/fishtest/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import zlib
from datetime import datetime, timedelta

import fishtest.stats.stat_util
from bson.binary import Binary
from bson.objectid import ObjectId
from pymongo import DESCENDING, MongoClient

import fishtest.stats.stat_util
from fishtest.actiondb import ActionDb
from fishtest.stats.stat_util import SPRT_elo
from fishtest.userdb import UserDb
Expand All @@ -32,14 +34,30 @@
worker_name,
)
from fishtest.views import del_tasks
from pymongo import DESCENDING, MongoClient

DEBUG = False

boot_time = datetime.utcnow()

last_rundb = None

server_config = None


def get_server_config():
global server_config
if server_config is None:
server_config = configparser.ConfigParser()
server_config["worker"] = {
"GamesCap": "9000",
}
config_path = os.path.expanduser("~/fishtest.ini")
if os.path.exists(config_path):
server_config.read(config_path)
if server_config["worker"]["GamesCap"] % 2 == 1:
server_config["worker"]["GamesCap"] += 1
return server_config


def get_port():
params = {}
Expand Down Expand Up @@ -470,7 +488,9 @@ def aggregate_unfinished_runs(self, username=None):
runs = {"pending": [], "active": []}
for run in unfinished_runs:
state = (
"active" if any(task["active"] for task in reversed(run["tasks"])) else "pending"
"active"
if any(task["active"] for task in reversed(run["tasks"]))
else "pending"
)
if state == "pending":
run["workers"] = run["cores"] = 0
Expand Down Expand Up @@ -867,7 +887,11 @@ def priority(run): # lower is better
remaining / sprt_batch_size_games
)

task_size = min(self.worker_cap(run, worker_info), remaining)
config = get_server_config()
config_worker_cap = max(2, int(config["worker"]["GamesCap"]))
task_size = min(
config_worker_cap, min(self.worker_cap(run, worker_info), remaining)
)
task = {
"num_games": task_size,
"active": True,
Expand Down