Merge pull request #8460 from MkDev11/fix/gc-monitor-warning-8002

[2.x] fix: Improve GCMonitor warning message clarity
This commit is contained in:
eugene yokota 2026-01-10 16:24:01 -05:00 committed by GitHub
commit 9ba3966ad2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -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 CPU seconds") { d =>
val dSeconds = (d / 1000.0).ceil.toInt
val percentage = total.toDouble / d * 100
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 " +