From 1b2bc53bcf6dd5ef8aec44d3044560564d3a5ba8 Mon Sep 17 00:00:00 2001 From: mkdev11 Date: Sat, 10 Jan 2026 15:03:57 +0200 Subject: [PATCH 1/2] fix: Improve GCMonitor warning message clarity Add 'seconds' unit to GC time and clarify that the percentage represents cumulative GC pause time across all collectors. Fixes #8002 --- main/src/main/scala/sbt/internal/GCMonitor.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/src/main/scala/sbt/internal/GCMonitor.scala b/main/src/main/scala/sbt/internal/GCMonitor.scala index 79b49af02..f39b8a4ff 100644 --- a/main/src/main/scala/sbt/internal/GCMonitor.scala +++ b/main/src/main/scala/sbt/internal/GCMonitor.scala @@ -62,8 +62,10 @@ class GCMonitor(logger: Logger) extends GCMonitorBase with AutoCloseable { override protected def emitWarning(total: Long, over: Option[Long]): Unit = { val totalSeconds = total / 1000.0 - val amountMsg = over.fold(s"$totalSeconds seconds") { d => - "In the last " + (d / 1000.0).ceil.toInt + f" seconds, $totalSeconds (${total.toDouble / d * 100}%.1f%%)" + val amountMsg = over.fold(f"$totalSeconds%.3f seconds") { d => + val dSeconds = (d / 1000.0).ceil.toInt + val percentage = total.toDouble / d * 100 + f"In the last $dSeconds seconds, $totalSeconds%.3f seconds ($percentage%.1f%%) of GC pause" } val msg = s"$amountMsg were spent in GC. " + s"[Heap: ${gbString(runtime.freeMemory())} free " + From 9be376973db689810ed63f1b9a534c8d8c8866a7 Mon Sep 17 00:00:00 2001 From: mkdev11 Date: Sat, 10 Jan 2026 22:23:05 +0200 Subject: [PATCH 2/2] fix: Use 'CPU seconds' to clarify GC time can exceed wall clock Address review feedback from eed3si9n to make it clearer that GC time is cumulative CPU time across parallel collectors, which is why it can exceed wall clock time. Fixes #8002 --- main/src/main/scala/sbt/internal/GCMonitor.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/src/main/scala/sbt/internal/GCMonitor.scala b/main/src/main/scala/sbt/internal/GCMonitor.scala index f39b8a4ff..305fda484 100644 --- a/main/src/main/scala/sbt/internal/GCMonitor.scala +++ b/main/src/main/scala/sbt/internal/GCMonitor.scala @@ -62,10 +62,10 @@ class GCMonitor(logger: Logger) extends GCMonitorBase with AutoCloseable { override protected def emitWarning(total: Long, over: Option[Long]): Unit = { val totalSeconds = total / 1000.0 - val amountMsg = over.fold(f"$totalSeconds%.3f seconds") { d => + val amountMsg = over.fold(f"$totalSeconds%.3f CPU seconds") { d => val dSeconds = (d / 1000.0).ceil.toInt val percentage = total.toDouble / d * 100 - f"In the last $dSeconds seconds, $totalSeconds%.3f seconds ($percentage%.1f%%) of GC pause" + f"In the last $dSeconds seconds, $totalSeconds%.3f CPU seconds ($percentage%.1f%%) of GC pause" } val msg = s"$amountMsg were spent in GC. " + s"[Heap: ${gbString(runtime.freeMemory())} free " +