diff --git a/server/fishtest/rundb.py b/server/fishtest/rundb.py index 2e14c5d5c..539fc2e30 100644 --- a/server/fishtest/rundb.py +++ b/server/fishtest/rundb.py @@ -639,7 +639,7 @@ def get_results(self, run, save_run=True): return results - def calc_itp(self, run, count): + def calc_itp(self, run, total_tp): itp = run["args"]["throughput"] itp = max(min(itp, 500), 1) @@ -668,9 +668,12 @@ def calc_itp(self, run, count): itp *= bonus # Malus for too many active runs - itp *= 36.0 / (36.0 + count * count) + # We scale based on total TP across all runs from this user + count = max(total_tp / 100.0, 1.0) + capped_count = min(count, 6.0) # cap at total 300 itp per user + itp *= 36.0 / (36.0 + capped_count * capped_count) * (capped_count / count) - run["args"]["itp"] = itp + return itp def update_workers_cores(self, run): workers = cores = 0 @@ -767,19 +770,21 @@ def sync_request_task(self, worker_info): if runs_finished or time.time() > self.task_time + 60: print("Request_task: refresh queue", flush=True) - # list user names for active runs + # list user names and ITP for active runs user_active = [] for r in self.get_unfinished_runs_id(): run = self.get_run(r["_id"]) if any(task["active"] for task in reversed(run["tasks"])): - user_active.append(run["args"].get("username")) + user_active.append((run["args"].get("username"), run["args"].get("throughput"))) - # now compute their itp + # now compute and update their itp self.task_runs = [] for r in self.get_unfinished_runs_id(): run = self.get_run(r["_id"]) self.update_workers_cores(run) - self.calc_itp(run, user_active.count(run["args"].get("username"))) + run_user = run["args"].get("username") + total_tp = sum([tp for user, tp in user_active if user == run_user]) + run["args"]["itp"] = self.calc_itp(run, total_tp) self.task_runs.append(run) self.task_time = time.time()