Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Sort kernel for RunArray #3695

Merged
merged 14 commits into from Feb 23, 2023
Merged

feat: Sort kernel for RunArray #3695

merged 14 commits into from Feb 23, 2023

Conversation

askoa
Copy link
Contributor

@askoa askoa commented Feb 11, 2023

Which issue does this PR close?

Part of #3520

Rationale for this change

See issue description

What changes are included in this PR?

Built on top to yet to be merged PR #3681

  • sort_run_to_indices for RunArray
  • sort_run for RunArray
  • Include sort run and sort run to indices in sort_kernel benchmark

Sorting run array to indices is very slow if the intention is to get output run array. The sorted indices are logical indices which has to be encoded back to run array. The function sort_run will rearrange runs based on sorted values and hence will be faster to get output run array.

How much faster is sort_run compared to sort_run_to_indices?

Below benchmark result shows sort_run produces the output run array using same time taken by sort_run_to_indices to produce indices.

sort primitive run to indices 2^12
                        time:   [11.023 µs 11.054 µs 11.096 µs]
Found 14 outliers among 100 measurements (14.00%)
  2 (2.00%) high mild
  12 (12.00%) high severe

sort primitive run to run 2^12
                        time:   [10.165 µs 10.267 µs 10.410 µs]
Found 12 outliers among 100 measurements (12.00%)
  6 (6.00%) high mild
  6 (6.00%) high severe

What's the catch?

The sort_run will only rearrange the runs and not re-encode them for efficiency. For e.g. an input RunArray { run_ends = [2,4,6,8], values = [1,2,1,2] } will result in output RunArray { run_ends = [2,4,6,8], values = [1,1,2,2] } and not RunArray { run_ends = [4,8], values = [1,2] }. The output of sort_run_to_indices can be used to re-encode the RunArray.

Are there any user-facing changes?

Users will get a new sort function for RunArray

@github-actions github-actions bot added the arrow Changes to the arrow crate label Feb 11, 2023
@askoa askoa changed the title WIP: feat: Sort kernel for RunArray feat: Sort kernel for RunArray Feb 13, 2023
@askoa askoa marked this pull request as ready for review February 13, 2023 16:28
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intend to review this fully tomorrow morning

arrow-array/src/run_iterator.rs Outdated Show resolved Hide resolved
arrow-ord/src/sort.rs Show resolved Hide resolved
@askoa
Copy link
Contributor Author

askoa commented Feb 15, 2023

I just noticed a key issue in this code. So changing this to draft.

@askoa askoa marked this pull request as draft February 15, 2023 16:54
@askoa askoa marked this pull request as ready for review February 15, 2023 17:18
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, sorry for taking so long to review. Left some minor comments

arrow-ord/src/sort.rs Outdated Show resolved Hide resolved
arrow-ord/src/sort.rs Outdated Show resolved Hide resolved
arrow-ord/src/sort.rs Show resolved Hide resolved
@askoa askoa marked this pull request as draft February 21, 2023 15:32
@askoa askoa marked this pull request as ready for review February 22, 2023 13:22
@tustvold tustvold merged commit ebe6f53 into apache:master Feb 23, 2023
@ursabot
Copy link

ursabot commented Feb 23, 2023

Benchmark runs are scheduled for baseline = e753dea and contender = ebe6f53. ebe6f53 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants