forked from NVIDIA/spark-rapids-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding GC Metrics Signed-off-by: Sayed Bilal Bari <[email protected]> * Review comment changes Signed-off-by: Sayed Bilal Bari <[email protected]> * Correcting output format + refactoring Signed-off-by: Sayed Bilal Bari <[email protected]> * Output Formatting Changes Signed-off-by: Sayed Bilal Bari <[email protected]> * Formatting + Making qual bench single threaded Signed-off-by: Sayed Bilal Bari <[email protected]> --------- Signed-off-by: Sayed Bilal Bari <[email protected]> Co-authored-by: Sayed Bilal Bari <[email protected]>
- Loading branch information
Showing
4 changed files
with
96 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
core/src/main/scala/org/apache/spark/sql/rapids/tool/util/MemoryMetricsTracker.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.apache.spark.sql.rapids.tool.util | ||
|
||
import java.lang.management.ManagementFactory | ||
|
||
import scala.collection.convert.ImplicitConversions.`collection AsScalaIterable` | ||
|
||
/** | ||
* Utility class to track memory metrics. | ||
* This class is used to track memory metrics such as GC count, GC time, | ||
* heap memory usage, etc. | ||
* | ||
*/ | ||
class MemoryMetricsTracker { | ||
private val startGCMetrics = getCurrentGCMetrics | ||
|
||
private def getCurrentGCMetrics: (Long, Long) = { | ||
val gcBeans = ManagementFactory.getGarbageCollectorMXBeans | ||
|
||
(gcBeans.map(_.getCollectionCount).sum, | ||
gcBeans.map(_.getCollectionTime).sum) | ||
} | ||
|
||
def getTotalGCCount: Long = { | ||
val (newGcCount:Long, _) = getCurrentGCMetrics | ||
newGcCount - startGCMetrics._1 | ||
} | ||
|
||
def getTotalGCTime: Long = { | ||
val (_, newGcTime:Long) = getCurrentGCMetrics | ||
newGcTime - startGCMetrics._2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters