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

Optimize SortPreservingMergeStream to avoid SortKeyCursor sharing #1624

Merged
merged 13 commits into from
Jan 22, 2022

Conversation

yjshen
Copy link
Member

@yjshen yjshen commented Jan 21, 2022

Which issue does this PR close?

This PR is based on #1596 so please review that one first.

Rationale for this change

In SortPreservingMergeStream, SortKeyCursor shouldn't be shared between min_heap and output batch buffer. The current sharing leads to the use of AtomicUsize, which may harm performance.

What changes are included in this PR?

  • Use RecordBatch instead of SortKeyCursor for output batch buffering.
  • Add a per-stream flag cursor_finished to make sure each input stream is pulled after a resume from Pending.
  • Remove AtomicUsize from SortKeyCursor.

Are there any user-facing changes?

No.

@github-actions github-actions bot added the datafusion Changes in the datafusion crate label Jan 21, 2022
@yjshen
Copy link
Member Author

yjshen commented Jan 21, 2022

Hi @alamb @tustvold could you please take a look?

Copy link
Contributor

@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.

Mechanically the changes in this PR make sense to me; Thanks @yjshen

@tustvold can you possibly take a look when you get a moment?

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 really like this change 👍

That being said I think it would be good to rename some things and update the corresponding comments to avoid future confusion. I also think it is possible to remove the Arc but I could be missing something...

@yjshen
Copy link
Member Author

yjshen commented Jan 22, 2022

@alamb @tustvold Thanks for the review. I've updated the documentation, renamed variables, removed the record batch from SortKeyCursor, PTAL.

@yjshen yjshen requested a review from alamb January 22, 2022 02:11
Copy link
Contributor

@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.

Looks like a great improvement to me 👍

@alamb alamb merged commit 62edddb into apache:master Jan 22, 2022
@alamb
Copy link
Contributor

alamb commented Jan 22, 2022

Thanks again @yjshen

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

Successfully merging this pull request may close these issues.

3 participants