Skip to content

Do not rebalance spilled keys #6002

Open
@crusaderky

Description

@crusaderky

Scheduler.rebalance() moves key/value pairs from workers with the heaviest memory load to those with the lightest.
"memory load" is, by default, measured in terms of optimistic memory: managed (not spilled) + unmanaged older than 30s, which is the same as process - managed recent.
(read: https://distributed.dask.org/en/latest/worker-memory.html#using-the-dashboard-to-monitor-memory-usage)

rebalance uses a least-recently-inserted algorithm to pick which keys to move - the rationale being that implementing a least-recently-used algorithm like on the worker-side spill system would require an unreasonable amount of extra synchronization from worker to scheduler.

In a somewhat common scenario where least-recently-inserted crudely matches least-recently-used, this means that rebalance will tend to move spilled keys first. The consequence is that rebalance not only will not improve in any way the situation on the sender worker, but it will actually make its memory usage spike for the whole duration of the transfer, as it copies the data out of the spill disk and into memory to prepare it for send (xref: #5996 for mitigation).

It will also aggravate memory usage on the receiving worker. If the worker later reaches the target threshold itself, then it will have a key from rebalance that used to be spilled (read: it was not used for a long time) that will be spilled potentially later than more recent keys, as the SpillBuffer makes no distinction between key/values used by rebalance/AMM and those used by the computation.

Proposed design

Sync a spilled flag from worker to scheduler.
Completely ignore spilled keys in rebalance().

Both issue and design are valid both in the current (legacy) implementation of rebalance() as well as in the future reimplementation on top of AMM.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions