Skip to content

Large Dataframe shuffle operations #6314

Open

Description

@mrocklin

Some dataframe operations require something like a full sort of the data. This can be expensive for a variety of reasons. This limits the scalability of Dask Dataframe to very large datasets. These operations include:

  1. set_index
  2. groupby-apply
  3. join on a non-sorted column

Our current approach is to split every input partition into several pieces, move those pieces around to their final destination, and then merge them into output partitions. In an unsorted input dataset every input partition will have something to contribute to most output partitions, so this is an n**2 operation. As the number of partitions increases this an become debilitating due to scheduler overhead.

So for example if we have 1000 partitions then this might create 1,000,000 tasks, which if overhead is something like 1ms per task (an overetimate) then this would add 1000s of overhead (about 15 minutes) regardless of how large our cluster is.

Staging: Today's approach

Today we avoid this by staging communication. We split things up not into 1000 little chunks, but into 30, and we do this a couple of times. This results in n * log_n tasks and log_n full communications. In our example above we would incur something like 30,000 + 30,000 tasks, or about 10s of overhead, but we would have to move our dataset around twice (which if you're on slow network can be troublesome)

What are some other approaches that we could take here?

See also

Activity

  1. mrocklin commented on Jun 11, 2020

    @mrocklin
    MemberAuthor

    One approach, inspired by Spark's shuffling service, is to make a shuffle service that handles moving around all-to-all type communication patterns on the side. This is what we do today with single-machine shuffles with partd. There is more information on this topic here: #6164

  2. mrocklin commented on Jun 11, 2020

    @mrocklin
    MemberAuthor

    Another approach is to stay with n**2 tasks, but generate them on the fly. This lets us hide the overhead of processing these tasks by overlapping them with communiation. More on this topic here: dask/distributed#3879

    @madsbk I think that I'm representing your approach well here, but I think that you probably know more about the specifics than I do.

  3. jakirkham commented on Jun 12, 2020

    @jakirkham
    Member

    Also issue ( #6163 ) and issue ( dask/distributed#3783 ) are related.

  4. added
    needs attention
    on Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dataframeneeds attention

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions