You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/08/08 22:04:23 UTC
[GitHub] [arrow-rs] tustvold opened a new pull request, #2381: Simplify BitReader (~5-10% faster)
tustvold opened a new pull request, #2381:
URL: https://github.com/apache/arrow-rs/pull/2381
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #.
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
This makes a couple of changes:
```
arrow_array_reader/Int32Array/binary packed, mandatory, no NULLs
time: [26.773 us 26.778 us 26.784 us]
change: [-12.530% -12.270% -11.986%] (p = 0.00 < 0.05)
Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
2 (2.00%) low severe
3 (3.00%) high mild
2 (2.00%) high severe
arrow_array_reader/Int32Array/binary packed, optional, no NULLs
time: [43.490 us 43.501 us 43.513 us]
change: [-8.0569% -7.7694% -7.4579%] (p = 0.00 < 0.05)
Performance has improved.
Found 13 outliers among 100 measurements (13.00%)
3 (3.00%) high mild
10 (10.00%) high severe
arrow_array_reader/Int32Array/binary packed, optional, half NULLs
time: [50.091 us 50.115 us 50.142 us]
change: [-3.0207% -2.7299% -2.4358%] (p = 0.00 < 0.05)
Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
2 (2.00%) high mild
2 (2.00%) high severe
arrow_array_reader/Int64Array/binary packed, mandatory, no NULLs
time: [23.427 us 23.432 us 23.436 us]
change: [-7.3450% -7.2770% -7.2229%] (p = 0.00 < 0.05)
Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
2 (2.00%) low mild
1 (1.00%) high severe
arrow_array_reader/Int64Array/binary packed, optional, no NULLs
time: [40.159 us 40.169 us 40.179 us]
change: [-4.6524% -4.3771% -4.1016%] (p = 0.00 < 0.05)
Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high severe
arrow_array_reader/Int64Array/binary packed, optional, half NULLs
time: [49.294 us 49.312 us 49.330 us]
change: [-1.3314% -1.1008% -0.9611%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 5 outliers among 100 measurements (5.00%)
4 (4.00%) high mild
1 (1.00%) high severe
arrow_array_reader/StringArray/plain encoded, mandatory, no NULLs
time: [171.83 us 171.96 us 172.09 us]
change: [-3.5398% -3.2856% -3.0931%] (p = 0.00 < 0.05)
Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
2 (2.00%) high mild
1 (1.00%) high severe
arrow_array_reader/StringArray/plain encoded, optional, no NULLs
time: [189.01 us 189.08 us 189.16 us]
change: [-3.5964% -3.4081% -3.2798%] (p = 0.00 < 0.05)
Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild
arrow_array_reader/StringArray/plain encoded, optional, half NULLs
time: [211.78 us 211.91 us 212.03 us]
change: [-4.9192% -4.6823% -4.5268%] (p = 0.00 < 0.05)
Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
4 (4.00%) high mild
2 (2.00%) high severe
arrow_array_reader/StringArray/dictionary encoded, mandatory, no NULLs
time: [134.94 us 135.22 us 135.51 us]
change: [-1.3736% -1.0797% -0.8383%] (p = 0.00 < 0.05)
Change within noise threshold.
arrow_array_reader/StringArray/dictionary encoded, optional, no NULLs
time: [150.57 us 150.81 us 151.06 us]
change: [-1.1385% -0.8209% -0.5214%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) high mild
1 (1.00%) high severe
arrow_array_reader/StringArray/dictionary encoded, optional, half NULLs
time: [188.25 us 188.37 us 188.49 us]
change: [-5.6464% -5.3275% -5.0459%] (p = 0.00 < 0.05)
Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
2 (2.00%) high mild
1 (1.00%) high severe
arrow_array_reader/StringDictionary/dictionary encoded, mandatory, no NULLs
time: [24.404 us 24.413 us 24.423 us]
change: [-1.8395% -1.5543% -1.2527%] (p = 0.00 < 0.05)
Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
3 (3.00%) high mild
1 (1.00%) high severe
arrow_array_reader/StringDictionary/dictionary encoded, optional, no NULLs
time: [41.200 us 41.229 us 41.271 us]
change: [-1.9306% -1.5861% -1.2388%] (p = 0.00 < 0.05)
Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
1 (1.00%) high mild
6 (6.00%) high severe
arrow_array_reader/StringDictionary/dictionary encoded, optional, half NULLs
time: [48.046 us 48.075 us 48.104 us]
change: [-7.1111% -6.7512% -6.3610%] (p = 0.00 < 0.05)
Performance has improved.
Found 9 outliers among 100 measurements (9.00%)
6 (6.00%) high mild
3 (3.00%) high severe
```
# What changes are included in this PR?
1. Removes `total_bytes` making it easier for LLVM to elide bounds checks
2. Lazily populates buffered_values when actually needed
3. Simplifies the skip implementation
The second of these is particularly impactful for DeltaBitPackedDecoder, where the miniblocks are in chunks of 32 and therefore never actually fall out of byte alignment.
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are there any user-facing changes?
No
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the `breaking change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2381: Simplify BitReader (~5-10% faster)
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2381:
URL: https://github.com/apache/arrow-rs/pull/2381#discussion_r940703571
##########
parquet/src/util/bit_util.rs:
##########
@@ -398,22 +397,7 @@ impl BitReader {
///
/// Returns `false` if there are no more values to skip, `true` otherwise.
pub fn skip_value(&mut self, num_bits: usize) -> bool {
- assert!(num_bits <= 64);
-
- if self.byte_offset * 8 + self.bit_offset + num_bits > self.total_bytes * 8 {
- return false;
- }
-
- self.bit_offset += num_bits;
-
- if self.bit_offset >= 64 {
- self.byte_offset += 8;
- self.bit_offset -= 64;
-
- self.reload_buffer_values();
- }
-
- true
+ self.skip(1, num_bits) == 1
Review Comment:
This isn't actually called by anything I can find, so lets just keep it simple
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold merged pull request #2381: Simplify BitReader (~5-10% faster)
Posted by GitBox <gi...@apache.org>.
tustvold merged PR #2381:
URL: https://github.com/apache/arrow-rs/pull/2381
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2381: Simplify BitReader (~5-10% faster)
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2381:
URL: https://github.com/apache/arrow-rs/pull/2381#discussion_r940707807
##########
parquet/src/util/bit_util.rs:
##########
@@ -385,37 +381,18 @@ impl BitReader {
self.byte_offset += 8;
self.bit_offset -= 64;
- self.reload_buffer_values();
- v |= trailing_bits(self.buffered_values, self.bit_offset)
- .wrapping_shl((num_bits - self.bit_offset) as u32);
+ if self.bit_offset != 0 {
+ self.load_buffer();
+
+ v |= trailing_bits(self.buffered_values, self.bit_offset)
+ .wrapping_shl((num_bits - self.bit_offset) as u32);
+ }
}
// TODO: better to avoid copying here
Some(from_ne_slice(v.as_bytes()))
}
- /// Skip one value of size `num_bits`.
Review Comment:
Removed as no longer needed, was only ever called by the implementation of `BitReader::skip` which now does something simpler
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2381: Simplify BitReader (~5-10% faster)
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2381:
URL: https://github.com/apache/arrow-rs/pull/2381#discussion_r945512878
##########
parquet/src/util/bit_util.rs:
##########
@@ -429,7 +406,7 @@ impl BitReader {
let mut values_to_read = batch.len();
let needed_bits = num_bits * values_to_read;
- let remaining_bits = (self.total_bytes - self.byte_offset) * 8 - self.bit_offset;
+ let remaining_bits = (self.buffer.len() - self.byte_offset) * 8 - self.bit_offset;
Review Comment:
The logic on the next line, and similar variants of it. We only read a number of bits based on what remains
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] alamb commented on a diff in pull request #2381: Simplify BitReader (~5-10% faster)
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #2381:
URL: https://github.com/apache/arrow-rs/pull/2381#discussion_r943395500
##########
parquet/src/util/bit_util.rs:
##########
@@ -373,10 +364,15 @@ impl BitReader {
assert!(num_bits <= 64);
assert!(num_bits <= size_of::<T>() * 8);
- if self.byte_offset * 8 + self.bit_offset + num_bits > self.total_bytes * 8 {
+ if self.byte_offset * 8 + self.bit_offset + num_bits > self.buffer.len() * 8 {
return None;
}
+ // Only need to populate buffer if byte aligned
Review Comment:
I don't understand this comment -- maybe some more context would help about why the buffer needs to be loaded if there are no more bits left in the currrent byte
##########
parquet/src/util/bit_util.rs:
##########
@@ -429,7 +406,7 @@ impl BitReader {
let mut values_to_read = batch.len();
let needed_bits = num_bits * values_to_read;
- let remaining_bits = (self.total_bytes - self.byte_offset) * 8 - self.bit_offset;
+ let remaining_bits = (self.buffer.len() - self.byte_offset) * 8 - self.bit_offset;
Review Comment:
I don't think this PR is any better or worse, but what ensures that self.bit_offset (which can be up to 63) is always less than `self.buffer.len() - self.byte_offset`?
##########
parquet/src/util/bit_util.rs:
##########
@@ -385,37 +381,18 @@ impl BitReader {
self.byte_offset += 8;
self.bit_offset -= 64;
- self.reload_buffer_values();
- v |= trailing_bits(self.buffered_values, self.bit_offset)
- .wrapping_shl((num_bits - self.bit_offset) as u32);
+ if self.bit_offset != 0 {
Review Comment:
The logic that decides when to reload `self.buffered_values` is confusing to me as I would normally expect calling `self.load_buffer()` would also reset `bit_offset` to 0 to match having just reloaded more bits into `self.buffered_values`
##########
parquet/src/util/bit_util.rs:
##########
@@ -672,8 +632,10 @@ impl BitReader {
})
}
- fn reload_buffer_values(&mut self) {
- let bytes_to_read = cmp::min(self.total_bytes - self.byte_offset, 8);
+ /// Populates `self.buffered_values`
+ #[inline]
+ fn load_buffer(&mut self) {
Review Comment:
Given there is a field called `buffer` and this function is not loading it, but rather reading *from* it and loading into `buffered_values` I recommend calling this function something slightly verbose:
```suggestion
/// Loads up to the the next 8 bytes from `self.buffer` at `self.byte_offfset`
/// into `self.buffered_values`. Reads fewer than 8 bytes if there are fewer than 8 bytes left
fn load_buffered_values(&mut self) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] ursabot commented on pull request #2381: Simplify BitReader (~5-10% faster)
Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #2381:
URL: https://github.com/apache/arrow-rs/pull/2381#issuecomment-1214860433
Benchmark runs are scheduled for baseline = 76e79d9fbe77d9669e59c24d501ea990f908c8e7 and contender = 47a2c21efd09cbe08c213ef2d2c11201e43b98f4. 47a2c21efd09cbe08c213ef2d2c11201e43b98f4 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/9a7c3f7051ba4279a1a355325a8f12d6...1515564dca084742a2c8d507b990e004/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/7d5dcd66a6d3447ca1e3f917a23e5f16...2e7526c6931e421bba1683996888ef55/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/fe118b19658f4c37a0115fda781f5a7b...c7cd9f6cc4fc40dcb4e4082be347f039/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/02bf718f2fe84537bc515071d4a042c9...bb426b4ba5bd4bd1afe50225e9c752e6/)
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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org