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



##########
File path: core/src/main/scala/org/apache/spark/internal/config/package.scala
##########
@@ -2267,4 +2267,12 @@ package object config {
       .version("3.3.0")
       .intConf
       .createWithDefault(5)
+
+  private[spark] val MEMORY_ONHEAP_PAGESIZE_OPTIMIZE_ENABLED =

Review comment:
       Do we need a flag for this? when would I not want it?

##########
File path: core/src/main/scala/org/apache/spark/util/Utils.scala
##########
@@ -3204,6 +3205,33 @@ 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) {
+      try {
+        val heapRegionSize = ManagementFactory
+          .getPlatformMXBean(classOf[HotSpotDiagnosticMXBean])
+          .getVMOption("G1HeapRegionSize").getValue.toLong
+        sizeInBytes > (heapRegionSize / 2)
+      } catch {
+        case t: Throwable =>
+          logWarning("Try to get G1HeapRegionSize failed. ", t)
+          false

Review comment:
       Just merge both false lines into one at the end

##########
File path: core/src/main/scala/org/apache/spark/util/Utils.scala
##########
@@ -3204,6 +3205,33 @@ private[spark] object Utils extends Logging {
     }
     files.toSeq
   }
+
+  private def isG1GarbageCollector: Boolean = {
+    val gcs = ManagementFactory.getGarbageCollectorMXBeans.asScala
+    gcs.exists(_.getName.equalsIgnoreCase("G1 Young Generation")) ||

Review comment:
       Nit: you could make this one exists() statement




-- 
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