Skip to content

Conversation

@Ted-Jiang
Copy link
Member

Which issue does this PR close?

Closes #3024 .

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the core Core DataFusion crate label Aug 8, 2022
partition_values,
} => match ready!(reader.poll_next_unpin(cx)) {
Some(result) => {
if let Some(instant) =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here will add first one batch processing time in total scanning time, I think it's acceptable🤔

@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2022

Codecov Report

Merging #3070 (a02279e) into master (0e0931d) will increase coverage by 0.08%.
The diff coverage is 96.29%.

@@            Coverage Diff             @@
##           master    #3070      +/-   ##
==========================================
+ Coverage   85.85%   85.93%   +0.08%     
==========================================
  Files         289      289              
  Lines       51890    52118     +228     
==========================================
+ Hits        44548    44789     +241     
+ Misses       7342     7329      -13     
Impacted Files Coverage Δ
...afusion/core/src/physical_plan/file_format/avro.rs 0.00% <ø> (ø)
.../core/src/physical_plan/file_format/file_stream.rs 90.98% <95.83%> (+0.50%) ⬆️
...tafusion/core/src/physical_plan/file_format/csv.rs 94.47% <100.00%> (ø)
...afusion/core/src/physical_plan/file_format/json.rs 93.93% <100.00%> (ø)
...sion/core/src/physical_plan/file_format/parquet.rs 95.46% <100.00%> (ø)
datafusion/core/tests/sql/mod.rs 97.79% <0.00%> (-0.31%) ⬇️
datafusion/proto/src/from_proto.rs 35.32% <0.00%> (-0.22%) ⬇️
datafusion/proto/src/to_proto.rs 52.94% <0.00%> (-0.10%) ⬇️
datafusion/expr/src/columnar_value.rs 100.00% <0.00%> (ø)
datafusion/core/tests/sql/timestamp.rs 100.00% <0.00%> (ø)
... and 13 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@Ted-Jiang
Copy link
Member Author

@alamb PTAL😊

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @Ted-Jiang -- I think this could go in as is.

One thought I had was that you might consider wrapping the logic for Time / Instant handling into its own struct

So instead of

    pub time_opening: (metrics::Time, Option<Instant>),

You could have something like

    pub time_opening: StartableTimer

where

struct StartableTime {
  metrics::Time, 
  start: Option<Instant>
}

impl StartableTime {
  fn start(&mut self) {
     assert!(self.start.is_none());
     self.start = Some(Instant::now());
  }

  fn stop(&mut self) {
    if let Some(start) = self.start.take() {
       self.timer.add_elapsed(start);
    }
}

.time_scanning
.0
.add_elapsed(instant);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder does it matter if we update these metrics on plan failure? As in if the stream is never ready the 'file opening time' will never get updated. Maybe that is ok 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, if the stream is never ready, it just not the metric issue😂

Ted-Jiang and others added 2 commits August 8, 2022 23:24
@Ted-Jiang
Copy link
Member Author

@alamb Thanks for your kindly advice! 👍
Following your advice, the code seems more clear and readable.😄
I have test in cli , metircs works fine.

 ParquetExec: limit=None, partitions=[Users/yangjiang/test-data/1g_tpch_pageIndex/lineitem_order/part-00000-a9999d7d-8a8b-48dd-b19d-9d06cade164b-c000.snappy.parquet], predicate=l_shipdate_max@0 >= 10471, 
projection=[l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment], metrics=[output_rows=2191114, elapsed_compute=1ns, spill_count=0, spilled_bytes=0, mem_used=0, num_predicate_creation_errors=0, predicate_evaluation_errors{filename=Users/yangjiang/test-data/1g_tpch_pageIndex/lineitem_order/part-00000-a9999d7d-8a8b-48dd-b19d-9d06cade164b-c000.snappy.parquet}=0, bytes_scanned{filename=xxx0.snappy.parquet}=76906726, row_groups_pruned{filename==xxx000.snappy.parquet}=1, 

time_elapsed_processing=12.378207765s, time_elapsed_opening=3.136067ms, time_elapsed_scanning=132.449522ms] |

@alamb
Copy link
Contributor

alamb commented Aug 8, 2022

Thanks @Ted-Jiang -- great to hear -- looks like the new assertions have been triggered in some CI tests. Testing for the win!

Limit,
}

struct StartableTime {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

None => return Poll::Ready(None),
};

self.file_stream_metrics.time_opening.start();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 looking very nice

}
None => self.state = FileStreamState::Idle,
None => {
self.file_stream_metrics.time_scanning.stop();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot stop timer here 😂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing for the Win!

@alamb alamb merged commit 098f0b0 into apache:master Aug 9, 2022
@alamb
Copy link
Contributor

alamb commented Aug 9, 2022

Thanks again @Ted-Jiang

@ursabot
Copy link

ursabot commented Aug 9, 2022

Benchmark runs are scheduled for baseline = 31381bf and contender = 098f0b0. 098f0b0 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize file stream metrics.

4 participants