From 1b2bc53bcf6dd5ef8aec44d3044560564d3a5ba8 Mon Sep 17 00:00:00 2001 From: mkdev11 Date: Sat, 10 Jan 2026 15:03:57 +0200 Subject: [PATCH] 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 " +