Skip to content

Use Blockwise/map_partitions in various DataFrame join methods #8306

Description

@gjoseph92

I noticed that some join methods have things like

        dsk = {
            (name, i): (apply, merge_chunk, [left_key, right_key], kwargs)
            for i, right_key in enumerate(right.__dask_keys__())
        }

where we're generating a low-level graph that could just be done with map_partitions. Using map_partitions in these scenarios would both speed up graph transmission and allow for blockwise fusion across the operations. Refactoring this simple sorts of graphs should be straightforward.

  • single_partition_join
  • hash_join's merge_chunk
  • stack_partitions should use HighLevelGraph.from_collections instead of merging all of the input graphs

cc @rjzamora @ncclementi @jrbourbeau

Activity

  1. jrbourbeau commented on Oct 27, 2021

    @jrbourbeau
    Member

    Thanks for flagging these @gjoseph92. In general, lifting low-level task graphs into high-level graphs is a nice improvement

  2. gjoseph92 commented on Nov 3, 2021

    @gjoseph92
    CollaboratorAuthor

    I just realized this is slightly more important than I'd originally thought, because now that low-level optimization is turned off for DataFrames, the only way we get task fusion is through HighLevelGraphs. So even simple linear chains won't be fused, exposing us to root task overproduction (dask/distributed#5223).

    For example, this means that a single_partition_join followed by a map_partitions operation may have worse memory performance than doing the join yourself within a map_partitions, since lots of extra single_partition_join outputs can accumulate in memory.

    cc @jrbourbeau @ncclementi

  3. jrbourbeau commented on Nov 3, 2021

    @jrbourbeau
    Member

    Ah, thanks for digging deeper here @gjoseph92

  4. gjoseph92 commented on Nov 15, 2021

    @gjoseph92
    CollaboratorAuthor

    Thanks for merging @jsignell! Note that these were not done:

    • hash_join's merge_chunk
    • stack_partitions should use HighLevelGraph.from_collections instead of merging all of the input graphs

    Should we re-open this issue, or open new ones for them?

  5. jrbourbeau commented on Nov 15, 2021

    @jrbourbeau
    Member

    Re-opening to continue to track here. I've also updated the original post to be a checklist instead of a bulleted list (hope that's okay)

  6. added
    highlevelgraph
    on Mar 1, 2022
  7. self-assigned this
    on Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

dataframehighlevelgraph

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions