Gautam-aman opened a new pull request, #10555:
URL: https://github.com/apache/rocketmq/pull/10555

   ## What is changed
   
   Replace `ByteString.copyFrom(messageExt.getBody())` with 
`UnsafeByteOperations.unsafeWrap(messageExt.getBody())` in 
`GrpcConverter.buildMessage()`.
   
   ## Why
   
   On the Proxy receive path, the message body has already been materialized as 
a dedicated `byte[]` during decoding.
   
   `ByteString.copyFrom()` performs an additional allocation and array copy 
before gRPC serialization. Using `UnsafeByteOperations.unsafeWrap()` allows the 
existing buffer to be wrapped directly, eliminating an unnecessary copy.
   
   ## Impact
   
   * Removes one heap allocation per received message.
   * Avoids an extra `System.arraycopy`.
   * Reduces GC pressure on high-throughput consumer workloads.
   
   ## Compatibility
   
   No behavioral changes. The resulting `ByteString` contents remain identical. 
Only the internal copy is removed.
   
   ## Verification
   
   * Verified the change is limited to `GrpcConverter.buildMessage()`.
   * Checkstyle passes successfully.
   * `UnsafeByteOperations` is available through the existing protobuf 
dependency.
   
   Closes #10488.
   


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

Reply via email to