You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Work stealing in case of job restrictions / resources would be useful #1389
If a task has been specifically restricted to run on particular workers (such as is the case when special hardware is required) then we do not steal.
This probably makes sense when a task is bound to a single or few workers, however the general case of host and resource restrictions might benefit from stealing.
For enabling work stealing within the resource framework (which is not excluded in the documentation), might it be enough to choose out of the idle workers the first one that matches the key's resources?
I think this would involve the following changes:
In WorkStealing.steal_time_ratio resource limited tasks would no longer be excluded:
if (keynotinself.scheduler.loose_restrictionsand (keyinself.scheduler.host_restrictionsorkeyinself.scheduler.worker_restrictions)):# or#key in self.scheduler.resource_restrictions):returnNone, None# don't steal
In WorkStealing.balance, this would take care of choosing a matching worker before the two calls of WorkStealing.move_task:
i+=1# in case the key has resource_restrictions,# set i to next worker providing themifkeyinself.scheduler.resource_restrictions.keys():
resource_i=self.next_resource_i(
idle,
self.scheduler.resource_restrictions[key],
start_index=i)
ifresource_iisNone:
continueelse:
i=resource_i
with a new method of WorkStealing as such:
defnext_resource_i(self,workers,resources,start_index=0):
""" Increases start_index until index % len(workers) points to a worker which provides the resources. If no such worker exist, returns None. """foriinrange(start_index, len(workers) +start_index):
iworker=i%len(workers)
suitable=Trueforresource,quantityinresources.items():
ifnotself.scheduler.worker_resources[workers[iworker]].has_key(resource) or \
quantity>self.scheduler.worker_resources[workers[iworker]][resource]:
suitable=Falsebreakifsuitable:
returnireturnNone
Additionally, the shift of resources would need to be handled. In WorkStealing.move_task, this would mean to add:
Then there would be one last change in scheduler.py, since resources would need to be released from the right worker. In Scheduler.transition_processing_memory, the release of resources would need to be shifted behind w = self.rprocessing.pop(key)
For some simple test cases this seems to be working for me. Resource restricted tasks are redistributed among the workers and scheduler.used_resources seems to be behaving as expected.
Sorry for the long comment, but probably this is too early for a Pull Request. Thanks!
For scheduling on resource restrictions you'll want to both ensure that the worker still has those resources (remember that semantically resources get used up as tasks run on those workers), and you may want to choose the best worker with those resources, rather than do a round-robin. See Scheduler.worker_objective.
Additionally we tend to only steal onto workers that are idling.
For scheduling on resource restrictions you'll want to both ensure that the worker still has those resources (remember that semantically resources get used up as tasks run on those workers)
Yes, if I understand correctly only idle workers can be thiefs. The resource check in next_resource_i(idle..) compares to the total resources available to the idle workers (for idle workers scheduler.used_resources[w] == scheduler.worker_resources[w]).
and you may want to choose the best worker with those resources, rather than do a round-robin. See Scheduler.worker_objective.
In the current implementation of WorkStealing, Scheduler.worker_objective doesn't seem to be taken into account (but only for the initial worker assignment using Scheduler.decide_worker). Of course the best idle worker (for example the one with most available relevant resources) could be chosen from the idle worker list within next_resource_i.
Related to this:
Is it possible that currently workers are not being checked for 'still available' resources? The relevant lines seem to be 3099-3102 in scheduler.py:
Yes, if I understand correctly only idle workers can be thiefs. The resource check in next_resource_i(idle..) compares to the total resources available to the idle workers (for idle workers scheduler.used_resources[w] == scheduler.worker_resources[w]).
Yes that's a valid point. If you're only taking from idling workers then we don't really care about best. Any from that set will do. Sorry for being a bit sloppy in my suggestions. My brain is cycling over a few things.
It's technically valid to schedule a task to a worker who is running low on resources (the worker will wait until resources are freed) but you're right that it would be nicer to prefer workers who can run the task sooner.
True, so probably any idle worker with sufficient resources should be a good choice.
Actually, related to my last point above: In scheduler.py, shoudn't self.used_resources be initialised with {r:0 for r in resources.keys()}?
defadd_resources(self, stream=None, worker=None, resources=None):
ifworkernotinself.worker_resources:
self.worker_resources[worker] =resourcesself.used_resources[worker] =resources# shoudn't this be {r:0 for r in resources.keys()}?forresource, quantityinresources.items():
self.resources[resource][worker] =quantityreturn'OK'
On Wed, Sep 13, 2017 at 1:29 PM, quakberto ***@***.***> wrote:
True, so probably any idle worker with sufficient resources should be a
good choice.
Actually, related to my last point above: In scheduler.py, shoudn't
self.used_resources be initialised with {r:0 for r in resources.keys()}?
def add_resources(self, stream=None, worker=None, resources=None):
if worker not in self.worker_resources:
self.worker_resources[worker] = resources
self.used_resources[worker] = resources # shoudn't this be {r:0 for r in resources.keys()}?
for resource, quantity in resources.items():
self.resources[resource][worker] = quantity
return 'OK'
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1389 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASszKSYqDc0czh-yVl1UKa1pqfspvDZks5siBDpgaJpZM4PV1V->
.
What is the motivation for host and worker restrictions blocking work stealing?
Surely there could easily be a situation where the worker or host restrictions for a particular task is a list of say 10 hosts out of 50 hosts. Any of the hosts from the restricted host list would do just fine.
For the worker_restrictions this would seem to be a fairly simple filter on idle before the thief worker is selected
if ts.worker_restrictions:
idle = [ws for ws in idle if ws.address in ts.worker_restrictions]
handling the host host_restrictions seems a bit more complicated as getting the host names seems not to be straightforward.
On Thu, Mar 22, 2018 at 7:31 AM, Matti Lyra ***@***.***> wrote:
What is the motivation for host and worker restrictions blocking work
stealing?
Surely there could easily be a situation where the worker or host
restrictions for a particular task is a list of say 10 hosts out of 50
hosts. Any of the hosts from the restricted host list would do just fine.
For the worker_restrictions this would seem to be a fairly simple filter
on idle before the thief worker is selected
if ts.worker_restrictions:
idle = [ws for ws in idle if ws.address in ts.worker_restrictions]
handling the host host_restrictions seems a bit more complicated as
getting the host names seems not to be straightforward.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1389 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASszFYT5HR-Oby6gc6kk25_4S6WDvPzks5tg4uYgaJpZM4PV1V->
.
Activity
m-albert commentedon Sep 13, 2017
I was looking into stealing.py.
For enabling work stealing within the resource framework (which is not excluded in the documentation), might it be enough to choose out of the idle workers the first one that matches the key's resources?
I think this would involve the following changes:
In
WorkStealing.steal_time_ratioresource limited tasks would no longer be excluded:In
WorkStealing.balance, this would take care of choosing a matching worker before the two calls ofWorkStealing.move_task:with a new method of
WorkStealingas such:Additionally, the shift of resources would need to be handled. In
WorkStealing.move_task, this would mean to add:Then there would be one last change in
scheduler.py, since resources would need to be released from the right worker. InScheduler.transition_processing_memory, the release of resources would need to be shifted behindw = self.rprocessing.pop(key)For some simple test cases this seems to be working for me. Resource restricted tasks are redistributed among the workers and
scheduler.used_resourcesseems to be behaving as expected.Sorry for the long comment, but probably this is too early for a Pull Request. Thanks!
mrocklin commentedon Sep 13, 2017
For scheduling on resource restrictions you'll want to both ensure that the worker still has those resources (remember that semantically resources get used up as tasks run on those workers), and you may want to choose the best worker with those resources, rather than do a round-robin. See
Scheduler.worker_objective.Additionally we tend to only steal onto workers that are idling.
m-albert commentedon Sep 13, 2017
Thanks for the feedback!
Yes, if I understand correctly only idle workers can be thiefs. The resource check in
next_resource_i(idle..)compares to the total resources available to the idle workers (for idle workersscheduler.used_resources[w]==scheduler.worker_resources[w]).In the current implementation of
WorkStealing,Scheduler.worker_objectivedoesn't seem to be taken into account (but only for the initial worker assignment usingScheduler.decide_worker). Of course the best idle worker (for example the one with most available relevant resources) could be chosen from the idle worker list withinnext_resource_i.Related to this:
Is it possible that currently workers are not being checked for 'still available' resources? The relevant lines seem to be 3099-3102 in
scheduler.py:Shouldn't
suppliedbe taken from the difference between the quantities inself.resourcesandself.used_resourcesrather than only fromself.resources?mrocklin commentedon Sep 13, 2017
Yes that's a valid point. If you're only taking from idling workers then we don't really care about best. Any from that set will do. Sorry for being a bit sloppy in my suggestions. My brain is cycling over a few things.
It's technically valid to schedule a task to a worker who is running low on resources (the worker will wait until resources are freed) but you're right that it would be nicer to prefer workers who can run the task sooner.
m-albert commentedon Sep 13, 2017
True, so probably any idle worker with sufficient resources should be a good choice.
Actually, related to my last point above: In
scheduler.py, shoudn'tself.used_resourcesbe initialised with{r:0 for r in resources.keys()}?mrocklin commentedon Sep 13, 2017
vincentschut commentedon Oct 20, 2017
Apparently I am running into this (https://stackoverflow.com/questions/46849315/schedule-tasks-based-purely-on-idleness-instead-of-data-communication, I first thought the cause was different). This issue seems stalled? Is implementing this still somewhere on the agenda? Or should I not hold my breath and find a workaround...?
mrocklin commentedon Oct 20, 2017
If you have time to try to resolve this issue that would be very welcome @vincentschut .
Support work stealing for resource restricted tasks (see issue dask#1389
mattilyra commentedon Mar 22, 2018
What is the motivation for
hostandworkerrestrictions blocking work stealing?Surely there could easily be a situation where the worker or host restrictions for a particular task is a list of say 10 hosts out of 50 hosts. Any of the hosts from the restricted host list would do just fine.
For the
worker_restrictionsthis would seem to be a fairly simple filter onidlebefore the thief worker is selectedhandling the host
host_restrictionsseems a bit more complicated as getting the host names seems not to be straightforward.mrocklin commentedon Mar 22, 2018
seibert commentedon Sep 11, 2019
In case anyone stumbles on this issue, there is a stalled PR here to fix this: #2740
lesteve commentedon Mar 5, 2020
I guess this one can be closed since #3069 has been merged.
jrbourbeau commentedon Mar 5, 2020
Agreed, thanks for following up @lesteve!