Skip to content
Closed
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
14 changes: 4 additions & 10 deletions encodings/decimal-byte-parts/benches/dbp_assemble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// SPDX-FileCopyrightText: Copyright the Vortex contributors

//! Reassembling integer slices, including output-buffer allocation.
//! Array benchmarks also include validation, part execution, and casts.
//!
//! Array benchmarks also include validation and part execution.

mod common;

Expand Down Expand Up @@ -146,15 +147,8 @@ mod arrays {
fn dbp_assemble_narrowed(bencher: Bencher, (values_type, len): (DecimalType, usize)) {
let (precision, lower_parts) = match values_type {
DecimalType::I64 => (18, vec![]),
DecimalType::I128 => (38, vec![buffer![u8::MAX; len].into_array()]),
DecimalType::I256 => (
76,
vec![
buffer![u8::MAX; len].into_array(),
buffer![u16::MAX; len].into_array(),
buffer![u32::MAX; len].into_array(),
],
),
DecimalType::I128 => (38, vec![buffer![u64::MAX; len].into_array()]),
DecimalType::I256 => (76, vec![buffer![u64::MAX; len].into_array(); 3]),
_ => vortex_panic!("unsupported benchmark storage type: {values_type}"),
};
bench_parts(
Expand Down
31 changes: 23 additions & 8 deletions encodings/decimal-byte-parts/benches/dbp_compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

//! Decimal compute on DecimalByteParts arrays whose MSP holds the whole value.
//!
//! Every case has no lower parts. Most cases store the values in an MSP narrower than the
//! canonical width of the dtype, and `msp_i64_p18_canonical` is the control whose MSP has the
//! canonical width. Sum and min-max read the decoded decimal, and the filter filters the MSP and
//! then decodes the result, so their cost follows the width that decoding produces. Comparisons
//! against a constant run on the MSP.
//! Every case has no lower parts. Most cases store the values in an MSP narrower than the canonical
//! width of the dtype, and `msp_i64_p18_canonical` is the control whose MSP has the canonical
//! width. `decode` and `filter` stop at the form that decoding produces, a [`Widen`] or the
//! canonical array, and sum and min-max read that form, so their cost follows its width.
//! `canonicalize` also pays the widening copy that an export pays, so it omits the control, where
//! decoding already returns the canonical array. Comparisons against a constant run on the MSP.

use std::fmt;
use std::sync::LazyLock;
Expand All @@ -20,7 +21,6 @@ use rand::distr::uniform::SampleRange;
use rand::distr::uniform::SampleUniform;
use rand::rngs::StdRng;
use vortex_array::ArrayRef;
use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
Expand All @@ -31,6 +31,7 @@ use vortex_array::arrays::BoolArray;
use vortex_array::arrays::ConstantArray;
use vortex_array::arrays::DecimalArray;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::arrays::Widen;
use vortex_array::builtins::ArrayBuiltins;
use vortex_array::dtype::DecimalDType;
use vortex_array::dtype::NativePType;
Expand Down Expand Up @@ -253,11 +254,25 @@ fn bench_case<O>(
fn decode(bencher: Bencher, case: Case) {
bench_case(bencher, case, |array, ctx| {
array
.execute::<DecimalArray>(ctx)
.execute_until::<Widen>(ctx)
.vortex_expect("decode DecimalByteParts")
});
}

#[divan::bench(args = [
Case::MspI32P18,
Case::MspI32P18Nullable,
Case::GapMspI16P10,
Case::MspI64P38,
])]
fn canonicalize(bencher: Bencher, case: Case) {
bench_case(bencher, case, |array, ctx| {
array
.execute::<DecimalArray>(ctx)
.vortex_expect("canonicalize DecimalByteParts")
});
}

/// Compares a new array of `case` with `Gte` against a constant of `value` in each iteration.
fn bench_compare(bencher: Bencher, case: Case, value: DecimalValue) {
let constant = case.constant(value);
Expand Down Expand Up @@ -302,7 +317,7 @@ fn filter(bencher: Bencher, case: Case) {
array
.filter(mask)
.vortex_expect("filter DecimalByteParts")
.execute::<Canonical>(&mut ctx)
.execute_until::<Widen>(&mut ctx)
.vortex_expect("execute the filter")
});
}
Expand Down
Loading