Skip to content

Commit

Permalink
one more metrics for expand (#31)
Browse files Browse the repository at this point in the history
Signed-off-by: Firestarman <[email protected]>
  • Loading branch information
firestarman authored Feb 29, 2024
1 parent 806edc2 commit 429b354
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions sql-plugin/src/main/scala/com/nvidia/spark/rapids/GpuExec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ object GpuMetric extends Logging {
case (k, v) => (k, wrap(v))
}

def ns[T](metrics: GpuMetric*)(f: => T): T = {
val start = System.nanoTime()
try {
f
} finally {
val taken = System.nanoTime() - start
metrics.foreach(_.add(taken))
}
}

object DEBUG_LEVEL extends MetricsLevel(0)
object MODERATE_LEVEL extends MetricsLevel(1)
object ESSENTIAL_LEVEL extends MetricsLevel(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ case class GpuExpandExec(
useTieredProject.asInstanceOf[java.lang.Boolean],
preprojectEnabled.asInstanceOf[java.lang.Boolean])

private val PRE_PROJECT_TIME = "preprojectTime"
override val outputRowsLevel: MetricsLevel = ESSENTIAL_LEVEL
override val outputBatchesLevel: MetricsLevel = MODERATE_LEVEL
override lazy val additionalMetrics: Map[String, GpuMetric] = Map(
PRE_PROJECT_TIME -> createNanoTimingMetric(DEBUG_LEVEL, "pre-projection time"),
OP_TIME -> createNanoTimingMetric(MODERATE_LEVEL, DESCRIPTION_OP_TIME),
NUM_INPUT_ROWS -> createMetric(DEBUG_LEVEL, DESCRIPTION_NUM_INPUT_ROWS),
NUM_INPUT_BATCHES -> createMetric(DEBUG_LEVEL, DESCRIPTION_NUM_INPUT_BATCHES))
Expand Down Expand Up @@ -109,8 +111,10 @@ case class GpuExpandExec(
// We got some nested expressions, so pre-projection is good to enable.
projectionsForBind = preprojectedProjections
attributesForBind = preprojectionList.map(_.toAttribute)
val opMetric = metricsMap(OP_TIME)
val preproMetric = metricsMap(PRE_PROJECT_TIME)
preprojectIter = (iter: Iterator[ColumnarBatch]) => iter.map(cb =>
metricsMap(OP_TIME).ns {
GpuMetric.ns(opMetric, preproMetric) {
boundPreprojections.projectAndCloseWithRetrySingleBatch(
SpillableColumnarBatch(cb, SpillPriorities.ACTIVE_ON_DECK_PRIORITY))
}
Expand Down

0 comments on commit 429b354

Please sign in to comment.