@@ -21,7 +21,6 @@ use std::env::VarError;
2121use std:: fmt;
2222use std:: fmt:: Display ;
2323use std:: sync:: LazyLock ;
24- use std:: sync:: atomic:: AtomicUsize ;
2524
2625use vortex_error:: VortexExpect ;
2726use vortex_error:: VortexResult ;
@@ -107,7 +106,7 @@ impl ArrayRef {
107106 /// For safety, we will error when the number of execution iterations reaches a configurable
108107 /// maximum (default 128, override with `VORTEX_MAX_ITERATIONS`).
109108 pub fn execute_until < M : Matcher > ( self , ctx : & mut ExecutionCtx ) -> VortexResult < ArrayRef > {
110- let mut current = self . optimize ( ) ? ;
109+ let mut current = self ;
111110 let mut stack: Vec < StackFrame > = Vec :: new ( ) ;
112111
113112 for _ in 0 ..max_iterations ( ) {
@@ -221,19 +220,25 @@ impl StackFrame {
221220/// Execution context for batch CPU compute.
222221#[ derive( Debug , Clone ) ]
223222pub struct ExecutionCtx {
224- id : usize ,
225223 session : VortexSession ,
224+ #[ cfg( debug_assertions) ]
225+ id : usize ,
226+ #[ cfg( debug_assertions) ]
226227 ops : Vec < String > ,
227228}
228229
229230impl ExecutionCtx {
230231 /// Create a new execution context with the given session.
231232 pub fn new ( session : VortexSession ) -> Self {
232- static EXEC_CTX_ID : AtomicUsize = AtomicUsize :: new ( 0 ) ;
233- let id = EXEC_CTX_ID . fetch_add ( 1 , std:: sync:: atomic:: Ordering :: Relaxed ) ;
234233 Self {
235234 session,
236- id,
235+ #[ cfg( debug_assertions) ]
236+ id : {
237+ static EXEC_CTX_ID : std:: sync:: atomic:: AtomicUsize =
238+ std:: sync:: atomic:: AtomicUsize :: new ( 0 ) ;
239+ EXEC_CTX_ID . fetch_add ( 1 , std:: sync:: atomic:: Ordering :: Relaxed )
240+ } ,
241+ #[ cfg( debug_assertions) ]
237242 ops : Vec :: new ( ) ,
238243 }
239244 }
@@ -255,20 +260,26 @@ impl ExecutionCtx {
255260 ///
256261 /// Use the [`format_args!`] macro to create the `msg` argument.
257262 pub fn log ( & mut self , msg : fmt:: Arguments < ' _ > ) {
263+ #[ cfg( debug_assertions) ]
258264 if tracing:: enabled!( tracing:: Level :: DEBUG ) {
259265 let formatted = format ! ( " - {msg}" ) ;
260266 tracing:: trace!( "exec[{}]: {formatted}" , self . id) ;
261267 self . ops . push ( formatted) ;
262268 }
269+ let _ = msg;
263270 }
264271}
265272
266273impl Display for ExecutionCtx {
267274 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
268- write ! ( f, "exec[{}]" , self . id)
275+ #[ cfg( debug_assertions) ]
276+ return write ! ( f, "exec[{}]" , self . id) ;
277+ #[ cfg( not( debug_assertions) ) ]
278+ write ! ( f, "exec" )
269279 }
270280}
271281
282+ #[ cfg( debug_assertions) ]
272283impl Drop for ExecutionCtx {
273284 fn drop ( & mut self ) {
274285 if !self . ops . is_empty ( ) && tracing:: enabled!( tracing:: Level :: DEBUG ) {
0 commit comments