This is an automated email from the ASF dual-hosted git repository. xushiyan pushed a commit to branch revert-5060-feature/threadlocal_ObjectSizeCalculator2 in repository https://gitbox.apache.org/repos/asf/hudi.git
commit a45e51938aa0eec643dbae4f27bfe33eaeaf4155 Author: Raymond Xu <[email protected]> AuthorDate: Thu Apr 14 12:27:42 2022 -0700 Revert "[HUDI-3652] Make ObjectSizeCalculator threadlocal to reduce memory footprint (#5060)" This reverts commit f0ab4a6e9ef433ac943d2409051418f7f80a6902. --- .../main/java/org/apache/hudi/common/util/ObjectSizeCalculator.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hudi-common/src/main/java/org/apache/hudi/common/util/ObjectSizeCalculator.java b/hudi-common/src/main/java/org/apache/hudi/common/util/ObjectSizeCalculator.java index 99b2d5a2cb..7e625e8eb4 100644 --- a/hudi-common/src/main/java/org/apache/hudi/common/util/ObjectSizeCalculator.java +++ b/hudi-common/src/main/java/org/apache/hudi/common/util/ObjectSizeCalculator.java @@ -54,8 +54,6 @@ import java.util.Set; * @author Attila Szegedi */ public class ObjectSizeCalculator { - private static final ThreadLocal<ObjectSizeCalculator> OBJECT_SIZE_CALCULATOR_THREAD_LOCAL = ThreadLocal.withInitial(() -> new ObjectSizeCalculator(CurrentLayout.SPEC)); - private static class CurrentLayout { private static final MemoryLayoutSpecification SPEC = getEffectiveMemoryLayoutSpecification(); @@ -73,7 +71,7 @@ public class ObjectSizeCalculator { * @throws UnsupportedOperationException if the current vm memory layout cannot be detected. */ public static long getObjectSize(Object obj) throws UnsupportedOperationException { - return obj == null ? 0 : OBJECT_SIZE_CALCULATOR_THREAD_LOCAL.get().calculateObjectSize(obj); + return obj == null ? 0 : new ObjectSizeCalculator(CurrentLayout.SPEC).calculateObjectSize(obj); } // Fixed object header size for arrays.
