-
Notifications
You must be signed in to change notification settings - Fork 15.4k
MINOR: reduce impact of trace logging in replica hot path #8468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,7 +83,6 @@ class Replica(val brokerId: Int, val topicPartition: TopicPartition) extends Log | |
| lastFetchLeaderLogEndOffset = leaderEndOffset | ||
| lastFetchTimeMs = followerFetchTimeMs | ||
| updateLastSentHighWatermark(lastSentHighwatermark) | ||
| trace(s"Updated state of replica to $this") | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -96,7 +95,6 @@ class Replica(val brokerId: Int, val topicPartition: TopicPartition) extends Log | |
| */ | ||
| private def updateLastSentHighWatermark(highWatermark: Long): Unit = { | ||
| _lastSentHighWatermark = highWatermark | ||
| trace(s"Updated HW of replica to $highWatermark") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this trace call is worthwhile given the cost. It would be hard to turn it on without being deluged with logs..
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @junrao Thoughts? Can we remove these calls?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At minimum I think we could keep the trace I deleted here: #8468 (comment) which should end up logging the lastSentWatermark anyway?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree this may not be that useful. We have other logging like the following in Partition.updateFollowerFetchState() that provides similar traceability. |
||
| } | ||
|
|
||
| def resetLastCaughtUpTime(curLeaderLogEndOffset: Long, curTimeMs: Long, lastCaughtUpTimeMs: Long): Unit = { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,6 +149,7 @@ class ReplicaFetcherThread(name: String, | |
| override def processPartitionData(topicPartition: TopicPartition, | ||
| fetchOffset: Long, | ||
| partitionData: FetchData): Option[LogAppendInfo] = { | ||
| val logTrace = isTraceEnabled | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Saves 3 getEffectiveLevel checks. |
||
| val partition = replicaMgr.nonOfflinePartition(topicPartition).get | ||
| val log = partition.localLogOrException | ||
| val records = toMemoryRecords(partitionData.records) | ||
|
|
@@ -159,14 +160,14 @@ class ReplicaFetcherThread(name: String, | |
| throw new IllegalStateException("Offset mismatch for partition %s: fetched offset = %d, log end offset = %d.".format( | ||
| topicPartition, fetchOffset, log.logEndOffset)) | ||
|
|
||
| if (isTraceEnabled) | ||
| if (logTrace) | ||
| trace("Follower has replica log end offset %d for partition %s. Received %d messages and leader hw %d" | ||
| .format(log.logEndOffset, topicPartition, records.sizeInBytes, partitionData.highWatermark)) | ||
|
|
||
| // Append the leader's messages to the log | ||
| val logAppendInfo = partition.appendRecordsToFollowerOrFutureReplica(records, isFuture = false) | ||
|
|
||
| if (isTraceEnabled) | ||
| if (logTrace) | ||
| trace("Follower has replica log end offset %d after appending %d bytes of messages for partition %s" | ||
| .format(log.logEndOffset, records.sizeInBytes, topicPartition)) | ||
| val leaderLogStartOffset = partitionData.logStartOffset | ||
|
|
@@ -175,7 +176,7 @@ class ReplicaFetcherThread(name: String, | |
| // These values will be computed upon becoming leader or handling a preferred read replica fetch. | ||
| val followerHighWatermark = log.updateHighWatermark(partitionData.highWatermark) | ||
| log.maybeIncrementLogStartOffset(leaderLogStartOffset) | ||
| if (isTraceEnabled) | ||
| if (logTrace) | ||
| trace(s"Follower set replica high watermark for partition $topicPartition to $followerHighWatermark") | ||
|
|
||
| // Traffic from both in-sync and out of sync replicas are accounted for in replication quota to ensure total replication | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this trace call is worthwhile given the cost. It would be hard to turn it on without being deluged with logs.