You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/04/18 10:32:27 UTC

[GitHub] [arrow] alamb commented on a change in pull request #10078: ARROW-12432: [Rust] [DataFusion] Add metrics to SortExec

alamb commented on a change in pull request #10078:
URL: https://github.com/apache/arrow/pull/10078#discussion_r615377229



##########
File path: rust/arrow/Cargo.toml
##########
@@ -47,7 +47,7 @@ regex = "1.3"
 lazy_static = "1.4"
 packed_simd = { version = "0.3.4", optional = true, package = "packed_simd_2" }
 chrono = "0.4"
-flatbuffers = "^0.8"
+flatbuffers = "=0.8.3" # 0.8.4 introduces const generics

Review comment:
       this may be accidentally included from  https://github.com/apache/arrow/pull/10081

##########
File path: rust/datafusion/src/physical_plan/sort.rs
##########
@@ -379,7 +430,8 @@ mod tests {
         assert_eq!(DataType::Float32, *sort_exec.schema().field(0).data_type());
         assert_eq!(DataType::Float64, *sort_exec.schema().field(1).data_type());
 
-        let result: Vec<RecordBatch> = collect(sort_exec).await?;
+        let result: Vec<RecordBatch> = collect(sort_exec.clone()).await?;
+        assert_eq!(sort_exec.metrics().get("outputRows").unwrap().value, 8);
         assert_eq!(result.len(), 1);

Review comment:
       Maybe also assert that the time counter was greater than zero?

##########
File path: rust/datafusion/src/physical_plan/sort.rs
##########
@@ -56,7 +63,12 @@ impl SortExec {
         expr: Vec<PhysicalSortExpr>,
         input: Arc<dyn ExecutionPlan>,
     ) -> Result<Self> {
-        Ok(Self { expr, input })
+        Ok(Self {
+            expr,
+            input,
+            output_rows: SQLMetric::counter("outputRows"),
+            sort_time_nanos: SQLMetric::time_nanos("sortTime"),

Review comment:
       Given Rust's focus on compile time type checking, what would you think about using typed counters rather than `String` keys? 
   
   So make the code look something like:
   
   ```suggestion
               output_rows: SQLMetric<OutputRows>::new(),
               sort_time_nanos: SQLMetric<SortTime>::new(),
   ```

##########
File path: rust/datafusion/src/physical_plan/mod.rs
##########
@@ -52,6 +52,8 @@ pub type SendableRecordBatchStream = Pin<Box<dyn RecordBatchStream + Send + Sync
 pub enum MetricType {
     /// Simple counter
     Counter,
+    /// Time in nanoseconds

Review comment:
       It would probably help to explicitly mention if this was wall clock time, or cpu time . It looks like this PR saves wallclock time for sort
   
   Both are probably interesting counters / metrics to eventually have




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org