Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/10116#discussion_r46501447 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/metric/SQLMetrics.scala --- @@ -149,6 +149,32 @@ private[sql] object SQLMetrics { } /** + * Create a timing metric that reports duration in millis relative to startTime. + * + * The expected usage pattern is: + * On the driver: + * metric = createTimingMetric(..., System.currentTimeMillis) + * On each executor + * < Do some work > + * metric += System.currentTimeMillis + * The metric will then output the latest value across all the executors. This is a proxy for + * wall clock latency as it measures when the last executor finished this stage. + */ + def createTimingMetric(sc: SparkContext, name: String, startTime: Long): LongSQLMetric = { + val stringValue = (values: Seq[Long]) => { + val validValues = values.filter(_ >= startTime) + if (validValues.isEmpty) { + // The clocks between the different machines are not perfectly synced so this can happen. + "0" --- End diff -- This is a nice feature for performance investigation! Should we detect if the machine clocks are synced when starting Spark?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org