Copilot commented on code in PR #13116:
URL: https://github.com/apache/gluten/pull/13116#discussion_r4091556597
##########
backends-bolt/src/main/scala/org/apache/gluten/backendsapi/bolt/BoltMetricsApi.scala:
##########
@@ -543,6 +543,22 @@ class BoltMetricsApi extends MetricsApi with Logging {
override def genSortTransformerMetricsUpdater(metrics: Map[String,
SQLMetric]): MetricsUpdater =
new SortMetricsUpdater(metrics)
+ override def genTopNTransformerMetrics(sparkContext: SparkContext):
Map[String, SQLMetric] =
+ Map(
+ "numOutputRows" -> SQLMetrics.createMetric(sparkContext, "number of
output rows"),
+ "outputVectors" -> SQLMetrics.createMetric(sparkContext, "number of
output vectors"),
+ "outputBytes" -> SQLMetrics.createSizeMetric(sparkContext, "number of
output bytes"),
Review Comment:
The new regression test exercises only the Velox implementation, while this
patch also adds independent Bolt TopN lowering and metric wiring. A failure in
Bolt's updater or metric attachment would therefore pass the current tests; add
the equivalent assertion to `BoltMetricsSuite` (and keep it under the
repository's unit-test coverage).
##########
backends-bolt/src/main/scala/org/apache/gluten/metrics/TopNMetricsUpdater.scala:
##########
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+package org.apache.gluten.metrics
+
+import org.apache.spark.sql.execution.metric.SQLMetric
+
+// Bolt lowers TopN to a bounded-heap `TopNNode`, which never spills. Hence,
unlike
+// SortMetricsUpdater, no spill-related metrics are collected here.
+class TopNMetricsUpdater(val metrics: Map[String, SQLMetric]) extends
MetricsUpdater {
+
+ override def updateNativeMetrics(opMetrics: IOperatorMetrics): Unit = {
+ if (opMetrics != null) {
+ val operatorMetrics = opMetrics.asInstanceOf[OperatorMetrics]
+ metrics("numOutputRows") += operatorMetrics.outputRows
+ metrics("outputVectors") += operatorMetrics.outputVectors
+ metrics("outputBytes") += operatorMetrics.outputBytes
+ metrics("cpuCount") += operatorMetrics.cpuCount
+ metrics("wallNanos") += operatorMetrics.wallNanos
Review Comment:
This updater drops `operatorMetrics.loadLazyVectorTime`, and the
corresponding metric is also absent from `genTopNTransformerMetrics`. The Bolt
native metrics already expose this field for other operators, so TopN silently
loses it; add the metric to the map and update it here to preserve the stated
parity with `LimitMetricsUpdater`.
##########
backends-velox/src/main/scala/org/apache/gluten/metrics/TopNMetricsUpdater.scala:
##########
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+package org.apache.gluten.metrics
+
+import org.apache.spark.sql.execution.metric.SQLMetric
+
+// Velox lowers TopN to a bounded-heap `TopNNode`, which never spills. Hence,
unlike
+// SortMetricsUpdater, no spill-related metrics are collected here.
+class TopNMetricsUpdater(val metrics: Map[String, SQLMetric]) extends
MetricsUpdater {
+
+ override def updateNativeMetrics(opMetrics: IOperatorMetrics): Unit = {
+ if (opMetrics != null) {
+ val operatorMetrics = opMetrics.asInstanceOf[OperatorMetrics]
+ metrics("numOutputRows") += operatorMetrics.outputRows
+ metrics("outputVectors") += operatorMetrics.outputVectors
+ metrics("outputBytes") += operatorMetrics.outputBytes
+ metrics("cpuCount") += operatorMetrics.cpuCount
+ metrics("wallNanos") += operatorMetrics.wallNanos
Review Comment:
This updater drops `operatorMetrics.loadLazyVectorTime`, and the
corresponding metric is also absent from `genTopNTransformerMetrics`. The Velox
native metrics already expose this field for other operators, so TopN silently
loses it; add the metric to the map and update it here to preserve the stated
parity with `LimitMetricsUpdater`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]