You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/08/23 03:40:33 UTC

[GitHub] [ozone] jojochuang opened a new pull request, #3709: HDDS-7161. Make Checksum.int2ByteString() zero-copy

jojochuang opened a new pull request, #3709:
URL: https://github.com/apache/ozone/pull/3709

   ## What changes were proposed in this pull request?
   Remove expensive heap memory copy; replace with zero copy wrapper.
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-7161
   
   ## How was this patch tested?
   
   Covered by existing UT.


-- 
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@ozone.apache.org

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


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


[GitHub] [ozone] jojochuang commented on a diff in pull request #3709: HDDS-7161. Make Checksum.int2ByteString() zero-copy

Posted by GitBox <gi...@apache.org>.
jojochuang commented on code in PR #3709:
URL: https://github.com/apache/ozone/pull/3709#discussion_r954103300


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/Checksum.java:
##########
@@ -60,7 +61,7 @@ private static Function<ByteBuffer, ByteString> newMessageDigestFunction(
   }
 
   public static ByteString int2ByteString(int n) {
-    return ByteString.copyFrom(Ints.toByteArray(n));
+    return UnsafeByteOperations.unsafeWrap(Ints.toByteArray(n));

Review Comment:
   Yeah..i thought about that but
   (1) it seems quite involved to pass the configuration object over to make the decision
   (2) while it's called "unsafe byte operations", because the  byte array passed in is guaranteed immutable (Ints.toByteArray(n) returns a new temporary byte array), it is safe.



-- 
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@ozone.apache.org

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


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


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3709: HDDS-7161. Make Checksum.int2ByteString() zero-copy

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3709:
URL: https://github.com/apache/ozone/pull/3709#discussion_r952224288


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/Checksum.java:
##########
@@ -60,7 +61,7 @@ private static Function<ByteBuffer, ByteString> newMessageDigestFunction(
   }
 
   public static ByteString int2ByteString(int n) {
-    return ByteString.copyFrom(Ints.toByteArray(n));
+    return UnsafeByteOperations.unsafeWrap(Ints.toByteArray(n));

Review Comment:
   Should this be conditional on the following config property?
   
   https://github.com/apache/ozone/blob/df9ed54ba1235044fee73a7709b376b9dd44b213/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConfigKeys.java#L102-L105
   
   Similar to current logic for `ByteBuffer`s:
   
   https://github.com/apache/ozone/blob/df9ed54ba1235044fee73a7709b376b9dd44b213/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ByteStringConversion.java#L45-L53



-- 
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@ozone.apache.org

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


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


[GitHub] [ozone] adoroszlai merged pull request #3709: HDDS-7161. Make Checksum.int2ByteString() zero-copy

Posted by GitBox <gi...@apache.org>.
adoroszlai merged PR #3709:
URL: https://github.com/apache/ozone/pull/3709


-- 
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@ozone.apache.org

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


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


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3709: HDDS-7161. Make Checksum.int2ByteString() zero-copy

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3709:
URL: https://github.com/apache/ozone/pull/3709#discussion_r954127974


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/Checksum.java:
##########
@@ -60,7 +61,7 @@ private static Function<ByteBuffer, ByteString> newMessageDigestFunction(
   }
 
   public static ByteString int2ByteString(int n) {
-    return ByteString.copyFrom(Ints.toByteArray(n));
+    return UnsafeByteOperations.unsafeWrap(Ints.toByteArray(n));

Review Comment:
   Makes sense, thanks.



-- 
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@ozone.apache.org

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


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


[GitHub] [ozone] adoroszlai commented on pull request #3709: HDDS-7161. Make Checksum.int2ByteString() zero-copy

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on PR #3709:
URL: https://github.com/apache/ozone/pull/3709#issuecomment-1226273711

   Thanks @jojochuang for the patch, @kerneltime for review.


-- 
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@ozone.apache.org

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


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