Copilot commented on code in PR #3696:
URL: https://github.com/apache/celeborn/pull/3696#discussion_r3296413830
##########
worker/src/main/scala/org/apache/celeborn/service/deploy/worker/storage/Flusher.scala:
##########
@@ -73,29 +73,38 @@ abstract private[worker] class Flusher(
copyBytes = new Array[Byte](maxTaskSize.toInt)
}
while (!stopFlag.get()) {
- val task = workingQueues(index).take()
- val key = s"Flusher-$this-${Random.nextInt()}"
- workerSource.sample(getFlushTimeMetric(), key) {
- if (!task.notifier.hasException) {
- try {
- val flushBeginTime = System.nanoTime()
- lastBeginFlushTime.set(index, flushBeginTime)
- task.flush(copyBytes)
- if (flushTimeMetric != null) {
- val delta = System.nanoTime() - flushBeginTime
- flushTimeMetric.update(delta)
+ val task = workingQueues(index).poll(1000, TimeUnit.MILLISECONDS)
+ if (task != null) {
+ val key = s"Flusher-$this-${Random.nextInt()}"
+ workerSource.sample(getFlushTimeMetric(), key) {
+ if (!task.notifier.hasException) {
+ try {
+ val flushBeginTime = System.nanoTime()
+ lastBeginFlushTime.set(index, flushBeginTime)
+ task.flush(copyBytes)
+ if (flushTimeMetric != null) {
+ val delta = System.nanoTime() - flushBeginTime
+ flushTimeMetric.update(delta)
+ }
+ } catch {
+ case t: Throwable =>
+ val e = ExceptionUtils.wrapThrowableToIOException(t)
+ task.notifier.setException(e)
+ processIOException(e, DiskStatus.READ_OR_WRITE_FAILURE)
+ logWarning(s"Flusher-$this-thread-$index encounter
exception.", t)
}
- } catch {
- case t: Throwable =>
- val e = ExceptionUtils.wrapThrowableToIOException(t)
- task.notifier.setException(e)
- processIOException(e, DiskStatus.READ_OR_WRITE_FAILURE)
- logWarning(s"Flusher-$this-thread-$index encounter
exception.", t)
+ lastBeginFlushTime.set(index, -1)
}
- lastBeginFlushTime.set(index, -1)
+ Utils.tryLogNonFatalError(returnBuffer(task.buffer,
task.keepBuffer))
+ task.notifier.numPendingFlushes.decrementAndGet()
+ }
Review Comment:
`workerSource.sample(getFlushTimeMetric(), key)` is a timer for the flush
metric (e.g. `WorkerSource.FLUSH_LOCAL_DATA_TIME`). Moving `returnBuffer(...)`
and `numPendingFlushes.decrementAndGet()` inside the sampled block changes the
semantics of the timer (it now includes buffer recycling / bookkeeping time)
and makes it inconsistent with `flushBeginTime`/`flushTimeMetric.update(...)`
which measure only `task.flush`. Consider keeping the sampled block scoped to
the actual flush work (as before) and run buffer return/decrement outside it,
or use a separate metric if you want to include cleanup time.
--
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]