style95 commented on a change in pull request #5110:
URL: https://github.com/apache/openwhisk/pull/5110#discussion_r628061145
##########
File path:
common/scala/src/main/scala/org/apache/openwhisk/common/AverageRingBuffer.scala
##########
@@ -0,0 +1,34 @@
+package org.apache.openwhisk.common
+
+object AverageRingBuffer {
+ def apply(maxSize: Int) = new AverageRingBuffer(maxSize)
+}
+
+/**
+ * This buffer provides the average of the given elements.
+ * The number of elements are limited and the first element is removed if the
maximum size is reached.
+ * Since it is based on the Vector, its operation takes effectively constant
time.
+ * For more details, please visit
https://docs.scala-lang.org/overviews/collections/performance-characteristics.html
+ *
+ * @param maxSize the maximum size of the buffer
+ */
+class AverageRingBuffer(private val maxSize: Int) {
Review comment:
This circular buffer is used to calculate the average execution time of
recent N activations for a given action.
##########
File path:
core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/queue/SchedulingDecisionMaker.scala
##########
@@ -0,0 +1,244 @@
+package org.apache.openwhisk.core.scheduler.queue
+
+import akka.actor.{Actor, ActorSystem, Props}
+import org.apache.openwhisk.common.Logging
+import org.apache.openwhisk.core.entity.FullyQualifiedEntityName
+
+import scala.concurrent.{ExecutionContext, Future}
+import scala.util.{Failure, Success}
+
+class SchedulingDecisionMaker(
Review comment:
This component decides whether to add more containers or not for the
given action.
It uses the average execution time of an action.
There are three cases to calculate the average execution.
1. Initial execution.
In this case, we just assume the execution time as tick time(100ms by
default).
2. Queue is newly created.
In this case, activations exist in the DB, but no data in the
AverageRingBuffer.
So we fetch the average execution time from DB.
3. An action is continuously executed.
Each container sends the last execution time along with `FetchRequest` when
it pulls a new activation from a queue.
And our scheduler keeps N execution times in the AverageRingBuffer.
So we can easily calculate the average execution time of recent N executions.
--
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:
[email protected]