dao-jun opened a new pull request, #25555:
URL: https://github.com/apache/pulsar/pull/25555

   ### Motivation
   
     ServerCnx.handleSend sits on the hot publish path, but the same 
MessageMetadata can be parsed multiple times for a single message. In the 
persistent-topic flow, producer-side encryption validation, delayed-delivery 
checks, and deduplication/chunk handling may all reparse the same payload. That 
adds avoidable CPU overhead
     to a latency-sensitive path.
   
     This change reduces that overhead by parsing metadata once per publish 
attempt and reusing it across the broker publish flow. It also keeps the 
behavior safe by invalidating the cached metadata after broker interceptors 
run, so any interceptor-side buffer mutation does not reuse stale data.
   
   ### Modifications
   
     - Make send debug logging in ServerCnx lazy, so metadata is not parsed 
when debug logging is disabled.
     - Create MessagePublishContext before producer-side publish validation 
starts.
     - Cache MessageMetadata in MessagePublishContext and reuse it within the 
same publish attempt.
     - Reuse cached metadata in:
         - producer encryption-required validation
         - persistent topic maximum delivery delay validation
         - deduplication paths that previously reparsed message metadata
     - Invalidate the cached metadata after 
BrokerInterceptor.onMessagePublish(...) to preserve correctness if an 
interceptor mutates the payload.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe 
tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads 
(10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Does this pull request potentially affect one of the following parts:
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *If the box was checked, please highlight the changes*
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment


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