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

Refactor loser tree code in SortPreservingMerge per PR comments #4407

Merged
merged 8 commits into from
Jan 12, 2023

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Nov 28, 2022

Which issue does this PR close?

re #4300.

Rationale for this change

  1. I wanted to get the merge speed improvements into DataFusion
  2. I wanted an excuse to work on the code myself for a bit

What changes are included in this PR?

Implements suggestions from @tustvold and @viirya in #4301

Are these changes tested?

covered by existing tests

TODO: need to run benchmarks

Are there any user-facing changes?

No

/// The tree update could not be completed (e.g. the input was not
/// ready or had an error). The caller should return the `Poll`
/// result to its caller
Incomplete(Poll<Option<ArrowResult<RecordBatch>>>),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Incomplete(Poll<Option<ArrowResult<RecordBatch>>>),
Pending,
Error(ArrowError),

Given we never seem to return TreeUpdate::Incomplete(Poll::Ready(None)) or TreeUpdate::Incomplete(Poll::Ready(Some(Ok(_))))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in 1bdb25a

@alamb
Copy link
Contributor Author

alamb commented Nov 28, 2022

Here are performance results. It is somewhat of a mixed bag (some show a few percent less) results are
results.txt

The first run is the second time I ran cargo bench against 0d334cf (aka no code change) and it reports some regressions and then the second run is with the changes in this PR

Copy link
Contributor Author

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Given this PR makes the code more readable (in my opinion) I would like to merge it.

@richox or @tustvold do you have any concerns?

If not I plan to do over the next day or two

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 think removing TreeUpdate would further simplify this code, but I'm happy for this to go in as is


/// The result of updating the loser tree. It is the same as an Option
/// but with specific names for easier readability
enum TreeUpdate {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really see the need for this over Poll<Result<()>> in particular it is confusing what its semantics are w.r.t wakers

if let Err(e) = self.build()? {
    return Poll::Ready(Err(e))
}

Is not significantly more verbose

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried it out and you are right -- I think Poll made the code better -- in 2237abe

self.aborted = true;
return TreeUpdate::Error(e);
}
Poll::Pending => return TreeUpdate::Pending,
Copy link
Contributor

Choose a reason for hiding this comment

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

If this method returned Poll this could just use ready! or even ?

@alamb alamb merged commit 82bbaa3 into apache:master Jan 12, 2023
@ursabot
Copy link

ursabot commented Jan 12, 2023

Benchmark runs are scheduled for baseline = 0d27fcb and contender = 82bbaa3. 82bbaa3 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-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-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

@alamb alamb deleted the alamb/tournament-merging-updates branch August 8, 2023 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants