From 5887a91d5153b7f6a929d9e68c225ec63528ea3a Mon Sep 17 00:00:00 2001 From: Ryo Onodera Date: Wed, 28 Feb 2024 23:50:01 +0900 Subject: [PATCH] Reduce and comment about Page::blocked_tasks cap. --- unified-scheduler-logic/src/lib.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/unified-scheduler-logic/src/lib.rs b/unified-scheduler-logic/src/lib.rs index bba213961b76a1..15386b8a09d508 100644 --- a/unified-scheduler-logic/src/lib.rs +++ b/unified-scheduler-logic/src/lib.rs @@ -416,7 +416,16 @@ impl Default for PageInner { fn default() -> Self { Self { usage: PageUsage::default(), - blocked_tasks: VecDeque::with_capacity(1024), + // Capacity should be configurable to create with large capacity like 1024 inside the + // (multi-threaded) closures passed to create_task(). In this way, reallocs can be + // avoided happening in the scheduler thread. Also, this configurability is desired for + // unified-scheduler-logic's motto: separation of concerns (the pure logic should be + // sufficiently distanced from any some random knob's constants needed for messy + // reality for author's personal preference...). + // + // Note that large cap should be accompanied with proper scheduler cleaning after use, + // which should be handled by higher layers (i.e. scheduler pool). + blocked_tasks: VecDeque::with_capacity(128), } } } @@ -726,6 +735,8 @@ impl SchedulingStateMachine { pub unsafe fn exclusively_initialize_current_thread_for_scheduling() -> Self { Self { last_task_index: None, + // It's very unlikely this is desired to be configurable, like + // `PageInner::blocked_tasks`'s cap. unblocked_task_queue: VecDeque::with_capacity(1024), active_task_count: ShortCounter::zero(), handled_task_count: ShortCounter::zero(),