wang-jiahua opened a new pull request, #10535:
URL: https://github.com/apache/rocketmq/pull/10535

   <!-- Please make sure the target branch is right. In most case, the target 
branch should be `develop`. -->
   
   ### Which Issue(s) This PR Fixes
   
   <!-- Please ensure that the related issue has already been created, and 
[link this pull request to that issue using 
keywords](<https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword>)
 to ensure automatic closure. -->
   
   Fixes #10533
   
   ### Brief Description
   
   Implement `FastCodesHeader.encode()/decode()` for `SendMessageRequestHeader` 
and `SendMessageResponseHeader` to eliminate reflection-based header 
serialization on the send message hot path.
   
   1. **`SendMessageRequestHeader`** — Implement `encode()` using 
`writeIfNotNull` for 14 fields, and `decode()` using `getAndCheckNotNull`. This 
replaces the reflection-based `makeCustomHeaderToNet()` path which uses 
`Field.get()` + `toString()` for every field on every send.
   2. **`SendMessageResponseHeader`** — Implement `encode()` and `decode()` for 
5 response fields.
   3. **`SendMessageRequestHeaderV2`** — Fix `decode()` signature from 
`Map<String, String>` to `HashMap<String, String>` to match the 
`FastCodesHeader` interface.
   
   ### How Did You Test This Change?
   
   1. **Unit tests**: All 16 `SendMessageProcessorTest` tests pass.
   2. **Compilation**: `remoting` + `broker` modules compile cleanly on JDK 21.
   3. **Commercial compatibility**: `YitianSendMessageRequestHeader extends 
SendMessageRequestHeader` (subclass, unaffected). 
`YitianSendMessageResponseHeader implements FastCodesHeader` with its own 
`encode()/decode()` (independent implementation, unaffected).
   4. **Microbenchmark** (R1 encode/decode bench): `writeIfNotNull` + 
`writeDecimalInt` is 25% faster than `value.toString()` + `writeStr` for 
encoding; `readStr` with single-byte cache is 56% faster for decoding.
   


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