This repository was archived by the owner on Aug 29, 2024. It is now read-only.
forked from dask-contrib/dask-sql
-
Notifications
You must be signed in to change notification settings - Fork 1
Add fast path for multi-column sorting #5
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5ad586d
add fast path for multi-column sorting
quasiben 8fc9a7b
lint
quasiben ac7bad8
Merge remote-tracking branch 'upstream/main' into multi-col-sort
charlesbluca c86cdab
Prevent single column Dask dataframes from calling sort_values
charlesbluca d321ca3
Wrap dask_cudf import in try/except block
charlesbluca ed65228
Add test for fast multi column sort
charlesbluca 76eb2aa
Move multi_col_sort contents to apply_sort
charlesbluca 927c618
Ignore index for dask-cudf sorting
charlesbluca 963ad5e
Fix show tables test for cudf enabled fixture
charlesbluca 5fb3c41
Trigger CI
charlesbluca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import pytest | ||
|
|
||
| pytest.importorskip("dask_cudf") | ||
|
|
||
| from cudf.testing._utils import assert_eq | ||
|
|
||
|
|
||
| def test_cudf_order_by(c): | ||
| df = c.sql( | ||
| """ | ||
| SELECT | ||
| * | ||
| FROM cudf_user_table_1 | ||
| ORDER BY user_id | ||
| """ | ||
| ).compute() | ||
|
|
||
| expected_df = ( | ||
| c.sql( | ||
| """ | ||
| SELECT | ||
| * | ||
| FROM cudf_user_table_1 | ||
| """ | ||
| ) | ||
| .sort_values(by="user_id", ignore_index=True) | ||
| .compute() | ||
| ) | ||
|
|
||
| assert_eq(df, expected_df) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not call
.persist()on single patition frames .Just curious , Does
.persist()ensure we dont trigger duplicate computations as IIRC,.sort_values()is not lazy.I wonder if this is a better patten
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map_partitionsin the single partition case.persisthere; I would assume this is here mostly to match up with the persist call happening in the workaround:dask-sql/dask_sql/physical/utils/sort.py
Line 38 in 4d5f7dd
EDIT:
Just saw your edit - knowing that, it looks like the current pattern should be good (once we account for the single partition case) - should we still opt to persist before running
sort_values?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing it again now., will update here. Sorry for the edit and confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So i tested an example workflow with and without persisting first, and persisting before sorting indeed prevents duplicate computation.
Without Persisting (DASK PROFILE):
With Persisting (DASK PROFILE):
The trade of here is memory vs duplicate computation. I think we might want to think more about this .
I wonder if a version of in-place sorting might prevent some memory overheads.
Anyways, we should think deeply about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC: @randerzander
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect the persist calls here are due to handling the multi-col sort on CPU. Once pandas-dev/pandas#43881 is resolved and Dask has a native multi-col sort we can probably remove them entirely. @charlesbluca is correct that I was originally intending to match the the case when native mult-col sorting is not supported.
I think it's ok to safely remove persist in the initial try state and return the dataframe directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed these changes to the original PR:
dask-contrib#229