Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7e9bc1c
Add protection against repeated use of one worker in a quiet cluster
douglasdavis Mar 26, 2021
19c5f40
move and rename test
douglasdavis Mar 26, 2021
59508e6
implement matt's first suggestion; passes cythonization
douglasdavis Mar 26, 2021
af580fa
add comments to current implementation
douglasdavis Mar 26, 2021
cb1bdc7
zoom into self._n_task; then linear search for 0 occupancy
douglasdavis Apr 1, 2021
78dd9e9
Update distributed/scheduler.py
douglasdavis Apr 2, 2021
a111b8d
Update distributed/scheduler.py
douglasdavis Apr 2, 2021
5c8f004
Update distributed/scheduler.py
douglasdavis Apr 2, 2021
4a0332e
Update distributed/scheduler.py
douglasdavis Apr 2, 2021
d4ce4a5
type annotations
douglasdavis Apr 2, 2021
309415c
simplify loop looking for next zero occupancy worker; inline comment
douglasdavis Apr 6, 2021
327af66
Merge branch 'main' into gh4637
douglasdavis Apr 6, 2021
dd2a99a
bring back test after conflict fix.
douglasdavis Apr 6, 2021
03de0d4
Update distributed/scheduler.py
douglasdavis Apr 6, 2021
74a81dc
trigger CI
douglasdavis Apr 8, 2021
8519691
Merge remote-tracking branch 'upstream/main' into gh4637
douglasdavis Apr 8, 2021
0fbbc9c
Update distributed/scheduler.py
mrocklin Apr 9, 2021
1dd5622
reuse worker_pool.values() via wp_vals value
douglasdavis Apr 9, 2021
107fbf4
Merge remote-tracking branch 'upstream/main' into gh4637
douglasdavis Apr 13, 2021
0258767
Merge remote-tracking branch 'upstream/main' into gh4637
douglasdavis Apr 13, 2021
6a768e1
implement suggestions from James related to test_retries (GH#4638)
douglasdavis Apr 13, 2021
f94dc0c
Merge remote-tracking branch 'upstream/main' into gh4637
douglasdavis Apr 14, 2021
85433d8
Merge branch 'main' of https://github.com/dask/distributed into gh4637
jrbourbeau Apr 15, 2021
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
17 changes: 15 additions & 2 deletions distributed/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2141,11 +2141,24 @@ def decide_worker(self, ts: TaskState) -> WorkerState:
else:
worker_pool = self._idle or self._workers
worker_pool_dv = cast(dict, worker_pool)
wp_vals = worker_pool.values()
n_workers: Py_ssize_t = len(worker_pool_dv)
Comment thread
douglasdavis marked this conversation as resolved.
if n_workers < 20: # smart but linear in small case
ws = min(worker_pool.values(), key=operator.attrgetter("occupancy"))
ws = min(wp_vals, key=operator.attrgetter("occupancy"))
if ws._occupancy == 0:
# special case to use round-robin; linear search
# for next worker with zero occupancy (or just
# land back where we started).
wp_i: WorkerState
start: Py_ssize_t = self._n_tasks % n_workers
i: Py_ssize_t
for i in range(n_workers):
wp_i = wp_vals[(i + start) % n_workers]
if wp_i._occupancy == 0:
Comment thread
jakirkham marked this conversation as resolved.
ws = wp_i
break
else: # dumb but fast in large case
ws = worker_pool.values()[self._n_tasks % n_workers]
ws = wp_vals[self._n_tasks % n_workers]

if self._validate:
assert ws is None or isinstance(ws, WorkerState), (
Expand Down
12 changes: 5 additions & 7 deletions distributed/tests/test_client_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,26 +210,24 @@ def test_unsupported_arguments(client, s, a, b):
def test_retries(client):
args = [ZeroDivisionError("one"), ZeroDivisionError("two"), 42]

with client.get_executor(retries=3, pure=False) as e:
with client.get_executor(retries=5, pure=False) as e:
future = e.submit(varying(args))
assert future.result() == 42

with client.get_executor(retries=2) as e:
with client.get_executor(retries=4) as e:
future = e.submit(varying(args))
result = future.result()
assert result == 42

with client.get_executor(retries=1) as e:
with client.get_executor(retries=2) as e:
future = e.submit(varying(args))
with pytest.raises(ZeroDivisionError) as exc_info:
with pytest.raises(ZeroDivisionError, match="two"):
res = future.result()
exc_info.match("two")

with client.get_executor(retries=0) as e:
future = e.submit(varying(args))
with pytest.raises(ZeroDivisionError) as exc_info:
with pytest.raises(ZeroDivisionError, match="one"):
res = future.result()
exc_info.match("one")


def test_shutdown(loop):
Expand Down
8 changes: 8 additions & 0 deletions distributed/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2234,3 +2234,11 @@ async def test_get_worker_monitor_info(s, a, b):
assert all(res[w.address]["range_query"][m] is not None for m in ms)
assert res[w.address]["count"] is not None
assert res[w.address]["last_time"] is not None


@gen_cluster(client=True)
async def test_quiet_cluster_round_robin(c, s, a, b):
await c.submit(inc, 1)
await c.submit(inc, 2)
await c.submit(inc, 3)
assert a.log and b.log