s0nskar commented on code in PR #3696:
URL: https://github.com/apache/celeborn/pull/3696#discussion_r3407625386
##########
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()
+ } else {
+ allocator match {
+ case alloc: PooledByteBufAllocator =>
+ // Free buffer pool memory to main direct memory when flush
thread is idle.
+ alloc.trimCurrentThreadCache
+ case _ =>
+ }
Review Comment:
Added.
--
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]