-
Notifications
You must be signed in to change notification settings - Fork 182
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
fix: Various metrics bug fixes and improvements #1111
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
725ccb4
Refactor native planner to build tree of SparkPlan that maps to origi…
andygrove 581984e
add SparkPlan children
andygrove d25f2d3
clippy
andygrove 2027dc9
add some more documentation
andygrove 8c8c9a5
aggregate metrics
andygrove baae1ba
simplify approach
andygrove 68d0fdf
add a unit test
andygrove 2347203
save progress
andygrove d0aeda1
remove debug, add specific jvm timer
andygrove 3359738
fix
andygrove 0a8a06b
clippy
andygrove 40e90d5
clippy
andygrove 5bfe334
format
andygrove 0a3044e
Revert some changes, update documentation
andygrove d430175
fix typo
andygrove ff5076d
fix typo
andygrove ca66095
measure more FFI time
andygrove 6fd5723
record FFI time for CollectLimitExec and TakeOrderedAndProject
andygrove c512187
upmerge:
andygrove 56e3ead
save
andygrove 36e6233
Revert "save"
andygrove ff26736
revert FFI timing changes, which are now in a separate PR
andygrove 82c9c7c
remove println
andygrove c77b144
address feedback
andygrove 11b5fb6
address feedback: explain how Spark plan ID is used
andygrove 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
use crate::execution::operators::{CopyExec, ScanExec}; | ||
use arrow_schema::SchemaRef; | ||
use datafusion::physical_plan::ExecutionPlan; | ||
use std::sync::Arc; | ||
|
||
/// Wrapper around a native plan that maps to a Spark plan and can optionally contain | ||
/// references to other native plans that should contribute to the Spark SQL metrics | ||
/// for the root plan (such as CopyExec and ScanExec nodes) | ||
#[derive(Debug, Clone)] | ||
pub(crate) struct SparkPlan { | ||
/// Spark plan ID (used for informational purposes only) | ||
pub(crate) plan_id: u32, | ||
/// The root of the native plan that was generated for this Spark plan | ||
pub(crate) native_plan: Arc<dyn ExecutionPlan>, | ||
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. so 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. yes |
||
/// Child Spark plans | ||
pub(crate) children: Vec<Arc<SparkPlan>>, | ||
/// Additional native plans that were generated for this Spark plan that we need | ||
/// to collect metrics for (such as CopyExec and ScanExec) | ||
pub(crate) additional_native_plans: Vec<Arc<dyn ExecutionPlan>>, | ||
} | ||
|
||
impl SparkPlan { | ||
/// Create a SparkPlan that consists of a single native plan | ||
pub(crate) fn new( | ||
plan_id: u32, | ||
native_plan: Arc<dyn ExecutionPlan>, | ||
children: Vec<Arc<SparkPlan>>, | ||
) -> Self { | ||
let mut additional_native_plans: Vec<Arc<dyn ExecutionPlan>> = vec![]; | ||
for child in &children { | ||
collect_additional_plans(Arc::clone(&child.native_plan), &mut additional_native_plans); | ||
} | ||
Self { | ||
plan_id, | ||
native_plan, | ||
children, | ||
additional_native_plans, | ||
} | ||
} | ||
|
||
/// Create a SparkPlan that consists of more than one native plan | ||
pub(crate) fn new_with_additional( | ||
plan_id: u32, | ||
native_plan: Arc<dyn ExecutionPlan>, | ||
children: Vec<Arc<SparkPlan>>, | ||
additional_native_plans: Vec<Arc<dyn ExecutionPlan>>, | ||
) -> Self { | ||
let mut accum: Vec<Arc<dyn ExecutionPlan>> = vec![]; | ||
for plan in &additional_native_plans { | ||
accum.push(Arc::clone(plan)); | ||
} | ||
for child in &children { | ||
collect_additional_plans(Arc::clone(&child.native_plan), &mut accum); | ||
} | ||
Self { | ||
plan_id, | ||
native_plan, | ||
children, | ||
additional_native_plans: accum, | ||
} | ||
} | ||
|
||
/// Get the schema of the native plan | ||
pub(crate) fn schema(&self) -> SchemaRef { | ||
self.native_plan.schema() | ||
} | ||
|
||
/// Get the child SparkPlan instances | ||
pub(crate) fn children(&self) -> &Vec<Arc<SparkPlan>> { | ||
&self.children | ||
} | ||
} | ||
|
||
fn collect_additional_plans( | ||
child: Arc<dyn ExecutionPlan>, | ||
additional_native_plans: &mut Vec<Arc<dyn ExecutionPlan>>, | ||
) { | ||
if child.as_any().is::<CopyExec>() { | ||
additional_native_plans.push(Arc::clone(&child)); | ||
// CopyExec may be wrapping a ScanExec | ||
collect_additional_plans(Arc::clone(child.children()[0]), additional_native_plans); | ||
} else if child.as_any().is::<ScanExec>() { | ||
additional_native_plans.push(Arc::clone(&child)); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.
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.
Is the
plan_id
used somehow?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.
Or additional/child plans searches for the parent by the id?
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.
It was not being used yet, but I have now pushed a commit to include it in the "native explain" output, to make it easier to debug performance issues