Merge pull request #181 from sched-ext/rustland-interactive-tuning

scx_rustland: interactive tuning
This commit is contained in:
Andrea Righi 2024-03-10 19:31:00 +01:00 committed by GitHub
commit b7c06b9ed9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,8 +79,8 @@ const SCHEDULER_NAME: &'static str = "RustLand";
///
#[derive(Debug, Parser)]
struct Opts {
/// Scheduling slice duration in microseconds.
#[clap(short = 's', long, default_value = "20000")]
/// Scheduling slice duration in microseconds (default is 5ms).
#[clap(short = 's', long, default_value = "5000")]
slice_us: u64,
/// Time slice boost: increasing this value enhances performance of interactive applications
@ -391,10 +391,13 @@ impl<'a> Scheduler<'a> {
// NOTE: we should make this threshold a tunable, but for now let's assume that a moving
// average of 10 voluntary context switch per second is enough to classify the task as
// interactive.
//
// NOTE: some tasks may have a very high weight, that can potentially disrupt our slice
// boost optimizations, therefore always limit the task priority to a max of 1000.
let weight = if task_info.avg_nvcsw >= 10 {
task.weight * self.slice_boost.max(1)
task.weight.min(1000) * self.slice_boost.max(1)
} else {
task.weight
task.weight.min(1000)
};
// Scale the time slice by the task's priority (weight).