Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions distributed/distributed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ distributed:
idle-timeout: null # Shut down after this duration, like "1h" or "30 minutes"
transition-log-length: 100000
work-stealing: True # workers should steal tasks from each other
work-stealing-interval: 100ms # Callback time for work stealing
worker-ttl: null # like '60s'. Time to live for workers. They must heartbeat faster than this
pickle: True # Is the scheduler allowed to deserialize arbitrary bytestrings
preload: []
Expand Down
11 changes: 9 additions & 2 deletions distributed/stealing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import dask
from .core import CommClosedError
from .diagnostics.plugin import SchedulerPlugin
from .utils import log_errors, PeriodicCallback
from .utils import log_errors, parse_timedelta, PeriodicCallback

try:
from cytoolz import topk
Expand Down Expand Up @@ -40,8 +40,15 @@ def __init__(self, scheduler):
for worker in scheduler.workers:
self.add_worker(worker=worker)

# `callback_time` is in milliseconds
callback_time = 1000 * parse_timedelta(
dask.config.get("distributed.scheduler.work-stealing-interval"),
default="ms",
Comment thread
TomAugspurger marked this conversation as resolved.
)
pc = PeriodicCallback(
callback=self.balance, callback_time=100, io_loop=self.scheduler.loop
callback=self.balance,
callback_time=callback_time,
io_loop=self.scheduler.loop,
)
self._pc = pc
self.scheduler.periodic_callbacks["stealing"] = pc
Expand Down
18 changes: 18 additions & 0 deletions distributed/tests/test_steal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from toolz import sliding_window, concat
from tornado import gen

import dask
from distributed import Nanny, Worker, wait, worker_client
from distributed.config import config
from distributed.metrics import time
Expand Down Expand Up @@ -676,3 +677,20 @@ def test_lose_task(c, s, a, b):

out = log.getvalue()
assert "Error" not in out


@gen_cluster(client=True)
def test_worker_stealing_interval(c, s, a, b):
from distributed.scheduler import WorkStealing

ws = WorkStealing(s)
assert ws._pc.callback_time == 100

with dask.config.set({"distributed.scheduler.work-stealing-interval": "500ms"}):
ws = WorkStealing(s)
assert ws._pc.callback_time == 500

# Default unit is `ms`
with dask.config.set({"distributed.scheduler.work-stealing-interval": 2}):
ws = WorkStealing(s)
assert ws._pc.callback_time == 2