You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by gi...@git.apache.org on 2017/06/19 06:13:07 UTC

[GitHub] markusthoemmes commented on a change in pull request #2360: Choose target invoker based on specific invoker load.

markusthoemmes commented on a change in pull request #2360: Choose target invoker based on specific invoker load.
URL: https://github.com/apache/incubator-openwhisk/pull/2360#discussion_r122626751
 
 

 ##########
 File path: core/controller/src/main/scala/whisk/core/loadBalancer/LoadBalancerService.scala
 ##########
 @@ -299,26 +329,32 @@ class LoadBalancerService(config: WhiskConfig, entityStore: EntityStore)(implici
      * Invoker is currently using and which is better avoid if/until
      * these are moved to some common place (like a subclass of Message?)
      */
-    private val activationCountMap = TrieMap[(String, String), AtomicInteger]()
-    private def hashAndCountSubjectAction(msg: ActivationMessage): (Int, Int) = {
+    private def hashSubjectAction(msg: ActivationMessage): Int = {
         val subject = msg.user.subject.asString
         val path = msg.action.toString
-        val hash = subject.hashCode() ^ path.hashCode()
-        val key = (subject, path)
-        val count = activationCountMap.get(key) match {
-            case Some(counter) => counter.getAndIncrement()
-            case None => {
-                activationCountMap.put(key, new AtomicInteger(0))
-                0
-            }
-        }
-        return (hash, count)
+        subject.hashCode() ^ path.hashCode()
+    }
+
+    /** Memoizes the result of `f` for later use. */
+    private def memoize[I, O](f: I => O): I => O = new scala.collection.mutable.HashMap[I, O]() {
 
 Review comment:
   Agree on the first, disagree on the latter: Don't think we need to be so cautious with this particular function. At steady state the results shouldn't change much. Folding it into the invokerHealth protocol won't guarantee no overlapping recomputation either. We could mitigate this by storing a Promise's future in the map and return that to each caller so we would fold all computations into one.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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