yew1eb opened a new pull request, #3769:
URL: https://github.com/apache/celeborn/pull/3769

    
   
   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     - Make sure the PR title start w/ a JIRA ticket, e.g. '[CELEBORN-XXXX] 
Your PR title ...'.
     - Be sure to keep the PR description updated to reflect all changes.
     - Please write your PR title to summarize what this PR proposes.
     - If possible, provide a concise example to reproduce the issue for a 
faster review.
   -->
   
   ### What changes were proposed in this pull request?
   Replace `s.getBytes(StandardCharsets.UTF_8)` in 
`Encoders.Strings#encodeLength` and `#encode` with Netty's 
`ByteBufUtil.utf8Bytes` / `ByteBufUtil.writeUtf8`, eliminating the intermediate 
`byte[]` allocated for every encoded string.
   
   Also includes:
   - `EncodersSuiteJ`: round-trip tests (ASCII / Chinese / emoji) plus a 
byte-for-byte wire-compatibility test against the previous `getBytes(UTF_8)` 
encoding
   - `EncodersJmhBenchmark`: the JMH benchmark used for the measurements below, 
following the existing `SlotsAllocatorJmhBenchmark` pattern (test-scope  
`jmh-core` / `jmh-generator-annprocess` in `common/pom.xml`)
   
   
   ### Why are the changes needed?
   `Encoders.Strings` is on the hot path of every transport message 
(`PushData`, `PushMergeData`, `PushDataHandShake`, `RegionStart`, 
`RegionFinish`, ...) Each `getBytes(UTF_8)` call allocates a throwaway 
`byte[]`, which adds up to significant GC pressure under load.
   
   Measured with `EncodersJmhBenchmark` (`-prof gc`):   
   
   
   | Metric | Before | After | Delta |
   | ------ | ------ | ----- | ----- |
   | gc.alloc.rate.norm | 330328 B/op | 98920 B/op | -70% |
   | gc.time | 25 ms | 6 ms | -76% |
   
   
   ### Does this PR resolve a correctness bug?
   No.
   
   ### Does this PR introduce _any_ user-facing change?
   No.
   
   
   ### How was this patch tested?
   
   - New unit tests `EncoderSuiteJ` (round-trip + wire compatibility)
   - `EncodersJmhBenchmark` reproduced with:
   ```
          build/mvn -pl common -am test-compile
          build/mvn -pl common exec:java \
            
-Dexec.mainClass=org.apache.celeborn.common.network.protocol.EncodersJmhBenchmark
 \
            -Dexec.classpathScope=test \
            -Dexec.args="-f 0 -wi 1 -i 1"
   ```
   


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