Skip to content

Commit

Permalink
perf(log): avoid too many checkpoint at the same time (#2129)
Browse files Browse the repository at this point in the history
Signed-off-by: Ning Yu <[email protected]>
  • Loading branch information
Chillax-0v0 authored Nov 7, 2024
1 parent c243eaf commit cab9e19
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@ class ElasticUnifiedLog(_logStartOffset: Long,
rst
}

def tryCheckpoint(): Unit = {
def tryCheckpoint(): Boolean = {
if (checkpointIntervalBytes > 0) {
checkpointIntervalBytes = 0
lastCheckpointTimestamp = time.milliseconds()
checkpoint()
true
} else {
false
}
}

Expand Down Expand Up @@ -306,7 +309,10 @@ object ElasticUnifiedLog extends Logging {
DirtyBytes.reset()
for (log <- Logs.values().asScala) {
try {
log.tryCheckpoint()
if (log.tryCheckpoint()) {
// sleep a while to avoid too many checkpoint at the same time, which may cause high append latency
Thread.sleep(10)
}
} catch {
case e: Throwable => error("Error while checkpoint", e)
}
Expand Down

0 comments on commit cab9e19

Please sign in to comment.