Skip to content
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ taffy = "0.9.0"
take_mut = "0.2.2"
tar = "0.4"
target-lexicon = "0.13"
temp-env = "0.3"
tempfile = "3"
termtree = { version = "1.0" }
test-with = "0.15"
Expand Down
4 changes: 2 additions & 2 deletions encodings/alp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use vortex_array::ArrayVTable;
use vortex_array::aggregate_fn::AggregateFnVTable;
use vortex_array::aggregate_fn::fns::nan_count::NanCount;
use vortex_array::aggregate_fn::session::AggregateFnSessionExt;
use vortex_array::arrays::patched::USE_EXPERIMENTAL_PATCHES;
use vortex_array::arrays::patched::use_experimental_patches;
use vortex_array::session::ArraySessionExt;
use vortex_session::VortexSession;

Expand All @@ -33,7 +33,7 @@ mod alp_rd;
pub fn initialize(session: &VortexSession) {
// If we're using the experimental Patched encoding, register a shim
// for ALP with interior patches to decode as Patched array.
if *USE_EXPERIMENTAL_PATCHES {
if use_experimental_patches() {
session.arrays().register(ALPPatchedPlugin);
} else {
session.arrays().register(ALP);
Expand Down
4 changes: 2 additions & 2 deletions encodings/fastlanes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ use vortex_array::aggregate_fn::AggregateFnVTable;
use vortex_array::aggregate_fn::fns::is_constant::IsConstant;
use vortex_array::aggregate_fn::fns::is_sorted::IsSorted;
use vortex_array::aggregate_fn::session::AggregateFnSessionExt;
use vortex_array::arrays::patched::USE_EXPERIMENTAL_PATCHES;
use vortex_array::arrays::patched::use_experimental_patches;
use vortex_array::session::ArraySessionExt;
use vortex_session::VortexSession;

/// Initialize fastlanes encodings in the given session.
pub fn initialize(session: &VortexSession) {
// If we're using the experimental Patched encoding, register a shim
// for BitPacked with interior patches decode as Patched array.
if *USE_EXPERIMENTAL_PATCHES {
if use_experimental_patches() {
session.arrays().register(BitPackedPatchedPlugin);
} else {
session.arrays().register(BitPacked);
Expand Down
4 changes: 2 additions & 2 deletions vortex-array/public-api.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3466,8 +3466,6 @@ pub fn vortex_array::arrays::patched::PatchedSlotsView<'a>::fmt(&self, f: &mut c

impl<'a> core::marker::Copy for vortex_array::arrays::patched::PatchedSlotsView<'a>

pub static vortex_array::arrays::patched::USE_EXPERIMENTAL_PATCHES: std::sync::lazy_lock::LazyLock<bool>

pub trait vortex_array::arrays::patched::PatchedArrayExt: vortex_array::arrays::patched::PatchedArraySlotsExt

pub fn vortex_array::arrays::patched::PatchedArrayExt::lane_range(&self, chunk: usize, lane: usize) -> vortex_error::VortexResult<core::ops::range::Range<usize>>
Expand Down Expand Up @@ -3512,6 +3510,8 @@ pub fn T::patch_values(&self) -> &vortex_array::ArrayRef

pub fn T::slots_view(&self) -> vortex_array::arrays::patched::PatchedSlotsView<'_>

pub fn vortex_array::arrays::patched::use_experimental_patches() -> bool

pub type vortex_array::arrays::patched::PatchedArray = vortex_array::Array<vortex_array::arrays::patched::Patched>

pub mod vortex_array::arrays::primitive
Expand Down
4 changes: 2 additions & 2 deletions vortex-array/src/aggregate_fn/accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::aggregate_fn::AggregateFnRef;
use crate::aggregate_fn::AggregateFnVTable;
use crate::aggregate_fn::session::AggregateFnSessionExt;
use crate::dtype::DType;
use crate::executor::MAX_ITERATIONS;
use crate::executor::max_iterations;
use crate::scalar::Scalar;

/// Reference-counted type-erased accumulator.
Expand Down Expand Up @@ -108,7 +108,7 @@ impl<V: AggregateFnVTable> DynAccumulator for Accumulator<V> {
let kernels = &session.aggregate_fns().kernels;

let mut batch = batch.clone();
for _ in 0..*MAX_ITERATIONS {
for _ in 0..max_iterations() {
if batch.is::<AnyCanonical>() {
break;
}
Expand Down
4 changes: 2 additions & 2 deletions vortex-array/src/aggregate_fn/accumulator_grouped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::builders::builder_with_capacity;
use crate::builtins::ArrayBuiltins;
use crate::dtype::DType;
use crate::dtype::IntegerPType;
use crate::executor::MAX_ITERATIONS;
use crate::executor::max_iterations;
use crate::match_each_integer_ptype;

/// Reference-counted type-erased grouped accumulator.
Expand Down Expand Up @@ -165,7 +165,7 @@ impl<V: AggregateFnVTable> GroupedAccumulator<V> {
let session = ctx.session().clone();
let kernels = &session.aggregate_fns().grouped_kernels;

for _ in 0..*MAX_ITERATIONS {
for _ in 0..max_iterations() {
if elements.is::<AnyCanonical>() {
break;
}
Expand Down
7 changes: 5 additions & 2 deletions vortex-array/src/arrays/patched/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,8 @@ const fn patch_lanes<V: Sized>() -> usize {
/// array, and eliminate the interior patches.
///
/// The builtin compressor will also generate Patched arrays.
pub static USE_EXPERIMENTAL_PATCHES: LazyLock<bool> =
LazyLock::new(|| env::var("VORTEX_EXPERIMENTAL_PATCHED_ARRAY").is_ok());
pub fn use_experimental_patches() -> bool {
static USE_EXPERIMENTAL_PATCHES: LazyLock<bool> =
LazyLock::new(|| env::var("VORTEX_EXPERIMENTAL_PATCHED_ARRAY").is_ok_and(|v| v == "1"));
*USE_EXPERIMENTAL_PATCHES
}
42 changes: 17 additions & 25 deletions vortex-array/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,21 @@ use crate::memory::HostAllocatorRef;
use crate::memory::MemorySessionExt;
use crate::optimizer::ArrayOptimizer;

/// Maximum number of iterations to attempt when executing an array before giving up and returning
/// an error.
pub(crate) static MAX_ITERATIONS: LazyLock<usize> =
LazyLock::new(|| match std::env::var("VORTEX_MAX_ITERATIONS") {
Ok(val) => val
.parse::<usize>()
.unwrap_or_else(|e| vortex_panic!("VORTEX_MAX_ITERATIONS is not a valid usize: {e}")),
Err(VarError::NotPresent) => 128,
Err(VarError::NotUnicode(_)) => {
vortex_panic!("VORTEX_MAX_ITERATIONS is not a valid unicode string")
}
});
/// Returns the maximum number of iterations to attempt when executing an array before giving up and returning
/// an error, can be by the `VORTEX_MAX_ITERATIONS` env variables, otherwise defaults to 128.
pub(crate) fn max_iterations() -> usize {
static MAX_ITERATIONS: LazyLock<usize> =
LazyLock::new(|| match std::env::var("VORTEX_MAX_ITERATIONS") {
Ok(val) => val.parse::<usize>().unwrap_or_else(|e| {
vortex_panic!("VORTEX_MAX_ITERATIONS is not a valid usize: {e}")
}),
Err(VarError::NotPresent) => 128,
Err(VarError::NotUnicode(_)) => {
vortex_panic!("VORTEX_MAX_ITERATIONS is not a valid unicode string")
}
});
*MAX_ITERATIONS
}

/// Marker trait for types that an [`ArrayRef`] can be executed into.
///
Expand Down Expand Up @@ -95,22 +98,11 @@ impl ArrayRef {
/// For safety, we will error when the number of execution iterations reaches a configurable
/// maximum (default 128, override with `VORTEX_MAX_ITERATIONS`).
pub fn execute_until<M: Matcher>(self, ctx: &mut ExecutionCtx) -> VortexResult<ArrayRef> {
static MAX_ITERATIONS: LazyLock<usize> =
LazyLock::new(|| match std::env::var("VORTEX_MAX_ITERATIONS") {
Ok(val) => val.parse::<usize>().unwrap_or_else(|e| {
vortex_panic!("VORTEX_MAX_ITERATIONS is not a valid usize: {e}")
}),
Err(VarError::NotPresent) => 128,
Err(VarError::NotUnicode(_)) => {
vortex_panic!("VORTEX_MAX_ITERATIONS is not a valid unicode string")
}
});

let mut current = self.optimize()?;
// Stack frames: (parent, slot_idx, done_predicate_for_slot)
let mut stack: Vec<(ArrayRef, usize, DonePredicate)> = Vec::new();

for _ in 0..*MAX_ITERATIONS {
for _ in 0..max_iterations() {
// Check for termination: use the stack frame's done predicate, or the root matcher.
let is_done = stack
.last()
Expand Down Expand Up @@ -179,7 +171,7 @@ impl ArrayRef {

vortex_bail!(
"Exceeded maximum execution iterations ({}) while executing array",
*MAX_ITERATIONS,
max_iterations(),
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions vortex-btrblocks/src/schemes/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use vortex_array::LEGACY_SESSION;
use vortex_array::ToCanonical;
use vortex_array::VortexSessionExecute;
use vortex_array::arrays::Patched;
use vortex_array::arrays::patched::USE_EXPERIMENTAL_PATCHES;
use vortex_array::arrays::patched::use_experimental_patches;
use vortex_array::arrays::primitive::PrimitiveArrayExt;
use vortex_array::dtype::PType;
use vortex_compressor::estimate::CompressionEstimate;
Expand Down Expand Up @@ -120,7 +120,7 @@ impl Scheme for ALPScheme {
let alp_stats = alp_encoded.as_array().statistics().to_owned();
let exponents = alp_encoded.exponents();

if *USE_EXPERIMENTAL_PATCHES {
if use_experimental_patches() {
let patches = alp_encoded.patches();

// Create ALP array without interior patches.
Expand Down
4 changes: 2 additions & 2 deletions vortex-btrblocks/src/schemes/integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use vortex_array::ToCanonical;
use vortex_array::VortexSessionExecute;
use vortex_array::arrays::ConstantArray;
use vortex_array::arrays::Patched;
use vortex_array::arrays::patched::USE_EXPERIMENTAL_PATCHES;
use vortex_array::arrays::patched::use_experimental_patches;
use vortex_array::arrays::primitive::PrimitiveArrayExt;
use vortex_array::scalar::Scalar;
use vortex_compressor::builtins::FloatDictScheme;
Expand Down Expand Up @@ -348,7 +348,7 @@ impl Scheme for BitPackingScheme {
let ptype = packed.dtype().as_ptype();
let mut parts = BitPacked::into_parts(packed);

let array = if *USE_EXPERIMENTAL_PATCHES {
let array = if use_experimental_patches() {
let patches = parts.patches.take();
// Transpose patches into G-ALP style PatchedArray, wrapping an inner BitPackedArray.
let array = BitPacked::try_new(
Expand Down
2 changes: 1 addition & 1 deletion vortex-error/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tokio = { workspace = true, features = ["rt"], optional = true }

[dev-dependencies]
serial_test = { version = "3.3.1" }
temp-env = "0.3"
temp-env = { workspace = true }

[lints]
workspace = true
9 changes: 8 additions & 1 deletion vortex-error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::io;
use std::num::TryFromIntError;
use std::ops::Deref;
use std::sync::Arc;
use std::sync::LazyLock;

/// A string that can be used as an error message.
#[derive(Debug)]
Expand All @@ -38,14 +39,20 @@ where
reason = "intentionally panic in debug mode when VORTEX_PANIC_ON_ERR is set"
)]
fn from(msg: T) -> Self {
if env::var("VORTEX_PANIC_ON_ERR").as_deref().unwrap_or("") == "1" {
if panic_on_err() {
panic!("{}\nBacktrace:\n{}", msg.into(), Backtrace::capture());
} else {
Self(msg.into())
}
}
}

fn panic_on_err() -> bool {
static PANIC_ON_ERR: LazyLock<bool> =
LazyLock::new(|| env::var("VORTEX_PANIC_ON_ERR").is_ok_and(|v| v == "1"));
*PANIC_ON_ERR
}

impl AsRef<str> for ErrString {
fn as_ref(&self) -> &str {
&self.0
Expand Down
4 changes: 2 additions & 2 deletions vortex-file/src/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use vortex_array::arrays::Primitive;
use vortex_array::arrays::Struct;
use vortex_array::arrays::VarBin;
use vortex_array::arrays::VarBinView;
use vortex_array::arrays::patched::USE_EXPERIMENTAL_PATCHES;
use vortex_array::arrays::patched::use_experimental_patches;
use vortex_array::dtype::FieldPath;
use vortex_btrblocks::BtrBlocksCompressorBuilder;
use vortex_btrblocks::SchemeExt;
Expand Down Expand Up @@ -90,7 +90,7 @@ pub static ALLOWED_ENCODINGS: LazyLock<HashSet<ArrayId>> = LazyLock::new(|| {
allowed.insert(Masked.id());
allowed.insert(Dict.id());

if *USE_EXPERIMENTAL_PATCHES {
if use_experimental_patches() {
allowed.insert(Patched.id());
}

Expand Down
2 changes: 1 addition & 1 deletion vortex-layout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ vortex-utils = { workspace = true, features = ["dashmap"] }
[dev-dependencies]
futures = { workspace = true, features = ["executor"] }
rstest = { workspace = true }
temp-env = { workspace = true }
tokio = { workspace = true, features = ["rt", "macros"] }
vortex-array = { path = "../vortex-array", features = ["_test-harness"] }
vortex-io = { path = "../vortex-io", features = ["tokio"] }
vortex-utils = { workspace = true, features = ["_test-harness"] }

[features]
_test-harness = []
Expand Down
Loading
Loading