Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions encodings/sequence/src/compute/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use vortex_array::scalar::PValue;
use vortex_array::scalar::Scalar;
use vortex_array::scalar_fn::fns::binary::CompareKernel;
use vortex_array::scalar_fn::fns::operators::CompareOperator;
use vortex_buffer::BitBuffer;
use vortex_buffer::BitBufferMut;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;
use vortex_error::vortex_bail;
Expand Down Expand Up @@ -56,7 +56,9 @@ impl CompareKernel for Sequence {
};

if let Ok(set_idx) = set_idx {
let buffer = BitBuffer::from_iter((0..lhs.len()).map(|idx| idx == set_idx));
let mut buffer = BitBufferMut::new_unset(lhs.len());
buffer.set(set_idx);
let buffer = buffer.freeze();
Comment on lines +59 to +61

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NICE

Ok(Some(BoolArray::new(buffer, validity).into_array()))
} else {
Ok(Some(
Expand Down
20 changes: 20 additions & 0 deletions vortex/benches/single_encoding_throughput.rs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please read the benchmarking docs

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Read docs/developer-guide/benchmarking.md and updated both cases to pass the length and match index through with_inputs, removing the captured values and std::hint::black_box. The focused run measured 19.99 microseconds median for from_iter and 87.3 nanoseconds for the single-set path, both below the 1 ms per-iteration limit.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ use vortex::encodings::zigzag::zigzag_encode;
use vortex::encodings::zstd::Zstd;
use vortex::encodings::zstd::ZstdData;
use vortex_array::VortexSessionExecute;
use vortex_buffer::BitBuffer;
use vortex_buffer::BitBufferMut;
use vortex_error::VortexResult;
use vortex_sequence::Sequence;
use vortex_session::VortexSession;
Expand Down Expand Up @@ -272,6 +274,24 @@ fn bench_sequence_decompress_u32(bencher: Bencher) {
.bench_refs(|(a, ctx)| canonicalize((**a).clone(), ctx));
}

#[divan::bench]
fn bench_sequence_compare_match_from_iter(bencher: Bencher) {
bencher
.with_inputs(|| (NUM_VALUES as usize, NUM_VALUES as usize / 2))
.bench_values(|(len, set_idx)| BitBuffer::from_iter((0..len).map(|idx| idx == set_idx)));
}

#[divan::bench]
fn bench_sequence_compare_match_single_set(bencher: Bencher) {
bencher
.with_inputs(|| (NUM_VALUES as usize, NUM_VALUES as usize / 2))
.bench_values(|(len, set_idx)| {
let mut buffer = BitBufferMut::new_unset(len);
buffer.set(set_idx);
buffer.freeze()
});
}

#[divan::bench(name = "alp_compress_f64")]
fn bench_alp_compress_f64(bencher: Bencher) {
let (_, _, float_array) = setup_primitive_arrays();
Expand Down