You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2019/11/13 08:35:08 UTC
[GitHub] [openwhisk] style95 commented on a change in pull request #4593:
Change ContainerPool buffer processing
style95 commented on a change in pull request #4593: Change ContainerPool buffer processing
URL: https://github.com/apache/openwhisk/pull/4593#discussion_r345625514
##########
File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerProxy.scala
##########
@@ -479,22 +497,37 @@ class ContainerProxy(factory: (TransactionId,
/** Either process runbuffer or signal parent to send work; return true if runbuffer is being processed */
def requestWork(newData: WarmedData): Boolean = {
- //if there is concurrency capacity, process runbuffer, or signal NeedWork
+ //if there is concurrency capacity, process runbuffer, signal NeedWork, or both
if (activeCount < newData.action.limits.concurrency.maxConcurrent) {
- runBuffer.dequeueOption match {
- case Some((run, q)) =>
- runBuffer = q
- self ! run
- true
- case _ =>
- context.parent ! NeedWork(newData)
- false
+ if (runBuffer.length > 0) {
+ processBuffer(newData.action, newData)
+ true
+ } else {
+ context.parent ! NeedWork(newData)
+ bufferProcessing //true in case buffer is still in process
}
} else {
false
}
}
+ /** Process buffered items up to the capacity of action concurrency config */
+ def processBuffer(action: ExecutableWhiskAction, newData: ContainerData) = {
+ //send as many buffered as possible
+ var available = action.limits.concurrency.maxConcurrent - activeCount
+ logging.info(this, s"resending up to ${available} from ${runBuffer.length} buffered jobs")
+ while (available > 0 && runBuffer.length > 0) {
Review comment:
Small nit.
How about replacing `var` and `while` with something similar to this?
```scala
val available = action.limits.concurrency.maxConcurrent - activeCount
logging.info(this, s"resending up to ${available} from ${runBuffer.length} buffered jobs")
1 to available foreach { _ =>
runBuffer.dequeueOption match {
case Some((run, q)) =>
self ! run
bufferProcessing = true
runBuffer = q
case _ =>
context.parent ! NeedWork(newData)
}
}
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services