This is an automated email from the ASF dual-hosted git repository.
style95 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new b0baa7b take prewarmed container's memory as used memory (#4911)
b0baa7b is described below
commit b0baa7b3c2aeff56fda0b826749e25df7067242a
Author: ningyougang <[email protected]>
AuthorDate: Mon Jan 18 13:41:15 2021 +0800
take prewarmed container's memory as used memory (#4911)
* take prewarmed container's memory as used memory
* Don't filter prewarmpool for other kinds
* Fix test case error
---
.../openwhisk/core/containerpool/ContainerPool.scala | 15 +++++++++------
.../core/containerpool/test/ContainerPoolTests.scala | 9 ++++-----
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git
a/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
b/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
index 4327ad1..92f058b 100644
---
a/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
+++
b/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
@@ -125,9 +125,12 @@ class ContainerPool(childFactory: ActorRefFactory =>
ActorRef,
//remove from resent tracking - it may get resent again, or get
processed
resent = None
}
+ val kind = r.action.exec.kind
+ val memory = r.action.limits.memory.megabytes.MB
+
val createdContainer =
// Is there enough space on the invoker for this action to be
executed.
- if (hasPoolSpaceFor(busyPool, r.action.limits.memory.megabytes.MB)) {
+ if (hasPoolSpaceFor(busyPool ++ prewarmedPool, memory)) {
// Schedule a job to a warm container
ContainerPool
.schedule(r.action, r.msg.user.namespace.name, freePool)
@@ -136,12 +139,12 @@ class ContainerPool(childFactory: ActorRefFactory =>
ActorRef,
// There was no warm/warming/warmingCold container. Try to
take a prewarm container or a cold container.
// Is there enough space to create a new container or do other
containers have to be removed?
- if (hasPoolSpaceFor(busyPool ++ freePool,
r.action.limits.memory.megabytes.MB)) {
+ if (hasPoolSpaceFor(busyPool ++ freePool ++ prewarmedPool,
memory)) {
takePrewarmContainer(r.action)
.map(container => (container, "prewarmed"))
.orElse {
- val container =
Some(createContainer(r.action.limits.memory.megabytes.MB), "cold")
- incrementColdStartCount(r.action.exec.kind,
r.action.limits.memory.megabytes.MB)
+ val container = Some(createContainer(memory), "cold")
+ incrementColdStartCount(kind, memory)
container
}
} else None)
@@ -158,8 +161,8 @@ class ContainerPool(childFactory: ActorRefFactory =>
ActorRef,
takePrewarmContainer(r.action)
.map(container => (container, "recreatedPrewarm"))
.getOrElse {
- val container =
(createContainer(r.action.limits.memory.megabytes.MB), "recreated")
- incrementColdStartCount(r.action.exec.kind,
r.action.limits.memory.megabytes.MB)
+ val container = (createContainer(memory), "recreated")
+ incrementColdStartCount(kind, memory)
container
}))
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerPoolTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerPoolTests.scala
index 63930fe..3fd0414 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerPoolTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerPoolTests.scala
@@ -329,9 +329,8 @@ class ContainerPoolTests
val feed = TestProbe()
val pool =
- system.actorOf(
- ContainerPool
- .props(factory, poolConfig(MemoryLimit.STD_MEMORY), feed.ref,
List(PrewarmingConfig(1, exec, memoryLimit))))
+ system.actorOf(ContainerPool
+ .props(factory, poolConfig(MemoryLimit.STD_MEMORY * 2), feed.ref,
List(PrewarmingConfig(1, exec, memoryLimit))))
containers(0).expectMsg(Start(exec, memoryLimit))
containers(0).send(pool, NeedWork(preWarmedData(exec.kind)))
pool ! runMessage
@@ -365,7 +364,7 @@ class ContainerPoolTests
ContainerPool
.props(
factory,
- poolConfig(MemoryLimit.STD_MEMORY),
+ poolConfig(MemoryLimit.STD_MEMORY * 2),
feed.ref,
List(PrewarmingConfig(1, alternativeExec, memoryLimit))))
containers(0).expectMsg(Start(alternativeExec, memoryLimit)) // container0
was prewarmed
@@ -385,7 +384,7 @@ class ContainerPoolTests
ContainerPool
.props(
factory,
- poolConfig(MemoryLimit.STD_MEMORY),
+ poolConfig(MemoryLimit.STD_MEMORY * 2),
feed.ref,
List(PrewarmingConfig(1, exec, alternativeLimit))))
containers(0).expectMsg(Start(exec, alternativeLimit)) // container0 was
prewarmed