Skip to content

Commit 584aa42

Browse files
rjogradycopybara-github
authored andcommitted
Randomize the order of selecting CPUs when we try to dispatch benchmarks onto workers.
This avoids a bias towards the lower-numbered CPUs. PiperOrigin-RevId: 803187095 Change-Id: I829b956b86dc8d8498d62cdbe2fc60c3ce8bf9db
1 parent 3c50bd2 commit 584aa42

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fleetbench/parallel/parallel_bench_lib.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,13 @@ def _RunSchedulingLoop(self) -> None:
353353

354354
self.utilization_samples.append((pd.Timestamp.now(), total_utilization))
355355

356+
# Avoid biasing towards lower-numbered CPUs by randomizing the order here.
357+
# That way CPUs with the same utilization will be randomly selected.
358+
cpu_util_items = list(utilization_per_cpu.items())
359+
np.random.shuffle(cpu_util_items)
360+
356361
least_busy_cpus = collections.OrderedDict(
357-
sorted(utilization_per_cpu.items(), key=lambda item: item[1])
362+
sorted(cpu_util_items, key=lambda item: item[1])
358363
)
359364

360365
# E.g. we are at 50% utilization, target is 70%.

0 commit comments

Comments
 (0)