@@ -134,9 +134,18 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
134134 // remove from resent tracking - it may get resent again, or get processed
135135 resent = None
136136 }
137+ val kind = r.action.exec.kind
138+ val memory = r.action.limits.memory.megabytes.MB
139+
140+ val prewarmedPoolForOtherKind = prewarmedPool.filter { info =>
141+ info match {
142+ case (_, PreWarmedData (_, `kind`, `memory`, _, _)) => false
143+ case _ => true
144+ }
145+ }
137146 val createdContainer =
138147 // Is there enough space on the invoker for this action to be executed.
139- if (hasPoolSpaceFor(busyPool, r.action.limits. memory.megabytes. MB )) {
148+ if (hasPoolSpaceFor(busyPool ++ prewarmedPoolForOtherKind, memory)) {
140149 // Schedule a job to a warm container
141150 ContainerPool
142151 .schedule(r.action, r.msg.user.namespace.name, freePool)
@@ -145,12 +154,12 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
145154 // There was no warm/warming/warmingCold container. Try to take a prewarm container or a cold container.
146155
147156 // Is there enough space to create a new container or do other containers have to be removed?
148- if (hasPoolSpaceFor(busyPool ++ freePool, r.action.limits. memory.megabytes. MB )) {
157+ if (hasPoolSpaceFor(busyPool ++ freePool ++ prewarmedPoolForOtherKind, memory)) {
149158 takePrewarmContainer(r.action)
150159 .map(container => (container, " prewarmed" ))
151160 .orElse {
152- val container = Some (createContainer(r.action.limits. memory.megabytes. MB ), " cold" )
153- incrementColdStartCount(r.action.exec. kind, r.action.limits. memory.megabytes. MB )
161+ val container = Some (createContainer(memory), " cold" )
162+ incrementColdStartCount(kind, memory)
154163 container
155164 }
156165 } else None )
@@ -167,8 +176,8 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
167176 takePrewarmContainer(r.action)
168177 .map(container => (container, " recreatedPrewarm" ))
169178 .getOrElse {
170- val container = (createContainer(r.action.limits. memory.megabytes. MB ), " recreated" )
171- incrementColdStartCount(r.action.exec. kind, r.action.limits. memory.megabytes. MB )
179+ val container = (createContainer(memory), " recreated" )
180+ incrementColdStartCount(kind, memory)
172181 container
173182 }))
174183
0 commit comments