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

   ### The issue
   `PartitionGroup#readyToProcess` formats a not-ready message on every call 
and `StreamTask` runs it per record. `StreamTask` logs that message at most 
once every 120s and discards the rest. Tasks that read a busy topic together 
with a quiet one pay this cost on almost every record.
   
   ### Why it happened
   KAFKA-19682 (#20693) replaced parameterized `logger.trace` calls with eager 
`String.format` calls collected in a `StringBuilder`. 
`StreamTask#isProcessable` also resolved the message before `maybeLogNotReady` 
checked the log interval.
   
   ### The fix
   - `ReadyToProcessResult` holds a `Supplier<String>`. `maybeLogNotReady` 
calls it only when it logs.
   - The suppliers capture only immutable locals, so they are safe with 
`SynchronizedPartitionGroup`.
   - The message for the partition that blocks processing is unchanged. When no 
partition has data, the message now lists the partitions past their idle 
deadline. Before, it printed a "fetched lag" line for each of them.
   
   ### Tests
   - New `PartitionGroupTest#shouldNotFormatNotReadyLogMessageUntilRequested`. 
It fails on trunk and passes with the fix.
   - `PartitionGroupTest`, `StreamTaskTest` and 
`SynchronizedPartitionGroupTest` pass unchanged.
   - Microbenchmark with two partitions, one of them idle: 1435 → 85 ns and 
3288 → 264 B per call while waiting; 1904 → 214 ns and 1128 → 344 B once the 
idle deadline has passed.
   
   


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