You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/06/09 07:19:44 UTC

[GitHub] [lucene] zhaih commented on a diff in pull request #949: LUCENE-10605: fix error in 32bit jvm object alignment gap calculation

zhaih commented on code in PR #949:
URL: https://github.com/apache/lucene/pull/949#discussion_r893146609


##########
lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java:
##########
@@ -191,15 +191,17 @@ public static int oversize(int minTargetSize, int bytesPerElement) {
           return newSize;
       }
     } else {
-      // round up to 4 byte alignment in 64bit env
+      // round up to 4 byte alignment in 32bit env

Review Comment:
   this should still be 8 byte alignment, but with 4 bytes offset given by array header, probably it's better to mention in 32 bit machine the array header is 12 bytes so the calculation below become reasonable.



##########
lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java:
##########
@@ -191,15 +191,17 @@ public static int oversize(int minTargetSize, int bytesPerElement) {
           return newSize;
       }
     } else {
-      // round up to 4 byte alignment in 64bit env
+      // round up to 4 byte alignment in 32bit env
       switch (bytesPerElement) {
-        case 2:
-          // round up to multiple of 2
-          return (newSize + 1) & 0x7ffffffe;
         case 1:
-          // round up to multiple of 4
-          return (newSize + 3) & 0x7ffffffc;
+          // round up to multiple of 8 plus 4

Review Comment:
   This is not round "up" strictly speaking since you only round up 5-7 but not 1-4, I'm not sure what's the right words but maybe just say "align with size of 4,12,20..."?



-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org