-
-
Notifications
You must be signed in to change notification settings - Fork 734
All tasks without dependencies are root-ish #7221
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
Open
gjoseph92
wants to merge
25
commits into
dask:main
Choose a base branch
from
gjoseph92:no-deps-is-rootish
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
1569df3
All tasks without dependencies are root-ish
gjoseph92 a75d057
fix `test_retries`
gjoseph92 1d9fce9
fix `distributed/diagnostics/tests/test_graph_layout.py::test_states`
gjoseph92 d20717f
fix `distributed/tests/test_cancelled_state.py::test_executing_cancel…
gjoseph92 841b0f2
fix `distributed/tests/test_worker_memory.py::test_pause_executor_man…
gjoseph92 0530ec6
driveby: async_wait_for
gjoseph92 bb33863
fix `distributed/tests/test_worker_memory.py::test_pause_executor_wit…
gjoseph92 abf36de
WIP update test_priorities
gjoseph92 9a040d2
Get test_priorities working
gjoseph92 d56f7f3
fix `test_states` for queuing disabled
gjoseph92 55818de
fix `test_retries`
gjoseph92 0e6901b
skip round robin for queuing
gjoseph92 a47ac74
Fix co-assignment when group smaller than cluster
gjoseph92 1cd75cb
`test_profile_plot` determinism
gjoseph92 913b511
Update distributed/tests/test_priorities.py
gjoseph92 680c538
Merge branch 'main' into no-deps-is-rootish
crusaderky 4c684a2
Refactor for clarity
crusaderky c901823
remove dead round-robin code
gjoseph92 3806164
test `c.submit` doesn't cut in line
gjoseph92 45b9bbd
remove `test_quiet_cluster_round_robin`
gjoseph92 0db898d
Special-case no-worker tasks that became root-ish
gjoseph92 e9be596
Copy over tests
gjoseph92 5985419
Revert "Copy over tests"
gjoseph92 c556762
Revert "Special-case no-worker tasks that became root-ish"
gjoseph92 17f1ba4
actors aren't rootish
gjoseph92 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,14 @@ | |
import dask | ||
from dask import delayed | ||
|
||
from distributed import Client, Event, Scheduler, Status, Worker, wait | ||
from distributed.utils_test import gen_cluster, inc, slowinc | ||
from distributed import Client, Event, Scheduler, Status, Worker | ||
from distributed.utils_test import ( | ||
async_wait_for, | ||
gen_cluster, | ||
inc, | ||
slowinc, | ||
wait_for_state, | ||
) | ||
|
||
dinc = delayed(inc) | ||
dslowinc = delayed(slowinc) | ||
|
@@ -35,8 +41,8 @@ async def block_worker( | |
pause : bool | ||
True | ||
When entering the context manager, pause the worker. At exit, wait for all | ||
tasks created inside the context manager to be added to Scheduler.unrunnable | ||
and then unpause the worker. | ||
tasks created inside the context manager to be added to ``Scheduler.unrunnable`` | ||
or ``Scheduler.queued`` and then unpause the worker. | ||
False | ||
When entering the context manager, send a dummy long task to the worker. At | ||
exit, wait for all tasks created inside the context manager to reach the | ||
|
@@ -51,48 +57,40 @@ async def block_worker( | |
""" | ||
if pause: | ||
w.status = Status.paused | ||
while s.workers[w.address].status != Status.paused: | ||
await asyncio.sleep(0.01) | ||
await async_wait_for( | ||
lambda: s.workers[w.address].status == Status.paused, timeout=5 | ||
) | ||
else: | ||
ev = Event() | ||
clog = c.submit(lambda ev: ev.wait(), ev, key="block_worker") | ||
while "block_worker" not in w.state.tasks: | ||
await asyncio.sleep(0.01) | ||
clog = c.submit(ev.wait, key="block_worker") | ||
await wait_for_state(clog.key, "executing", w) | ||
|
||
yield | ||
|
||
if ntasks_on_scheduler is None: | ||
ntasks_on_scheduler = len(c.futures) | ||
if ntasks_on_worker is None: | ||
ntasks_on_worker = len(c.futures) | ||
while len(s.tasks) < ntasks_on_scheduler: | ||
await asyncio.sleep(0.01) | ||
await async_wait_for(lambda: len(s.tasks) >= ntasks_on_scheduler, timeout=5) | ||
|
||
if pause: | ||
assert len(s.unrunnable) == ntasks_on_worker | ||
assert ( | ||
len(s.unrunnable) == ntasks_on_worker or len(s.queued) == ntasks_on_worker | ||
) | ||
assert not w.state.tasks | ||
w.status = Status.running | ||
else: | ||
while len(w.state.tasks) < ntasks_on_worker: | ||
await asyncio.sleep(0.01) | ||
await ev.set() | ||
await clog | ||
del clog | ||
while "block_worker" in s.tasks: | ||
await asyncio.sleep(0.01) | ||
await async_wait_for(lambda: "block_worker" not in s.tasks, timeout=5) | ||
|
||
|
||
def gen_blockable_cluster(test_func): | ||
"""Generate a cluster with 1 worker and disabled memory monitor, | ||
to be used together with ``async with block_worker(...):``. | ||
""" | ||
return pytest.mark.parametrize( | ||
"pause", | ||
[ | ||
pytest.param(False, id="queue on worker"), | ||
pytest.param(True, id="queue on scheduler"), | ||
], | ||
Comment on lines
-92
to
-94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove the ids? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They weren't accurate anymore. I could call then |
||
)( | ||
return pytest.mark.parametrize("pause", [False, True])( | ||
gen_cluster( | ||
client=True, | ||
nthreads=[("", 1)], | ||
|
@@ -109,11 +107,11 @@ async def test_submit(c, s, a, pause): | |
clog = c.submit(lambda ev: ev.wait(), ev, key="clog") | ||
high = c.submit(inc, 2, key="high", priority=1) | ||
|
||
await wait(high) | ||
assert all(ws.processing for ws in s.workers.values()) | ||
assert s.tasks[low.key].state == "processing" | ||
await high | ||
assert s.tasks[clog.key].state == "processing" | ||
assert s.tasks[low.key].state != "memory" | ||
await ev.set() | ||
await wait(low) | ||
await low | ||
|
||
|
||
@gen_blockable_cluster | ||
|
@@ -124,12 +122,12 @@ async def test_map(c, s, a, pause): | |
clog = c.submit(lambda ev: ev.wait(), ev, key="clog") | ||
high = c.map(inc, [4, 5, 6], key=["h1", "h2", "h3"], priority=1) | ||
|
||
await wait(high) | ||
assert all(ws.processing for ws in s.workers.values()) | ||
assert all(s.tasks[fut.key].state == "processing" for fut in low) | ||
await c.gather(high) | ||
assert s.tasks[clog.key].state == "processing" | ||
assert all(s.tasks[fut.key].state != "memory" for fut in low) | ||
await ev.set() | ||
await clog | ||
await wait(low) | ||
await c.gather(low) | ||
|
||
|
||
@gen_blockable_cluster | ||
|
@@ -140,12 +138,12 @@ async def test_compute(c, s, a, pause): | |
clog = c.submit(lambda ev: ev.wait(), ev, key="clog") | ||
high = c.compute(dinc(2, dask_key_name="high"), priority=1) | ||
|
||
await wait(high) | ||
assert all(ws.processing for ws in s.workers.values()) | ||
assert s.tasks[low.key].state == "processing" | ||
await high | ||
assert s.tasks[clog.key].state == "processing" | ||
assert s.tasks[low.key].state != "memory" | ||
await ev.set() | ||
await clog | ||
await wait(low) | ||
await low | ||
|
||
|
||
@gen_blockable_cluster | ||
|
@@ -156,12 +154,12 @@ async def test_persist(c, s, a, pause): | |
clog = c.submit(lambda ev: ev.wait(), ev, key="clog") | ||
high = dinc(2, dask_key_name="high").persist(priority=1) | ||
|
||
await wait(high) | ||
assert all(ws.processing for ws in s.workers.values()) | ||
assert s.tasks[low.key].state == "processing" | ||
await high | ||
assert s.tasks[clog.key].state == "processing" | ||
assert s.tasks[low.key].state != "memory" | ||
await ev.set() | ||
await wait(clog) | ||
await wait(low) | ||
await clog | ||
await low | ||
|
||
|
||
@gen_blockable_cluster | ||
|
@@ -176,11 +174,11 @@ async def test_annotate_compute(c, s, a, pause): | |
async with block_worker(c, s, a, pause): | ||
low, clog, high = c.compute([low, clog, high], optimize_graph=False) | ||
|
||
await wait(high) | ||
assert s.tasks[low.key].state == "processing" | ||
await high | ||
assert s.tasks[low.key].state != "memory" | ||
await ev.set() | ||
await wait(clog) | ||
await wait(low) | ||
await clog | ||
await low | ||
|
||
|
||
@gen_blockable_cluster | ||
|
@@ -195,11 +193,11 @@ async def test_annotate_persist(c, s, a, pause): | |
async with block_worker(c, s, a, pause): | ||
low, clog, high = c.persist([low, clog, high], optimize_graph=False) | ||
|
||
await wait(high) | ||
assert s.tasks[low.key].state == "processing" | ||
await high | ||
assert s.tasks[low.key].state != "memory" | ||
await ev.set() | ||
await wait(clog) | ||
await wait(low) | ||
await clog | ||
await low | ||
|
||
|
||
@gen_blockable_cluster | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to change these retries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is extremely sensitive to how workers are selected on an idle cluster. It uses this stateful
varying
utility, which changes its behavior depending on how many times it's been called on that worker.It had to be changed when the idle-round-robin behavior was added: https://github.com/dask/distributed/pull/4638/files#diff-59af67191283f0c64a3be8ce1f344f49b9d025f8264b77fba5c8250865bde433
So I've had to change it again since it's being removed.