Skip to content

Commit

Permalink
minor: split repartition time and send time metrics (apache#11440)
Browse files Browse the repository at this point in the history
  • Loading branch information
korowa authored Jul 16, 2024
1 parent f204869 commit 2837e02
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions datafusion/physical-plan/src/repartition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ impl BatchPartitioner {
num_partitions: partitions,
hash_buffer,
} => {
// Tracking time required for distributing indexes across output partitions
let timer = self.timer.timer();

let arrays = exprs
Expand All @@ -282,6 +283,11 @@ impl BatchPartitioner {
.append_value(index as u64);
}

// Finished building index-arrays for output partitions
timer.done();

// Borrowing partitioner timer to prevent moving `self` to closure
let partitioner_timer = &self.timer;
let it = indices
.into_iter()
.enumerate()
Expand All @@ -290,6 +296,9 @@ impl BatchPartitioner {
(!indices.is_empty()).then_some((partition, indices))
})
.map(move |(partition, indices)| {
// Tracking time required for repartitioned batches construction
let _timer = partitioner_timer.timer();

// Produce batches based on indices
let columns = batch
.columns()
Expand All @@ -303,9 +312,6 @@ impl BatchPartitioner {
let batch =
RecordBatch::try_new(batch.schema(), columns).unwrap();

// bind timer so it drops w/ this iterator
let _ = &timer;

Ok((partition, batch))
});

Expand Down

0 comments on commit 2837e02

Please sign in to comment.