Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scx_layered: Add per layer time slices to stats #732

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions scheds/rust/scx_layered/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,8 @@ struct Stats {

processing_dur: Duration,
prev_processing_dur: Duration,

layer_slice_us: Vec<u64>,
}

impl Stats {
Expand Down Expand Up @@ -846,6 +848,8 @@ impl Stats {

processing_dur: Default::default(),
prev_processing_dur: Default::default(),

layer_slice_us: vec![0; nr_layers],
})
}

Expand All @@ -868,6 +872,15 @@ impl Stats {
.map(|layer| layer.nr_tasks as usize)
.collect();

let layer_slice_us: Vec<u64> = skel
.maps
.bss_data
.layers
.iter()
.take(self.nr_layers)
.map(|layer| layer.slice_ns / 1000 as u64)
.collect();

let (total_load, layer_loads) = Self::read_layer_loads(skel, self.nr_layers);

let cur_layer_cycles = Self::read_layer_cycles(&cpu_ctxs, self.nr_layers);
Expand Down Expand Up @@ -916,6 +929,8 @@ impl Stats {

processing_dur,
prev_processing_dur: cur_processing_dur,

layer_slice_us,
};
Ok(())
}
Expand Down
6 changes: 5 additions & 1 deletion scheds/rust/scx_layered/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ pub struct LayerStats {
pub min_nr_cpus: u32,
#[stat(desc = "maximum # of CPUs assigned")]
pub max_nr_cpus: u32,
#[stat(desc = "slice duration config")]
pub slice_us: u64,
}

impl LayerStats {
Expand Down Expand Up @@ -212,6 +214,7 @@ impl LayerStats {
cur_nr_cpus: layer.cpus.count_ones() as u32,
min_nr_cpus: nr_cpus_range.0 as u32,
max_nr_cpus: nr_cpus_range.1 as u32,
slice_us: stats.layer_slice_us[lidx],
}
}

Expand Down Expand Up @@ -276,7 +279,7 @@ impl LayerStats {

writeln!(
w,
" {:<width$} preempt/first/xllc/xnuma/idle/fail={}/{}/{}/{}/{}/{} min_exec={}/{:7.2}ms",
" {:<width$} preempt/first/xllc/xnuma/idle/fail={}/{}/{}/{}/{}/{} min_exec={}/{:7.2}ms, slice={}ms",
"",
fmt_pct(self.preempt),
fmt_pct(self.preempt_first),
Expand All @@ -286,6 +289,7 @@ impl LayerStats {
fmt_pct(self.preempt_fail),
fmt_pct(self.min_exec),
self.min_exec_us as f64 / 1000.0,
self.slice_us as f64 / 1000.0,
width = header_width,
)?;

Expand Down
Loading