style95 commented on code in PR #5443:
URL: https://github.com/apache/openwhisk/pull/5443#discussion_r1337888402


##########
common/scala/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerFactory.scala:
##########
@@ -73,6 +75,16 @@ case class ContainerPoolConfig(userMemory: ByteSize,
   // Grant more CPU to a container if it allocates more memory.
   def cpuShare(reservedMemory: ByteSize) =
     max((totalShare / (userMemory.toBytes / reservedMemory.toBytes)).toInt, 2) 
// The minimum allowed cpu-shares is 2
+
+  private val minContainerCpus = 0.01 // The minimum cpus allowed by docker is 
0.01
+  private val roundingMultiplier = 100000
+  def cpuLimit(reservedMemory: ByteSize): Option[Double] = {
+    userCpus.map(c => {
+      val containerCpus = c / (userMemory.toBytes / reservedMemory.toBytes)
+      val roundedContainerCpus = round(containerCpus * 
roundingMultiplier).toDouble / roundingMultiplier // Only use decimal precision 
of 5

Review Comment:
   👍 



##########
common/scala/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerFactory.scala:
##########
@@ -73,6 +75,16 @@ case class ContainerPoolConfig(userMemory: ByteSize,
   // Grant more CPU to a container if it allocates more memory.
   def cpuShare(reservedMemory: ByteSize) =
     max((totalShare / (userMemory.toBytes / reservedMemory.toBytes)).toInt, 2) 
// The minimum allowed cpu-shares is 2
+
+  private val minContainerCpus = 0.01 // The minimum cpus allowed by docker is 
0.01
+  private val roundingMultiplier = 100000
+  def cpuLimit(reservedMemory: ByteSize): Option[Double] = {
+    userCpus.map(c => {
+      val containerCpus = c / (userMemory.toBytes / reservedMemory.toBytes)
+      val roundedContainerCpus = round(containerCpus * 
roundingMultiplier).toDouble / roundingMultiplier // Only use decimal precision 
of 5

Review Comment:
   👍 



-- 
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: issues-unsubscr...@openwhisk.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to