You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tustvold (via GitHub)" <gi...@apache.org> on 2023/05/16 14:23:22 UTC

[GitHub] [arrow-datafusion] tustvold opened a new pull request, #6364: Cleanup ExternalSorter metrics (#5885)

tustvold opened a new pull request, #6364:
URL: https://github.com/apache/arrow-datafusion/pull/6364

   # 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 #5885
   Part of #5108 
   
   # 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.  
   -->
   
   In preparation for improving the memory accounting in ExternalSorter / SortPreservingMerge I first wanted to sanitise what already existed. I will call out the various changes in the PR
   
   # 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.
   -->
   
   # 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)?
   -->
   
   # Are there any user-facing changes?
   
   mem_used, spill_count and spilled_bytes are no longer included in BaselineMetrics (as they were only used by ExternalSorter)
   
   CompositeMetricsSet and MemTrackingMetrics have been removed
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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@arrow.apache.org

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


[GitHub] [arrow-datafusion] alamb commented on pull request #6364: Cleanup ExternalSorter metrics (#5885)

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #6364:
URL: https://github.com/apache/arrow-datafusion/pull/6364#issuecomment-1551205097

   My benchmark run shows no changes in performance, as expected
   
   ```
   --------------------
   Benchmark sort.json
   --------------------
   ┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
   ┃ Query        ┃       sort ┃       sort ┃        Change ┃
   ┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
   │ Qsort utf8   │ 63572.72ms │ 65037.97ms │     no change │
   │ Qsort int    │ 77433.88ms │ 75017.20ms │     no change │
   │ Qsort        │ 65095.90ms │ 63913.09ms │     no change │
   │ decimal      │            │            │               │
   │ Qsort        │ 83230.11ms │ 80413.45ms │     no change │
   │ integer      │            │            │               │
   │ tuple        │            │            │               │
   │ Qsort utf8   │ 64949.20ms │ 61437.19ms │ +1.06x faster │
   │ tuple        │            │            │               │
   │ Qsort mixed  │ 74037.84ms │ 70042.36ms │ +1.06x faster │
   │ tuple        │            │            │               │
   ```


-- 
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@arrow.apache.org

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


[GitHub] [arrow-datafusion] tustvold merged pull request #6364: Cleanup ExternalSorter metrics (#5885)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold merged PR #6364:
URL: https://github.com/apache/arrow-datafusion/pull/6364


-- 
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@arrow.apache.org

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


[GitHub] [arrow-datafusion] tustvold commented on a diff in pull request #6364: Cleanup ExternalSorter metrics (#5885)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #6364:
URL: https://github.com/apache/arrow-datafusion/pull/6364#discussion_r1195251814


##########
datafusion/core/src/physical_plan/metrics/composite.rs:
##########
@@ -1,205 +0,0 @@
-// 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.
-
-//! Metrics common for complex operators with multiple steps.
-
-use crate::execution::memory_pool::MemoryPool;
-use crate::physical_plan::metrics::tracker::MemTrackingMetrics;
-use crate::physical_plan::metrics::{
-    BaselineMetrics, Count, ExecutionPlanMetricsSet, MetricValue, MetricsSet, Time,
-    Timestamp,
-};
-use crate::physical_plan::Metric;
-use chrono::{TimeZone, Utc};
-use std::sync::Arc;
-use std::time::Duration;
-
-#[derive(Debug, Clone)]
-/// Collects all metrics during a complex operation, which is composed of multiple steps and
-/// each stage reports its statistics separately.
-/// Give sort as an example, when the dataset is more significant than available memory, it will report
-/// multiple in-mem sort metrics and final merge-sort metrics from `SortPreservingMergeStream`.
-/// Therefore, We need a separation of metrics for which are final metrics (for output_rows accumulation),
-/// and which are intermediate metrics that we only account for elapsed_compute time.
-pub struct CompositeMetricsSet {

Review Comment:
   BaselineMetrics::intermediate replaces the need for this



-- 
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@arrow.apache.org

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


[GitHub] [arrow-datafusion] tustvold commented on a diff in pull request #6364: Cleanup ExternalSorter metrics (#5885)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #6364:
URL: https://github.com/apache/arrow-datafusion/pull/6364#discussion_r1195254773


##########
datafusion/core/src/physical_plan/metrics/tracker.rs:
##########
@@ -1,104 +0,0 @@
-// 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.
-
-//! Metrics with memory usage tracking capability
-
-use crate::physical_plan::metrics::{
-    BaselineMetrics, Count, ExecutionPlanMetricsSet, Time,
-};
-use std::sync::Arc;
-use std::task::Poll;
-
-use crate::error::Result;
-use crate::execution::memory_pool::{MemoryConsumer, MemoryPool, MemoryReservation};
-use arrow::record_batch::RecordBatch;
-
-/// Wraps a [`BaselineMetrics`] and records memory usage on a [`MemoryReservation`]
-#[derive(Debug)]
-pub struct MemTrackingMetrics {

Review Comment:
   I think this construction may date from an earlier iteration of the memory tracking, as it stands now it makes little sense.
   
   The memory reported by the mem_used metric will be a somewhat arbitrary value based on the last value at the point the plan finished. Additionally there isn't any way to use the MemoryReservation in a fallible manner. It felt easier to just separate the concerns of reporting plan metrics from tracking runtime memory usage.



-- 
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@arrow.apache.org

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


[GitHub] [arrow-datafusion] tustvold commented on a diff in pull request #6364: Cleanup ExternalSorter metrics (#5885)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #6364:
URL: https://github.com/apache/arrow-datafusion/pull/6364#discussion_r1195249166


##########
datafusion/core/src/physical_plan/metrics/baseline.rs:
##########
@@ -43,25 +43,16 @@ use crate::error::Result;
 /// // when operator is finished:
 /// baseline_metrics.done();
 /// ```
-#[derive(Debug)]
+#[derive(Debug, Clone)]
 pub struct BaselineMetrics {
     /// end_time is set when `ExecutionMetrics::done()` is called
-    end_time: Timestamp,
+    pub end_time: Timestamp,
 
     /// amount of time the operator was actively trying to use the CPU
-    elapsed_compute: Time,
-
-    /// count of spills during the execution of the operator
-    spill_count: Count,
-
-    /// total spilled bytes during the execution of the operator
-    spilled_bytes: Count,
-
-    /// current memory usage for the operator
-    mem_used: Gauge,

Review Comment:
   These were only used by ExternalSorter and so I figure aren't really Baseline



-- 
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@arrow.apache.org

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


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #6364: Cleanup ExternalSorter metrics (#5885)

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6364:
URL: https://github.com/apache/arrow-datafusion/pull/6364#discussion_r1195630138


##########
datafusion/core/src/physical_plan/sorts/sort.rs:
##########
@@ -56,6 +55,27 @@ use tempfile::NamedTempFile;
 use tokio::sync::mpsc::{Receiver, Sender};
 use tokio::task;
 
+struct ExternalSorterMetrics {

Review Comment:
   I agree it is much nicer to put sorting metrics on the sorter rather than BaselineMetrics



-- 
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@arrow.apache.org

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