Yicong-Huang commented on code in PR #59892:
URL: https://github.com/apache/spark/pull/59892#discussion_r4415938674


##########
python/pyspark/eval_handlers/_base.py:
##########
@@ -330,20 +352,29 @@ class 
BatchEvalTypeHandler(EvalTypeHandler["pa.RecordBatch", OutputBatch]):
 
     @property
     def serializer(self) -> Serializer:
-        return ArrowStreamSerializer(write_start_stream=True)
+        return ArrowStreamSerializer(
+            write_start_stream=True,
+            collect_timing=self._timing_enabled,
+        )
 
 
 class GroupedEvalTypeHandler(EvalTypeHandler[GroupedBatch, OutputBatch]):
     """Handler category whose input stream is ``Iterator[GroupedBatch]``."""
 
     @property
     def serializer(self) -> Serializer:
-        return ArrowStreamGroupSerializer(write_start_stream=True)
+        return ArrowStreamGroupSerializer(
+            write_start_stream=True,
+            collect_timing=self._timing_enabled,

Review Comment:
   can we keep those variables name the same, otherwise it is hard to match them



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala:
##########
@@ -5857,7 +5857,10 @@ object SQLConf {
   val PYTHON_UDF_DETAILED_TIMING_ENABLED =
     buildConf("spark.sql.execution.pythonUDF.detailedTiming.enabled")
       .internal()
-      .doc("When true, collect detailed timing metrics for supported Python 
UDFs.")
+      .doc("When true, collect detailed timing metrics for supported Python 
UDFs. " +
+        "With spark.python.udf.pipelined.enabled, phase timings can overlap 
and their sum " +
+        "does not represent elapsed time. Exclude reports with nonzero " +
+        "pythonNumPipelinedTasks from additive phase breakdowns.")

Review Comment:
   timing the overlapping threads (pipeline thread and main worker thread) is 
not ideal. maybe we should just have a metrics on each thread, to measure 
thread-locally, instead of a global metrics instance? 



##########
python/pyspark/worker_metrics.py:
##########
@@ -121,14 +123,23 @@ def measure(self, name: str) -> _WorkerTimer:
         self._duration_totals_ns.setdefault(name, 0)
         return _WorkerTimer(self._duration_totals_ns, name)
 
+    def subtract_duration_at_report(self, *, total_metric: str, nested_metric: 
str) -> None:
+        """Subtract nested_metric from total_metric at report time without 
registering either."""
+        self._duration_subtractions[total_metric] = nested_metric

Review Comment:
   can we simplify this method, sound like you are recording some sub timing in 
a duration, so that later you can break a duration in parts. would simply 
`set_sub_duration` or `record_sub_duration` work? it has nothing to do with 
report.
   
   at reporting time, we can be free to report the durations or sub-durations 
however we want.



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

Reply via email to