LuciferYang commented on code in PR #46783:
URL: https://github.com/apache/spark/pull/46783#discussion_r1618278790
##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -3057,16 +3057,8 @@ private[spark] object Utils
*/
lazy val isG1GC: Boolean = {
Try {
- val clazz =
Utils.classForName("com.sun.management.HotSpotDiagnosticMXBean")
- .asInstanceOf[Class[_ <: PlatformManagedObject]]
- val vmOptionClazz = Utils.classForName("com.sun.management.VMOption")
- val hotSpotDiagnosticMXBean = ManagementFactory.getPlatformMXBean(clazz)
- val vmOptionMethod = clazz.getMethod("getVMOption", classOf[String])
- val valueMethod = vmOptionClazz.getMethod("getValue")
-
- val useG1GCObject = vmOptionMethod.invoke(hotSpotDiagnosticMXBean,
"UseG1GC")
- val useG1GC = valueMethod.invoke(useG1GCObject).asInstanceOf[String]
- "true".equals(useG1GC)
+ ManagementFactory.getGarbageCollectorMXBeans.asScala
+ .exists(_.getName.contains("G1"))
Review Comment:
friendly ping @dongjoon-hyun, @HyukjinKwon @srowen and @rednaxelafx
Do you think this simplification is ok? When using G1 GC,
`ManagementFactory.getGarbageCollectorMXBeans` will return two instances of
`GarbageCollectorExtImpl`, their names are `G1 Young Generation` and `G1 Old
Generation`. Thanks ~
~If this is acceptable, I will go ahead and create a Jira.~
--
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]