Open wence- opened 2 years ago
Assigning myself for now - I have some ideas I'd like to explore for improvement. If someone else is interested in this before I get a chance to work on it, please reach out and I can share my thoughts!
This issue has been labeled inactive-30d
due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d
if there is no activity in the next 60 days.
A common pattern in dask is to shuffle distributed data around by some hash-based index. For example, this comes up in merging dataframes. Since the determination of index buckets is typically carried out independently from the splitting of the dataframe, this turns into calls to
libcudf.partitioning.partition
. The other option for this particular case would be to calllibcudf.hash.hash_partition
. The latter appears to be signficantly (~5x) faster for large dataframes (code attached below, which partitions a dataframe with row columns and 100_000_000 rows on the first column into a configurable number of partitions, for the results below I used 10). Typical numbers of partitions for this use case are likely O(10-1000). Although this performance difference is not the order one cost in a distributed shuffle, flipping the switch from partition by index to partition by hash in dask-cuda provides a 10% speedup in some benchmarks (see rapidsai/dask-cuda#952).To help the timings for the
partition-by-indices
case, I only compute the indices to partition on once. Profiling with nsight shows this takes ~2.7ms. Thepartition
call takes 52 ms (of whichscatter
takes 22ms), in contrasthash-and-scatter
in one go viahash_partition
takes 9.5ms. Sincepartition
by indices needs to read an extra column (the indices), I might expect things to be a bit slower, but this large difference was a bit surprising.There's a note in the partitioning code that it might make sense to avoid atomics:
https://github.com/rapidsai/cudf/blob/ec0b32bf73fc725982f62b0932782718d3886125/cpp/src/partitioning/partitioning.cu#L631
Aside: the pathological case of
npartitions == 1
is a factor of 2x slower for the partition-by-indices case, and 10x slower for partition-by-hash (probably worthwhile dispatching into a fast-path copy for that).cc: @bdice, @shwina