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

Improve VarBinaryDecoder::Take performance by accumulating small batches #239

Merged
merged 6 commits into from
Oct 16, 2022

Conversation

eddyxu
Copy link
Contributor

@eddyxu eddyxu commented Oct 16, 2022

Improve query SELECT external_image FROM oxford_pet WHERE class = 'pug' by 6X (12s -> 2s) on home computer.

@eddyxu eddyxu self-assigned this Oct 16, 2022
@eddyxu eddyxu added c++ C++ issues benchmark labels Oct 16, 2022
ARROW_ASSIGN_OR_RAISE(auto positions, ReadPositions(start, length));
assert(positions->length() == length + 1);

const int64_t kMinimalBatchBytes = 128 * 1024; // 128K
Copy link
Contributor

Choose a reason for hiding this comment

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

does this need to be enforced elsewhere? if so, do we need a global constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is an optimization, does not change behavior.

Long term this could be a runtime configuration tho.

template <ArrowType T>
::arrow::Result<std::shared_ptr<::arrow::Int64Array>> VarBinaryDecoder<T>::ReadPositions(
int32_t start, int32_t length) const {
auto buf = infile_->ReadAt(position_ + start * sizeof(int64_t), (length + 1) * sizeof(int64_t));
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to pass in length + 1 here? Isn't length * sizeof(int64_t) the number of bytes that need to be read?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So for an array like ["aa", "bbb", "cccc"] , the offset array should look like [0, 2, 5, 9], where [5, 9] is used to calculate the start and end of "cccc" string.

@changhiskhan changhiskhan merged commit eeecd68 into main Oct 16, 2022
@changhiskhan changhiskhan deleted the lei/binary_take branch October 16, 2022 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants