Skip to content
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

Adjust transfer costs in worker_objective #5326

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

gjoseph92
Copy link
Collaborator

This should maybe be two PRs, since there are two different things happening:

  1. Add a fixed (currently 10ms) penalty per transfer as discussed in Scheduler underestimates data transfer cost for small transfers #5324 (comment). This should help discourage small transfers. I'd prefer if this cost weren't just a magic 0.01 number though.

  2. Amortize the transfer cost by the number of waiters. This is related to Ignore widely-shared dependencies in decide_worker #5325. See the commit message b4ebbee for more description:

    The idea is that if a key we need has many dependents, we should amortize the cost of transferring it to a new worker, since those other dependencies could then run on the new worker more cheaply. "We'll probably have to move this at some point anyway, might as well do it now."
    This isn't actually intended to encourage transfers though. It's more meant to discourage transferring keys that could have just stayed in one place. The goal is that if A and B are on different workers, and we're the only task that will ever need A, but plenty of other tasks will need B, we should schedule alongside A even if B is a bit larger to move. This will Probably™️ lead to smoother scheduling overall.

    I haven't tested this at all yet; it's just a theory right now. Just looking for thoughts.

cc @fjetter @crusaderky @mrocklin

I'd like to incorporate measured latency somehow too instead of a magic 10ms, but it's a start.
As discussed in dask#5325. The idea is that if a key we need has many dependents, we should amortize the cost of transferring it to a new worker, since those other dependencies could then run on the new worker more cheaply. "We'll probably have to move this at some point anyway, might as well do it now."

This isn't actually intended to encourage transfers though. It's more meant to discourage transferring keys that could have just stayed in one place. The goal is that if A and B are on different workers, and we're the only task that will ever need A, but plenty of other tasks will need B, we should schedule alongside A even if B is a bit larger to move.

But this is all a theory and needs some tests.
Comment on lines 3424 to 3425
# amortize transfer cost over all waiters
comm_bytes += nbytes / len(dts._waiters)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an in-code comment explaining how this division amortizes cost? I assume this is again a "local topology" argument related to the fan-out tasks (#5325 (comment)) where we try to "ignore" tasks which will likely end up everywhere anyhow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. It's related to that, but actually a simpler idea. Basically, if we transfer to this worker now, that opens up the potential for N other tasks to run on this worker without transferring the data. So you could look at as, rather than this task paying the whole cost up front and others getting the benefit for free, all the sibling tasks split the cost of the transferring evenly between them. (That's an analogy of course—once transferred, the other tasks don't actually pay anything!)

@github-actions
Copy link
Contributor

github-actions bot commented May 4, 2022

Unit Test Results

       16 files  ±0         16 suites  ±0   7h 38m 11s ⏱️ + 22m 54s
  2 746 tests ±0    2 662 ✔️ ±0       80 💤  - 1  3 ±0  1 🔥 +1 
21 865 runs  +1  20 812 ✔️  - 2  1 048 💤 +2  4 ±0  1 🔥 +1 

For more details on these failures and errors, see this check.

Results for commit e3d62f6. ± Comparison against base commit baf05c0.

♻️ This comment has been updated with latest results.

distributed/scheduler.py Outdated Show resolved Hide resolved
distributed/scheduler.py Outdated Show resolved Hide resolved
distributed/scheduler.py Outdated Show resolved Hide resolved
Comment on lines +2807 to +2809
# amortize transfer cost over all waiters
comm_bytes += nbytes / len(dts.waiters)
xfers += 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# amortize transfer cost over all waiters
comm_bytes += nbytes / len(dts.waiters)
xfers += 1
nwaiters = len(dts.waiters)
# amortize transfer cost over all waiters
comm_bytes += nbytes / nwaiters
xfers += 1 / nwaiters

@gjoseph92 do you agree?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However this would not be replicable in get_comm_cost above

distributed/scheduler.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scheduler underestimates data transfer cost for small transfers
3 participants