@@ -29,30 +29,32 @@ use state_store::{
2929} ;
3030use tracing:: { debug, error, info, info_span, warn} ;
3131
32- // Maximum number of allocations per executor.
33- //
34- // In the future, this should be a dynamic value based on:
35- // - function concurrency configuration
36- // - function batching configuration
37- // - function timeout configuration
38- const MAX_ALLOCATIONS_PER_FN_EXECUTOR : usize = 20 ;
39-
4032struct TaskAllocationProcessor < ' a > {
4133 in_memory_state : & ' a mut InMemoryState ,
4234 clock : u64 ,
35+
36+ // Maximum number of allocations per executor.
37+ //
38+ // In the future, this should be a dynamic value based on:
39+ // - function concurrency configuration
40+ // - function batching configuration
41+ // - function timeout configuration
42+ queue_size : u32 ,
4343}
4444
4545#[ tracing:: instrument( skip( in_memory_state, clock, change) ) ]
4646pub fn invoke (
4747 in_memory_state : Arc < RwLock < InMemoryState > > ,
4848 clock : u64 ,
4949 change : & ChangeType ,
50+ queue_size : u32 ,
5051) -> Result < SchedulerUpdateRequest > {
5152 let mut in_memory_state = in_memory_state. write ( ) . unwrap ( ) ;
5253
5354 let mut task_allocator = TaskAllocationProcessor {
5455 in_memory_state : & mut in_memory_state. deref_mut ( ) ,
5556 clock,
57+ queue_size,
5658 } ;
5759
5860 task_allocator. invoke ( change)
@@ -64,12 +66,14 @@ pub fn invoke(
6466pub fn allocate (
6567 in_memory_state : Arc < RwLock < InMemoryState > > ,
6668 clock : u64 ,
69+ queue_size : u32 ,
6770) -> Result < SchedulerUpdateRequest > {
6871 let mut in_memory_state = in_memory_state. write ( ) . unwrap ( ) ;
6972
7073 let mut task_allocator = TaskAllocationProcessor {
7174 in_memory_state : & mut in_memory_state. deref_mut ( ) ,
7275 clock,
76+ queue_size,
7377 } ;
7478
7579 task_allocator. allocate ( )
@@ -255,7 +259,7 @@ impl<'a> TaskAllocationProcessor<'a> {
255259 let mut update = SchedulerUpdateRequest :: default ( ) ;
256260 let mut function_executors = self
257261 . in_memory_state
258- . candidate_function_executors ( task, MAX_ALLOCATIONS_PER_FN_EXECUTOR ) ?;
262+ . candidate_function_executors ( task, self . queue_size ) ?;
259263 if function_executors. function_executors . is_empty ( ) &&
260264 function_executors. num_pending_function_executors == 0
261265 {
@@ -269,7 +273,7 @@ impl<'a> TaskAllocationProcessor<'a> {
269273 ) ?;
270274 function_executors = self
271275 . in_memory_state
272- . candidate_function_executors ( task, MAX_ALLOCATIONS_PER_FN_EXECUTOR ) ?;
276+ . candidate_function_executors ( task, self . queue_size ) ?;
273277 }
274278 info ! (
275279 num_function_executors = function_executors. function_executors. len( ) ,
0 commit comments