@@ -125,9 +125,18 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
125125 // remove from resent tracking - it may get resent again, or get processed
126126 resent = None
127127 }
128+ val kind = r.action.exec.kind
129+ val memory = r.action.limits.memory.megabytes.MB
130+
131+ val prewarmedPoolForOtherKind = prewarmedPool.filter { info =>
132+ info match {
133+ case (_, PreWarmedData (_, `kind`, `memory`, _, _)) => false
134+ case _ => true
135+ }
136+ }
128137 val createdContainer =
129138 // Is there enough space on the invoker for this action to be executed.
130- if (hasPoolSpaceFor(busyPool, r.action.limits. memory.megabytes. MB )) {
139+ if (hasPoolSpaceFor(busyPool ++ prewarmedPoolForOtherKind, memory)) {
131140 // Schedule a job to a warm container
132141 ContainerPool
133142 .schedule(r.action, r.msg.user.namespace.name, freePool)
@@ -136,12 +145,12 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
136145 // There was no warm/warming/warmingCold container. Try to take a prewarm container or a cold container.
137146
138147 // Is there enough space to create a new container or do other containers have to be removed?
139- if (hasPoolSpaceFor(busyPool ++ freePool, r.action.limits. memory.megabytes. MB )) {
148+ if (hasPoolSpaceFor(busyPool ++ freePool ++ prewarmedPoolForOtherKind, memory)) {
140149 takePrewarmContainer(r.action)
141150 .map(container => (container, " prewarmed" ))
142151 .orElse {
143- val container = Some (createContainer(r.action.limits. memory.megabytes. MB ), " cold" )
144- incrementColdStartCount(r.action.exec. kind, r.action.limits. memory.megabytes. MB )
152+ val container = Some (createContainer(memory), " cold" )
153+ incrementColdStartCount(kind, memory)
145154 container
146155 }
147156 } else None )
@@ -158,8 +167,8 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
158167 takePrewarmContainer(r.action)
159168 .map(container => (container, " recreatedPrewarm" ))
160169 .getOrElse {
161- val container = (createContainer(r.action.limits. memory.megabytes. MB ), " recreated" )
162- incrementColdStartCount(r.action.exec. kind, r.action.limits. memory.megabytes. MB )
170+ val container = (createContainer(memory), " recreated" )
171+ incrementColdStartCount(kind, memory)
163172 container
164173 }))
165174
0 commit comments