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

Implement Skip for DeltaBitPackDecoder #2393

Merged
merged 4 commits into from Aug 12, 2022
Merged

Conversation

Ted-Jiang
Copy link
Member

Which issue does this PR close?

Closes #2281 .

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the parquet Changes to the parquet crate label Aug 10, 2022
@Ted-Jiang
Copy link
Member Author

@tustvold PATL😊

let batch_to_skip = self.mini_block_remaining.min(to_skip - skip);

for i in 0..batch_to_skip {
if let Some(v) = self.bit_reader.get_value::<T::T>(bit_width) {
Copy link
Contributor

Choose a reason for hiding this comment

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

get_value is pretty slow, it would be better to read in batches of the miniblock size (typically 32 or 64)

let bit_width = self.mini_block_bit_widths[self.mini_block_idx] as usize;
let batch_to_skip = self.mini_block_remaining.min(to_skip - skip);

for i in 0..batch_to_skip {
Copy link
Contributor

@tustvold tustvold Aug 10, 2022

Choose a reason for hiding this comment

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

The key optimisation that I think would be good to include is if you don't need to read any values from a block, you don't need to keep track of last_value for the block, and can just skip over the values

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree!

Copy link
Member Author

@Ted-Jiang Ted-Jiang Aug 11, 2022

Choose a reason for hiding this comment

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

Effectively you can only skip efficiently in multiples of the block size, as otherwise you are still having to decode all the value

@tustvold after checking with the code, i think there is only one [first value] in each col chunk, so we need read all values to calculate the last_value? 🤔
Am i right?

Copy link
Contributor

@tustvold tustvold Aug 11, 2022

Choose a reason for hiding this comment

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

Yup... Darn... I guess we just have to decode each block 😞

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe i can try to use a suitable skip_buffer, try not have performance downgrade.

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'm not confident that as written this will actually improve performance, perhaps we could get a benchmark? I've also added some suggestions of how to make it faster

@Ted-Jiang
Copy link
Member Author

Ted-Jiang commented Aug 11, 2022

I'm not confident that as written this will actually improve performance, perhaps we could get a benchmark? I've also added some suggestions of how to make it faster

Thanks for your useful guidance!
After #2407
i write a bench got

arrow_array_reader/Int32Array/binary packed skip, mandatory, no NULLs                                                                            
                        time:   [81.636 us 82.772 us 83.944 us]
                        change: [+98.920% +102.00% +105.13%] (p = 0.00 < 0.05)
                        Performance has regressed.
arrow_array_reader/Int32Array/binary packed skip, optional, no NULLs                                                                            
                        time:   [91.932 us 92.774 us 93.612 us]
                        change: [+76.901% +80.245% +83.995%] (p = 0.00 < 0.05)
                        Performance has regressed.

😭 there is a regressed !

(this use self.bit_reader.get_value::<T::T>(bit_width) decode each values)

@tustvold tustvold marked this pull request as draft August 12, 2022 08:02
@Ted-Jiang
Copy link
Member Author

Ted-Jiang commented Aug 12, 2022

@tustvold
After 98c9ab3

there is no performance downgrade and avoid allocate large buffer when skip large amount values.

arrow_array_reader/Int32Array/binary packed skip, mandatory, no NULLs                                                                             
                        time:   [38.054 us 38.268 us 38.506 us]
                        change: [-4.6824% -3.3258% -2.0893%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  4 (4.00%) low mild
  3 (3.00%) high mild
  1 (1.00%) high severe
arrow_array_reader/Int32Array/binary packed skip, optional, no NULLs                                                                             
                        time:   [47.428 us 47.588 us 47.769 us]
                        change: [-2.8683% -1.4678% +0.0342%] (p = 0.05 < 0.05)
                        Change within noise threshold.
Found 15 outliers among 100 measurements (15.00%)
  3 (3.00%) low mild
  6 (6.00%) high mild
  6 (6.00%) high severe

@tustvold tustvold marked this pull request as ready for review August 12, 2022 08:21
@tustvold
Copy link
Contributor

Looks good to me, thank you 👍

@tustvold tustvold merged commit d11b388 into apache:master Aug 12, 2022
@ursabot
Copy link

ursabot commented Aug 12, 2022

Benchmark runs are scheduled for baseline = 42e1068 and contender = d11b388. d11b388 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
parquet Changes to the parquet crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Skip for DeltaBitPackDecoder
3 participants