Skip to content

Commit 4026b1c

Browse files
committed
docs: justify 0.5 margin factor and clarify threshold changes in tests
1 parent f3a24e3 commit 4026b1c

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

distributed/stealing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,9 @@ def balance(self) -> None:
488488
comm_cost_victim = self.scheduler.get_comm_cost(ts, victim)
489489
compute = self.scheduler._get_prefix_duration(ts.prefix)
490490

491-
# Require at least 50% ROI on the network transfer cost to prevent thrashing
491+
# Be conservative about marginal steals: require headroom equal
492+
# to 50% of the thief's transfer cost to absorb estimation noise
493+
# and routine network jitter.
492494
margin = comm_cost_thief * 0.5
493495

494496
would_steal_without_margin = (

distributed/tests/test_steal.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,8 @@ def func(*args):
14491449
"cost, ntasks, expect_steal",
14501450
[
14511451
pytest.param(10, 10, False, id="not enough work to steal"),
1452+
# The 50% margin heuristic raises the minimum backlog needed to justify
1453+
# stealing these expensive tasks; 12 was enough before, 17 is enough now.
14521454
pytest.param(10, 17, True, id="enough work to steal"),
14531455
pytest.param(20, 17, False, id="not enough work for increased cost"),
14541456
],
@@ -2028,6 +2030,9 @@ async def test_reject_count_margin_metric(c, s, a, b):
20282030
steal = s.extensions["stealing"]
20292031
await steal.stop()
20302032

2033+
# Use enough short tasks to satisfy Scheduler.check_idle_saturated() for a
2034+
# single busy worker while still keeping the steal in the margin-rejection
2035+
# window once get_comm_cost() is patched below.
20312036
futures = c.map(
20322037
slowidentity,
20332038
range(21),

0 commit comments

Comments
 (0)