Ridzzz0Alam opened a new pull request, #24174:
URL: https://github.com/apache/kafka/pull/24174

   Follow-up to #23985 as suggested by @bbejeck.
    
   ### The issue
   `TaskExecutionMetadata#canProcessTask` (every task and every loop) and 
`PartitionGroup#nextRecord` (every record) pay for log messages that are almost 
never written.
    
   ### Why it happened
   `canProcessTask` formats its message with `String.format` on every call even 
though it is only logged at trace level or once every 120 s. The multi-argument 
trace calls in `nextRecord` build a varargs array and box their values even 
with trace off.
    
   ### The fix
   - `canProcessTask` keeps the message as a `Supplier<String>` and calls it 
only when it logs.
   - The multi-argument trace calls in `nextRecord` are guarded by 
`isTraceEnabled()`.
   ### Tests
   - `TaskExecutionMetadataTest#shouldNotFormatLogMessageUntilItIsLogged` and 
`PartitionGroupTest#shouldNotBuildTraceLogArgumentsInNextRecordWhenTraceIsDisabled`:
 both fail without the fix and pass with it.
   - The full `streams:test` run passes.
   


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