Skip to content

Commit 39bf887

Browse files
committed
clean up
Signed-off-by: Joe Isaacs <[email protected]>
1 parent 6f448ec commit 39bf887

File tree

5 files changed

+295
-185
lines changed

5 files changed

+295
-185
lines changed

encodings/runend/benches/run_end_decode.rs

Lines changed: 145 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#![allow(clippy::unwrap_used, clippy::cast_possible_truncation)]
55

6+
use std::fmt;
7+
68
use divan::Bencher;
79
use vortex_array::arrays::BoolArray;
810
use vortex_array::arrays::PrimitiveArray;
@@ -32,6 +34,35 @@ enum BoolDistribution {
3234
AllFalse,
3335
}
3436

37+
impl fmt::Display for BoolDistribution {
38+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
39+
match self {
40+
BoolDistribution::Alternating => write!(f, "alternating"),
41+
BoolDistribution::MostlyTrue => write!(f, "mostly_true"),
42+
BoolDistribution::MostlyFalse => write!(f, "mostly_false"),
43+
BoolDistribution::AllTrue => write!(f, "all_true"),
44+
BoolDistribution::AllFalse => write!(f, "all_false"),
45+
}
46+
}
47+
}
48+
49+
#[derive(Clone, Copy)]
50+
struct BoolBenchArgs {
51+
total_length: usize,
52+
avg_run_length: usize,
53+
distribution: BoolDistribution,
54+
}
55+
56+
impl fmt::Display for BoolBenchArgs {
57+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58+
write!(
59+
f,
60+
"{}_{}_{}",
61+
self.total_length, self.avg_run_length, self.distribution
62+
)
63+
}
64+
}
65+
3566
/// Creates bool test data with configurable distribution
3667
fn create_bool_test_data(
3768
total_length: usize,
@@ -66,45 +97,121 @@ fn create_bool_test_data(
6697
)
6798
}
6899

