Skip to content

Commit

Permalink
feat: log the execution plan in a more compact fashion (#2906)
Browse files Browse the repository at this point in the history
Currently we log the debug representation of the plan (twice!) every
time a plan is executed. This is way too much information (e.g. the
object store's debug information is repeated many times). In one
egregious case I was dealing with that had 8k fragments this was
generating 35MB of log data!

This PR changes to an indented display representation of the plan.
  • Loading branch information
westonpace committed Sep 18, 2024
1 parent 73599c5 commit 9c361fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 9 additions & 3 deletions rust/lance-datafusion/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ use datafusion::{
TaskContext,
},
physical_plan::{
stream::RecordBatchStreamAdapter, streaming::PartitionStream, DisplayAs, DisplayFormatType,
ExecutionPlan, PlanProperties, SendableRecordBatchStream,
display::DisplayableExecutionPlan, stream::RecordBatchStreamAdapter,
streaming::PartitionStream, DisplayAs, DisplayFormatType, ExecutionPlan, PlanProperties,
SendableRecordBatchStream,
},
};
use datafusion_common::{DataFusionError, Statistics};
Expand All @@ -29,7 +30,7 @@ use lazy_static::lazy_static;
use futures::stream;
use lance_arrow::SchemaExt;
use lance_core::Result;
use log::{info, warn};
use log::{debug, info, warn};

/// An source execution node created from an existing stream
///
Expand Down Expand Up @@ -241,6 +242,11 @@ pub fn execute_plan(
plan: Arc<dyn ExecutionPlan>,
options: LanceExecutionOptions,
) -> Result<SendableRecordBatchStream> {
debug!(
"Executing plan:\n{}",
DisplayableExecutionPlan::new(plan.as_ref()).indent(true)
);

let session_ctx = get_session_context(options);

// NOTE: we are only executing the first partition here. Therefore, if
Expand Down
3 changes: 0 additions & 3 deletions rust/lance/src/dataset/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ use lance_index::{scalar::expression::ScalarIndexExpr, DatasetIndexExt};
use lance_io::stream::RecordBatchStream;
use lance_linalg::distance::MetricType;
use lance_table::format::{Fragment, Index};
use log::debug;
use roaring::RoaringBitmap;
use tracing::{info_span, instrument, Span};

Expand Down Expand Up @@ -1112,8 +1111,6 @@ impl Scanner {
plan = rule.optimize(plan, &options)?;
}

debug!("Execution plan:\n{:?}", plan);

Ok(plan)
}

Expand Down

0 comments on commit 9c361fe

Please sign in to comment.