kiszk commented on a change in pull request #34846:
URL: https://github.com/apache/spark/pull/34846#discussion_r765659849



##########
File path: core/src/main/scala/org/apache/spark/util/Utils.scala
##########
@@ -3204,6 +3205,27 @@ private[spark] object Utils extends Logging {
     }
     files.toSeq
   }
+
+  private def isG1GarbageCollector: Boolean = {
+    val gcs = ManagementFactory.getGarbageCollectorMXBeans.asScala
+    gcs.exists(_.getName.equalsIgnoreCase("G1 Young Generation")) ||
+      gcs.exists(_.getName.equalsIgnoreCase("G1 Old Generation"))
+  }
+
+  /**
+   * Return true if current GC algorithm is G1 GC and the requested sizeInBytes
+   * are larger than 50% of the region size in G1.
+   */
+  def isHumongousAllocation(sizeInBytes: Long): Boolean = {
+    if (isG1GarbageCollector) {
+      val heapRegionSize = ManagementFactory
+        .getPlatformMXBean(classOf[HotSpotDiagnosticMXBean])
+        .getVMOption("G1HeapRegionSize").getValue.toLong

Review comment:
       I am afraid that this line may throw an exception in the future due to 
specification changes.   
   How about wrapping this by `try ... catch`? 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to