mirror of https://github.com/apache/kafka.git
				
				
				
			MINOR: Don't generate unnecessary strings for debug logging in FetchSessionHandler (#7394)
Profiling while benchmarking shows unnecessary calls to `responseDataToLogString` in FetchSessionHandler when logging was set to INFO level. This leads to 1.47% of the JVM CPU time going to this method. Fix it by checking if debug logging is enabled. Reviewers: Ismael Juma <ismael@juma.me.uk>
This commit is contained in:
		
							parent
							
								
									8818a7037d
								
							
						
					
					
						commit
						1dc5063cde
					
				|  | @ -397,14 +397,15 @@ public class FetchSessionHandler { | |||
|                 nextMetadata = FetchMetadata.INITIAL; | ||||
|                 return false; | ||||
|             } else if (response.sessionId() == INVALID_SESSION_ID) { | ||||
|                 log.debug("Node {} sent a full fetch response{}", | ||||
|                     node, responseDataToLogString(response)); | ||||
|                 if (log.isDebugEnabled()) | ||||
|                     log.debug("Node {} sent a full fetch response{}", node, responseDataToLogString(response)); | ||||
|                 nextMetadata = FetchMetadata.INITIAL; | ||||
|                 return true; | ||||
|             } else { | ||||
|                 // The server created a new incremental fetch session. | ||||
|                 log.debug("Node {} sent a full fetch response that created a new incremental " + | ||||
|                     "fetch session {}{}", node, response.sessionId(), responseDataToLogString(response)); | ||||
|                 if (log.isDebugEnabled()) | ||||
|                     log.debug("Node {} sent a full fetch response that created a new incremental " + | ||||
|                             "fetch session {}{}", node, response.sessionId(), responseDataToLogString(response)); | ||||
|                 nextMetadata = FetchMetadata.newIncremental(response.sessionId()); | ||||
|                 return true; | ||||
|             } | ||||
|  | @ -416,14 +417,16 @@ public class FetchSessionHandler { | |||
|                 return false; | ||||
|             } else if (response.sessionId() == INVALID_SESSION_ID) { | ||||
|                 // The incremental fetch session was closed by the server. | ||||
|                 log.debug("Node {} sent an incremental fetch response closing session {}{}", | ||||
|                     node, nextMetadata.sessionId(), responseDataToLogString(response)); | ||||
|                 if (log.isDebugEnabled()) | ||||
|                     log.debug("Node {} sent an incremental fetch response closing session {}{}", | ||||
|                             node, nextMetadata.sessionId(), responseDataToLogString(response)); | ||||
|                 nextMetadata = FetchMetadata.INITIAL; | ||||
|                 return true; | ||||
|             } else { | ||||
|                 // The incremental fetch session was continued by the server. | ||||
|                 log.debug("Node {} sent an incremental fetch response for session {}{}", | ||||
|                     node, response.sessionId(), responseDataToLogString(response)); | ||||
|                 if (log.isDebugEnabled()) | ||||
|                     log.debug("Node {} sent an incremental fetch response for session {}{}", | ||||
|                             node, response.sessionId(), responseDataToLogString(response)); | ||||
|                 nextMetadata = nextMetadata.nextIncremental(); | ||||
|                 return true; | ||||
|             } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue