uros-b commented on code in PR #57058:
URL: https://github.com/apache/spark/pull/57058#discussion_r3577165093
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SortExec.scala:
##########
@@ -212,3 +206,27 @@ case class SortExec(
override protected def withNewChildInternal(newChild: SparkPlan): SortExec =
copy(child = newChild)
}
+
+object SortExec {
+ /**
+ * Records the sort metrics (sort time, peak memory and spill size) for a
completed sort. This
+ * is called both by the interpreted path ([[SortExec.doExecute]]) and by
the generated code of
+ * [[SortExec.doProduce]], so the type-independent metric bookkeeping is
compiled once per JVM
+ * instead of being re-emitted into every SortExec stage's generated code.
+ *
+ * `spillSizeBefore` is the task's spilled-bytes count captured before the
rows were fed to the
+ * sorter, so that `spillSize` reflects only this operator's contribution.
+ */
+ def recordSortMetrics(
Review Comment:
Nit: consider mentioning that generated code reaches this through the static
forwarder, matching the wording you used for ColumnarToRowExec.advanceBatch
("...called by the generated code of [[ColumnarToRowExec]] (through the static
forwarder)..."). The static-forwarder linkage is the one non-obvious part of
calling a Scala object method from generated Java, so calling it out here keeps
the two helpers consistent and saves the next reader a double-take.
--
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]