-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve hashjoin execution metrics #4394
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,7 +149,9 @@ pub struct HashJoinExec { | |
#[derive(Debug)] | ||
struct HashJoinMetrics { | ||
/// Total time for joining probe-side batches to the build-side batches | ||
join_time: metrics::Time, | ||
probe_time: metrics::Time, | ||
/// Total time for building hashmap | ||
build_time: metrics::Time, | ||
/// Number of batches consumed by this operator | ||
input_batches: metrics::Count, | ||
/// Number of rows consumed by this operator | ||
|
@@ -162,7 +164,9 @@ struct HashJoinMetrics { | |
|
||
impl HashJoinMetrics { | ||
pub fn new(partition: usize, metrics: &ExecutionPlanMetricsSet) -> Self { | ||
let join_time = MetricBuilder::new(metrics).subset_time("join_time", partition); | ||
let probe_time = MetricBuilder::new(metrics).subset_time("probe_time", partition); | ||
|
||
let build_time = MetricBuilder::new(metrics).subset_time("build_time", partition); | ||
|
||
let input_batches = | ||
MetricBuilder::new(metrics).counter("input_batches", partition); | ||
|
@@ -175,7 +179,8 @@ impl HashJoinMetrics { | |
let output_rows = MetricBuilder::new(metrics).output_rows(partition); | ||
|
||
Self { | ||
join_time, | ||
probe_time, | ||
build_time, | ||
input_batches, | ||
input_rows, | ||
output_batches, | ||
|
@@ -1487,10 +1492,12 @@ impl HashJoinStream { | |
&mut self, | ||
cx: &mut std::task::Context<'_>, | ||
) -> Poll<Option<ArrowResult<RecordBatch>>> { | ||
let build_timer = self.join_metrics.build_time.timer(); | ||
let left_data = match ready!(self.left_fut.get(cx)) { | ||
Ok(left_data) => left_data, | ||
Err(e) => return Poll::Ready(Some(Err(e))), | ||
}; | ||
build_timer.done(); | ||
|
||
let visited_left_side = self.visited_left_side.get_or_insert_with(|| { | ||
let num_rows = left_data.1.num_rows(); | ||
|
@@ -1516,7 +1523,7 @@ impl HashJoinStream { | |
.poll_next_unpin(cx) | ||
.map(|maybe_batch| match maybe_batch { | ||
Some(Ok(batch)) => { | ||
let timer = self.join_metrics.join_time.timer(); | ||
let timer = self.join_metrics.probe_time.timer(); | ||
let result = build_batch( | ||
&batch, | ||
left_data, | ||
|
@@ -1532,7 +1539,6 @@ impl HashJoinStream { | |
self.join_metrics.input_batches.add(1); | ||
self.join_metrics.input_rows.add(batch.num_rows()); | ||
if let Ok((ref batch, ref left_side)) = result { | ||
timer.done(); | ||
self.join_metrics.output_batches.add(1); | ||
self.join_metrics.output_rows.add(batch.num_rows()); | ||
|
||
|
@@ -1551,11 +1557,13 @@ impl HashJoinStream { | |
| JoinType::RightAnti => {} | ||
} | ||
} | ||
Some(result.map(|x| x.0)) | ||
let final_result = Some(result.map(|x| x.0)); | ||
timer.done(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think drop will handle this for you (so the explicit |
||
final_result | ||
} | ||
Some(err) => Some(err), | ||
None => { | ||
let timer = self.join_metrics.join_time.timer(); | ||
let timer = self.join_metrics.probe_time.timer(); | ||
// For the left join, produce rows for unmatched rows | ||
match self.join_type { | ||
JoinType::Left | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be timing the overall clock time (not the cpu time) of the build. As long as that is what you are trying to time 👍