From ab61483464de9056f498955b9554fb8a1f8c4972 Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Wed, 12 Mar 2025 13:19:16 +0000 Subject: [PATCH 1/4] Don't try to fuzz unsupported compare on struct dtype --- Cargo.toml | 4 ++-- fuzz/src/lib.rs | 34 +++++++++++++++------------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0509188e1c4..1876d00d223 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -260,8 +260,8 @@ unwrap_used = "deny" use_debug = "deny" [profile.release] -codegen-units = 1 -lto = "thin" # attempts to perform optimizations across all crates within the dependency graph +#codegen-units = 1 +#lto = "thin" # attempts to perform optimizations across all crates within the dependency graph [profile.release_debug] debug = "full" diff --git a/fuzz/src/lib.rs b/fuzz/src/lib.rs index 427006f23b7..85fc6d52f9d 100644 --- a/fuzz/src/lib.rs +++ b/fuzz/src/lib.rs @@ -13,13 +13,12 @@ use libfuzzer_sys::arbitrary::Error::EmptyChoose; use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured}; pub use sort::sort_canonical_array; use vortex_array::aliases::hash_set::HashSet; -use vortex_array::arrays::ListEncoding; use vortex_array::arrays::arbitrary::ArbitraryArray; use vortex_array::compute::{Operator, SearchResult, SearchSortedSide, scalar_at}; -use vortex_array::vtable::EncodingVTable; -use vortex_array::{Array, ArrayRef, ArrayVisitorExt, EncodingId, IntoArray}; +use vortex_array::{Array, ArrayRef, IntoArray}; use vortex_btrblocks::BtrBlocksCompressor; use vortex_buffer::Buffer; +use vortex_dtype::DType; use vortex_error::{VortexUnwrap, vortex_panic}; use vortex_mask::Mask; use vortex_scalar::Scalar; @@ -74,7 +73,7 @@ impl<'a> Arbitrary<'a> for FuzzArrayAction { let array = ArbitraryArray::arbitrary(u)?.0; let mut current_array = array.to_array(); - let valid_actions = actions_for_array(¤t_array); + let valid_actions = actions_for_dtype(current_array.dtype()).into_iter().collect::>(); let mut actions = Vec::new(); let action_count = u.int_in_range(1..=4)?; @@ -201,21 +200,18 @@ fn random_value_from_list(u: &mut Unstructured<'_>, vec: &[usize]) -> Result = 0..=5; -fn actions_for_encoding(encoding_id: EncodingId) -> HashSet { - if ListEncoding.id() == encoding_id { +fn actions_for_dtype(dtype: &DType) -> HashSet { + match dtype { + // All but compare + DType::Struct(sdt, _) => sdt + .fields() + .map(|child| actions_for_dtype(&child)) + .fold((0..=4).collect(), |acc, actions| { + acc.intersection(&actions).copied().collect() + }), + // Once we support more list operations also recurse here on child dtype // compress, slice - vec![0, 1].into_iter().collect() - } else { - ALL_ACTIONS.collect() + DType::List(..) => [0, 1].into_iter().collect(), + _ => ALL_ACTIONS.collect(), } } - -fn actions_for_array(array: &dyn Array) -> Vec { - array - .depth_first_traversal() - .map(|child| actions_for_encoding(child.encoding())) - .fold(ALL_ACTIONS.collect::>(), |mut acc, actions| { - acc.retain(|a| actions.contains(a)); - acc - }) -} From 08f5cdda7444ed8a007ee0de23a4076ad35ffd2f Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Wed, 12 Mar 2025 13:34:47 +0000 Subject: [PATCH 2/4] less --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1876d00d223..0509188e1c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -260,8 +260,8 @@ unwrap_used = "deny" use_debug = "deny" [profile.release] -#codegen-units = 1 -#lto = "thin" # attempts to perform optimizations across all crates within the dependency graph +codegen-units = 1 +lto = "thin" # attempts to perform optimizations across all crates within the dependency graph [profile.release_debug] debug = "full" From efaa4b77505fca99eb0a9bba27c44f0ab01d51bb Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Wed, 12 Mar 2025 13:45:34 +0000 Subject: [PATCH 3/4] format --- fuzz/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fuzz/src/lib.rs b/fuzz/src/lib.rs index 85fc6d52f9d..d1c4ce03528 100644 --- a/fuzz/src/lib.rs +++ b/fuzz/src/lib.rs @@ -73,7 +73,9 @@ impl<'a> Arbitrary<'a> for FuzzArrayAction { let array = ArbitraryArray::arbitrary(u)?.0; let mut current_array = array.to_array(); - let valid_actions = actions_for_dtype(current_array.dtype()).into_iter().collect::>(); + let valid_actions = actions_for_dtype(current_array.dtype()) + .into_iter() + .collect::>(); let mut actions = Vec::new(); let action_count = u.int_in_range(1..=4)?; From eacd7eae0c233558ac89f30a2442268a81d4c3b9 Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Wed, 12 Mar 2025 15:11:25 +0000 Subject: [PATCH 4/4] sort --- fuzz/fuzz_targets/array_ops.rs | 5 ++--- fuzz/src/lib.rs | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fuzz/fuzz_targets/array_ops.rs b/fuzz/fuzz_targets/array_ops.rs index 6551f102800..994ec65f20f 100644 --- a/fuzz/fuzz_targets/array_ops.rs +++ b/fuzz/fuzz_targets/array_ops.rs @@ -22,11 +22,10 @@ fuzz_target!(|fuzz_action: FuzzArrayAction| -> Corpus { for (i, (action, expected)) in actions.into_iter().enumerate() { match action { Action::Compress => { - let compressed_array = BtrBlocksCompressor + current_array = BtrBlocksCompressor .compress(current_array.to_canonical().vortex_unwrap().as_ref()) .vortex_unwrap(); - assert_array_eq(&expected.array(), &compressed_array, i); - current_array = compressed_array; + assert_array_eq(&expected.array(), ¤t_array, i); } Action::Slice(range) => { current_array = slice(¤t_array, range.start, range.end).vortex_unwrap(); diff --git a/fuzz/src/lib.rs b/fuzz/src/lib.rs index d1c4ce03528..ded949189b9 100644 --- a/fuzz/src/lib.rs +++ b/fuzz/src/lib.rs @@ -73,9 +73,10 @@ impl<'a> Arbitrary<'a> for FuzzArrayAction { let array = ArbitraryArray::arbitrary(u)?.0; let mut current_array = array.to_array(); - let valid_actions = actions_for_dtype(current_array.dtype()) + let mut valid_actions = actions_for_dtype(current_array.dtype()) .into_iter() .collect::>(); + valid_actions.sort_unstable(); let mut actions = Vec::new(); let action_count = u.int_in_range(1..=4)?;