Skip to content

Commit

Permalink
Improved perf of rle (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao authored Apr 22, 2022
1 parent dc05110 commit b2edf96
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ bloom_filter = ["xxhash-rust"]
[[bench]]
name = "decode_bitpacking"
harness = false

[[bench]]
name = "decode_rle"
harness = false
19 changes: 19 additions & 0 deletions benches/decode_rle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use criterion::{criterion_group, criterion_main, Criterion};

use parquet2::encoding::hybrid_rle::{encode_u32, Decoder};

fn add_benchmark(c: &mut Criterion) {
(10..=20).step_by(2).for_each(|log2_size| {
let size = 2usize.pow(log2_size);

let mut bytes = vec![];
encode_u32(&mut bytes, (0..size as u32).map(|x| x % 128), 8).unwrap();

c.bench_function(&format!("rle decode 2^{}", log2_size), |b| {
b.iter(|| Decoder::new(&bytes, 1).count())
});
})
}

criterion_group!(benches, add_benchmark);
criterion_main!(benches);
1 change: 1 addition & 0 deletions src/encoding/hybrid_rle/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ impl<'a> Decoder<'a> {
impl<'a> Iterator for Decoder<'a> {
type Item = HybridEncoded<'a>;

#[inline] // -18% improvement in bench
fn next(&mut self) -> Option<Self::Item> {
if self.values.is_empty() {
return None;
Expand Down

0 comments on commit b2edf96

Please sign in to comment.