From 8ea31fb15cf8bf5ede4913d29d53982c64dd4cbe Mon Sep 17 00:00:00 2001
From: "Ahmed Hussein (amahussein)"
Date: Fri, 15 Nov 2024 11:42:17 -0600
Subject: [PATCH] Trigger GC at the beginning of each benchmark iteration
Signed-off-by: Ahmed Hussein (amahussein)
Contributes to #1423
Trigger a GC at the beginning of each benchmark iteration
---
.../org/apache/spark/rapids/tool/benchmarks/Benchmark.scala | 1 +
1 file changed, 1 insertion(+)
diff --git a/core/src/main/scala/org/apache/spark/rapids/tool/benchmarks/Benchmark.scala b/core/src/main/scala/org/apache/spark/rapids/tool/benchmarks/Benchmark.scala
index a09f121ad..45ad3bdd4 100644
--- a/core/src/main/scala/org/apache/spark/rapids/tool/benchmarks/Benchmark.scala
+++ b/core/src/main/scala/org/apache/spark/rapids/tool/benchmarks/Benchmark.scala
@@ -104,6 +104,7 @@ class Benchmark(
val gcTimes = ArrayBuffer[Long]()
//For tracking maximum GC over iterations
for (i <- 0 until minIters) {
+ System.gc() // ensures GC for a consistent state across different iterations
val timer = new ToolsTimer(i)
val memoryTracker = new MemoryMetricsTracker
f(timer)