You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "andygrove (via GitHub)" <gi...@apache.org> on 2024/11/19 19:55:09 UTC
[PR] chore: Add native metrics for plan creation time [datafusion-comet]
andygrove opened a new pull request, #1100:
URL: https://github.com/apache/datafusion-comet/pull/1100
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Part of https://github.com/apache/datafusion-comet/issues/1098
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
When enabling the "native explain" feature, we see metrics for plan execution but not for plan creation.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
Show timings for plan creation.
## How are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
Non-functional change. Existing tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Add native metrics for plan creation time [datafusion-comet]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #1100:
URL: https://github.com/apache/datafusion-comet/pull/1100#discussion_r1849115188
##########
native/core/src/execution/jni_api.rs:
##########
@@ -335,20 +343,26 @@ pub unsafe extern "system" fn Java_org_apache_comet_Native_executePlan(
// Because we don't know if input arrays are dictionary-encoded when we create
// query plan, we need to defer stream initialization to first time execution.
if exec_context.root_op.is_none() {
+ let start = Instant::now();
let planner = PhysicalPlanner::new(Arc::clone(&exec_context.session_ctx))
.with_exec_id(exec_context_id);
let (scans, root_op) = planner.create_plan(
&exec_context.spark_plan,
&mut exec_context.input_sources.clone(),
)?;
+ let physical_plan_time = start.elapsed().as_millis() as usize;
Review Comment:
wondering should we `info!` the planner time?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Improve CometScan metrics [datafusion-comet]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on PR #1100:
URL: https://github.com/apache/datafusion-comet/pull/1100#issuecomment-2489166991
> @viirya @kazuyukitanimura @comphead Could you take another look? The scope increased slightly (see updated PR description).
>
> This is what the logging looks like now for native query plans with metrics:
>
> ```
> [Stage 18 Partition 25] plan creation (including CometScans fetching first batches) took 1.490261253s:
> ShuffleWriterExec: partitioning=UnknownPartitioning(1), metrics=[output_rows=10, elapsed_compute=55.574µs, spill_count=0, spilled_bytes=0, data_size=704]
> ScanExec: source=[], schema=[col_0: Int64, col_1: Decimal128(34, 4), col_2: Date32, col_3: Int32], metrics=[output_rows=20, elapsed_compute=1.490176093s, cast_time=1ns]
> ```
its lgtm, do you need to `info!` explicitly planning times?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Improve CometScan metrics [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #1100:
URL: https://github.com/apache/datafusion-comet/pull/1100#issuecomment-2489603118
> its lgtm, do you need to `info!` explicitly planning times?
I'm going to keep iterating on this. I would like to see the actual planning time without the partial execution of fetching the first batch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Improve CometScan metrics [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #1100:
URL: https://github.com/apache/datafusion-comet/pull/1100#discussion_r1851019192
##########
spark/src/main/scala/org/apache/comet/CometExecIterator.scala:
##########
@@ -95,7 +95,8 @@ class CometExecIterator(
nativeUtil.getNextBatch(
numOutputCols,
(arrayAddrs, schemaAddrs) => {
- nativeLib.executePlan(plan, arrayAddrs, schemaAddrs)
+ val ctx = TaskContext.get()
+ nativeLib.executePlan(ctx.stageId(), ctx.partitionId(), plan, arrayAddrs, schemaAddrs)
Review Comment:
Yes, because we create one plan per partition we have a lot of repeated plans and it is helpful to see the partition number.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Improve CometScan metrics [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #1100:
URL: https://github.com/apache/datafusion-comet/pull/1100#issuecomment-2488823931
@viirya @kazuyukitanimura @comphead Could you take another look? The scope increased slightly (see updated PR description).
This is what the logging looks like now for native query plans with metrics:
```
[Stage 18 Partition 25] plan creation (including CometScans fetching first batches) took 1.490261253s:
ShuffleWriterExec: partitioning=UnknownPartitioning(1), metrics=[output_rows=10, elapsed_compute=55.574µs, spill_count=0, spilled_bytes=0, data_size=704]
ScanExec: source=[], schema=[col_0: Int64, col_1: Decimal128(34, 4), col_2: Date32, col_3: Int32], metrics=[output_rows=20, elapsed_compute=1.490176093s, cast_time=1ns]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Improve CometScan metrics [datafusion-comet]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #1100:
URL: https://github.com/apache/datafusion-comet/pull/1100#discussion_r1850718569
##########
spark/src/main/scala/org/apache/comet/CometExecIterator.scala:
##########
@@ -95,7 +95,8 @@ class CometExecIterator(
nativeUtil.getNextBatch(
numOutputCols,
(arrayAddrs, schemaAddrs) => {
- nativeLib.executePlan(plan, arrayAddrs, schemaAddrs)
+ val ctx = TaskContext.get()
+ nativeLib.executePlan(ctx.stageId(), ctx.partitionId(), plan, arrayAddrs, schemaAddrs)
Review Comment:
is it to track times for specific partitions?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Add native metrics for plan creation time [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #1100:
URL: https://github.com/apache/datafusion-comet/pull/1100#issuecomment-2487170869
I am moving this to draft for now. The plan creation time now matches the ScanExec metric since https://github.com/apache/datafusion-comet/pull/1105 was merged.
I would still like to see the planning time, but only if it excludes execution time for the first batch. I have some ideas I want to try out to resolve this.
```
24/11/19 19:04:23 INFO core/src/execution/jni_api.rs: Comet native query plan with metrics (plan creation took 1339 ms):
ShuffleWriterExec: partitioning=UnknownPartitioning(1), metrics=[output_rows=10, elapsed_compute=32.602µs, spill_count=0, spilled_bytes=0, data_size=704]
ScanExec: source=[], schema=[col_0: Int64, col_1: Decimal128(34, 4), col_2: Date32, col_3: Int32], metrics=[output_rows=20, elapsed_compute=1.339205712s, cast_time=1ns]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Improve CometScan metrics [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove merged PR #1100:
URL: https://github.com/apache/datafusion-comet/pull/1100
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org