pan3793 commented on code in PR #54572:
URL: https://github.com/apache/spark/pull/54572#discussion_r2872740632


##########
core/src/main/scala/org/apache/spark/util/SizeEstimator.scala:
##########
@@ -97,32 +96,56 @@ object SizeEstimator extends Logging {
   // Size of an object reference
   // Based on https://wikis.oracle.com/display/HotSpotInternals/CompressedOops
   private var isCompressedOops = false
+
+  // Whether Compact Object Headers (JEP 450/519) are enabled.
+  // With Compact Object Headers, the object header is 8 bytes on 64-bit JVMs
+  // (the class pointer is encoded inside the mark word), so objectSize = 8
+  // and pointerSize = 4 regardless of UseCompressedOops.
+  private var isCompactObjectHeaders = false
+
   private var pointerSize = 4
 
   // Minimum size of a java.lang.Object
   private var objectSize = 8
 
   initialize()
 
-  // Sets object size, pointer size based on architecture and CompressedOops 
settings
-  // from the JVM.
+  // Sets object size, pointer size based on architecture, CompressedOops
+  // and CompactObjectHeaders settings from the JVM.
   private def initialize(): Unit = {
     val arch = Utils.osArch
     is64bit = arch.contains("64") || arch.contains("s390x")
+    isCompactObjectHeaders = is64bit && getIsCompactObjectHeaders
     isCompressedOops = getIsCompressedOops
 
     objectSize = if (!is64bit) 8 else {
-      if (!isCompressedOops) {
+      if (isCompactObjectHeaders) {
+        8
+      } else if (!isCompressedOops) {
         16
       } else {
         12
       }
     }
-    pointerSize = if (is64bit && !isCompressedOops) 8 else 4
+    pointerSize = if (is64bit && !isCompressedOops && !isCompactObjectHeaders) 
8 else 4

Review Comment:
   NVM, you are right, I made a mistake here, Oops = Ordinary Object Pointers 
(pointers to Java objects in the heap), it's not class pointers



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