Skip to content

RFC Allow size measurements of shuffle_group intermediate results - #6149

Closed
fjetter wants to merge 1 commit into
dask:masterfrom
fjetter:sizeof_shuffle_group
Closed

fjetter wants to merge 1 commit into
dask:masterfrom
fjetter:sizeof_shuffle_group

Conversation

@fjetter

@fjetter fjetter commented Apr 28, 2020

Copy link
Copy Markdown
Member

I'm currently investigating heavy memory usage of a shuffle (similar, if not identical to #2456) and realized that we do not have any sizing information about the intermediate stages when shuffling.
From my understanding this is mostly because we move the shuffle_group results around in dicts and we do not properly estimate dict sizes due to potentially severe performance implications. As a practical fix these results could be passed as tuples since the dict keys were integer indices anyhow.

The size estimation would not only be useful for debugging but I would also expect the distributed scheduler to assign tasks much smarter to the workers with proper size estimates. Especially for a data intensive operation like a shuffle I would expect this effect to be strong. I'll follow up with some measurements but wanted to pick your brains before I step too deep into the rabbit hole.

@fjetter
fjetter force-pushed the sizeof_shuffle_group branch from e7b471b to d2bbe0c Compare April 29, 2020 07:29
@mrocklin

Copy link
Copy Markdown
Member

In principle this change seems fine.

If we go a bit deeper it seems like there is some policy difference in how we compute sizeof for tuples and dicts, which is a bit strange. The same argument for not wanting to recurse down into dicts for performance reasons also holds for tuples. For example, bag computations can pass around large tuples for which we would not want to call sizeof on every element.

Short term I'm happy to merge this (assuming that there are not major side effects) but long-term we might want to change our sizeof computation to be more robust to large collections. I wonder if it would make sense to randomly sample. For example the logic might be something like the following

def sizeof(collection):
    if len(collection) < 10:
        return sys.getsizeof(collection) + sum(map(sizeof, collection))
    else:
        return sys.getsizeof(collection) * len(collection) / 10 * random.sample(collection, 10)

@mrocklin

Copy link
Copy Markdown
Member

Also, thank you for finding and helping to resolve this. I wasn't aware that we weren't capturing the size information here. I agree that this may end up being important for efficient shuffling.

@fjetter

fjetter commented Apr 30, 2020

Copy link
Copy Markdown
Member Author

Agreed that this is not an optimal solution. I opened #6154 to discuss this issue in particular with a proposal for the implementation and some benchmarks.

Regarding this change, what I could observe so far is that my computations behave much more stable and spill to disk seems to work much better. I don't have any concrete measurements, yet

@mrocklin

mrocklin commented Apr 30, 2020 via email

Copy link
Copy Markdown
Member

@fjetter fjetter closed this May 5, 2020
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.

2 participants