69-
// Medium size: 10k elements with various run lengths
70-
const BOOL_ARGS: &[(usize, usize)] = &[
71-
(10_000, 2), // Very short runs (5000 runs)
72-
(10_000, 10), // Short runs (1000 runs)
73-
(10_000, 100), // Medium runs (100 runs)
74-
(10_000, 1000), // Long runs (10 runs)
100+
// Medium size: 10k elements with various run lengths and distributions
101+
const BOOL_ARGS: &[BoolBenchArgs] = &[
102+
BoolBenchArgs {
103+
total_length: 10_000,
104+
avg_run_length: 2,
105+
distribution: BoolDistribution::Alternating,
106+
},
107+
BoolBenchArgs {
108+
total_length: 10_000,
109+
avg_run_length: 10,
110+
distribution: BoolDistribution::Alternating,
111+
},
112+
BoolBenchArgs {
113+
total_length: 10_000,
114+
avg_run_length: 100,
115+
distribution: BoolDistribution::Alternating,
116+
},
117+
BoolBenchArgs {
118+
total_length: 10_000,
119+
avg_run_length: 1000,
120+
distribution: BoolDistribution::Alternating,
121+
},
122+
BoolBenchArgs {
123+
total_length: 10_000,
124+
avg_run_length: 2,
125+
distribution: BoolDistribution::MostlyTrue,
126+
},
127+
BoolBenchArgs {
128+
total_length: 10_000,
129+
avg_run_length: 10,
130+
distribution: BoolDistribution::MostlyTrue,
131+
},
132+
BoolBenchArgs {
133+
total_length: 10_000,
134+
avg_run_length: 100,
135+
distribution: BoolDistribution::MostlyTrue,
136+
},
137+
BoolBenchArgs {
138+
total_length: 10_000,
139+
avg_run_length: 1000,
140+
distribution: BoolDistribution::MostlyTrue,
141+
},
142+
BoolBenchArgs {
143+
total_length: 10_000,
144+
avg_run_length: 2,
145+
distribution: BoolDistribution::MostlyFalse,
146+
},
147+
BoolBenchArgs {
148+
total_length: 10_000,
149+
avg_run_length: 10,
150+
distribution: BoolDistribution::MostlyFalse,
151+
},
152+
BoolBenchArgs {
153+
total_length: 10_000,
154+
avg_run_length: 100,
155+
distribution: BoolDistribution::MostlyFalse,
156+
},
157+
BoolBenchArgs {
158+
total_length: 10_000,
159+
avg_run_length: 1000,
160+
distribution: BoolDistribution::MostlyFalse,
161+
},
162+
BoolBenchArgs {
163+
total_length: 10_000,
164+
avg_run_length: 2,
165+
distribution: BoolDistribution::AllTrue,
166+
},
167+
BoolBenchArgs {
168+
total_length: 10_000,
169+
avg_run_length: 10,
170+
distribution: BoolDistribution::AllTrue,
171+
},
172+
BoolBenchArgs {
173+
total_length: 10_000,
174+
avg_run_length: 100,
175+
distribution: BoolDistribution::AllTrue,
176+
},
177+
BoolBenchArgs {
178+
total_length: 10_000,
179+
avg_run_length: 1000,
180+
distribution: BoolDistribution::AllTrue,
181+
},
182+
BoolBenchArgs {
183+
total_length: 10_000,
184+
avg_run_length: 2,
185+
distribution: BoolDistribution::AllFalse,
186+
},
187+
BoolBenchArgs {
188+
total_length: 10_000,
189+
avg_run_length: 10,
190+
distribution: BoolDistribution::AllFalse,
191+
},
192+
BoolBenchArgs {
193+
total_length: 10_000,
194+
avg_run_length: 100,
195+
distribution: BoolDistribution::AllFalse,
196+
},
197+
BoolBenchArgs {
198+
total_length: 10_000,
199+
avg_run_length: 1000,
200+
distribution: BoolDistribution::AllFalse,
201+
},
75202
];
76203

77204
#[divan::bench(args = BOOL_ARGS)]
78-
fn decode_bool_alternating(bencher: Bencher, (total_length, avg_run_length): (usize, usize)) {
79-
let (ends, values) =
80-
create_bool_test_data(total_length, avg_run_length, BoolDistribution::Alternating);
81-
bencher.bench(|| runend_decode_bools(ends.clone(), values.clone(), 0, total_length));
82-
}
83-
84-
#[divan::bench(args = BOOL_ARGS)]
85-
fn decode_bool_mostly_true(bencher: Bencher, (total_length, avg_run_length): (usize, usize)) {
86-
let (ends, values) =
87-
create_bool_test_data(total_length, avg_run_length, BoolDistribution::MostlyTrue);
88-
bencher.bench(|| runend_decode_bools(ends.clone(), values.clone(), 0, total_length));
89-
}
90-
91-
#[divan::bench(args = BOOL_ARGS)]
92-
fn decode_bool_mostly_false(bencher: Bencher, (total_length, avg_run_length): (usize, usize)) {
93-
let (ends, values) =
94-
create_bool_test_data(total_length, avg_run_length, BoolDistribution::MostlyFalse);
95-
bencher.bench(|| runend_decode_bools(ends.clone(), values.clone(), 0, total_length));
96-
}
97-
98-
#[divan::bench(args = BOOL_ARGS)]
99-
fn decode_bool_all_true(bencher: Bencher, (total_length, avg_run_length): (usize, usize)) {
100-
let (ends, values) =
101-
create_bool_test_data(total_length, avg_run_length, BoolDistribution::AllTrue);
102-
bencher.bench(|| runend_decode_bools(ends.clone(), values.clone(), 0, total_length));
103-
}
104-
105-
#[divan::bench(args = BOOL_ARGS)]
106-
fn decode_bool_all_false(bencher: Bencher, (total_length, avg_run_length): (usize, usize)) {
107-
let (ends, values) =
108-
create_bool_test_data(total_length, avg_run_length, BoolDistribution::AllFalse);
109-
bencher.bench(|| runend_decode_bools(ends.clone(), values.clone(), 0, total_length));
205+
fn decode_bool(bencher: Bencher, args: BoolBenchArgs) {
206+
let BoolBenchArgs {
207+
total_length,
208+
avg_run_length,
209+
distribution,
210+
} = args;
211+
let (bools, indices) = create_bool_test_data(total_length, avg_run_length, distribution);
212+
bencher
213+
.with_inputs(|| (&bools, &indices))
214+
.bench_refs(|(ends, values)| {
215+
runend_decode_bools(ends.clone(), values.clone(), 0, total_length)
216+
});
110217
}

encodings/runend/src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ use vortex_error::vortex_ensure;
3939
use vortex_error::vortex_panic;
4040
use vortex_scalar::PValue;
4141

42-
use crate::compress::runend_decode_bools;
4342
use crate::compress::runend_decode_primitive;
4443
use crate::compress::runend_encode;
44+
use crate::decompress_bool::runend_decode_bools;
4545
use crate::kernel::PARENT_KERNELS;
4646
use crate::rules::RULES;
4747

encodings/runend/src/compress.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ pub fn runend_decode_primitive(
186186
}))
187187
}
188188

189-
pub use crate::decompress_bool::runend_decode_bools;
190-
191189
pub fn runend_decode_typed_primitive<T: NativePType>(
192190
run_ends: impl Iterator<Item = usize>,
193191
values: &[T],

encodings/runend/src/compute/compare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use vortex_error::VortexResult;
1515

1616
use crate::RunEndArray;
1717
use crate::RunEndVTable;
18-
use crate::compress::runend_decode_bools;
18+
use crate::decompress_bool::runend_decode_bools;
1919

2020
impl CompareKernel for RunEndVTable {
2121
fn compare(

0 commit comments

Comments
 (0)