-
Notifications
You must be signed in to change notification settings - Fork 94
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 timeslice #578
Conversation
d3a91b2
to
ca595d1
Compare
scheds/rust/scx_layered/src/main.rs
Outdated
layer.min_exec_ns = min_exec_us * 1000; | ||
layer.yield_step_ns = if *yield_ignore > 0.999 { | ||
0 | ||
} else if *yield_ignore < 0.001 { | ||
opts.slice_us * 1000 | ||
layer.slice_ns * 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this conversion doesn't need to be done since it already gets converted above...
ca595d1
to
4f752f0
Compare
@@ -788,8 +790,9 @@ static bool keep_running(struct cpu_ctx *cctx, struct task_struct *p) | |||
if (!(tctx = lookup_task_ctx(p)) || !(layer = lookup_layer(tctx->layer))) | |||
goto no; | |||
|
|||
u64 layer_slice_ns = layer->slice_ns > 0 ? layer->slice_ns : slice_ns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may also want to use layer_slice_ns to refill p->scx.slice
if the task keeps running. Otherwise the task's time slice is automatically refilled to SCX_SLICE_DFL
if I'm not wrong.
Maybe something like this (untested):
diff --git a/scheds/rust/scx_layered/src/bpf/main.bpf.c b/scheds/rust/scx_layered/src/bpf/main.bpf.c
index 14e6fc9..cb9ccbe 100644
--- a/scheds/rust/scx_layered/src/bpf/main.bpf.c
+++ b/scheds/rust/scx_layered/src/bpf/main.bpf.c
@@ -817,6 +817,7 @@ static bool keep_running(struct cpu_ctx *cctx, struct task_struct *p)
*/
if (disable_topology) {
if (!scx_bpf_dsq_nr_queued(layer->idx)) {
+ p->scx.slice = layer_slice_ns;
lstat_inc(LSTAT_KEEP, layer, cctx);
return true;
}
@@ -825,6 +826,7 @@ static bool keep_running(struct cpu_ctx *cctx, struct task_struct *p)
tctx->last_cpu :
bpf_get_smp_processor_id());
if (!scx_bpf_dsq_nr_queued(dsq_id)) {
+ p->scx.slice = layer_slice_ns;
lstat_inc(LSTAT_KEEP, layer, cctx);
return true;
}
@@ -850,6 +852,7 @@ static bool keep_running(struct cpu_ctx *cctx, struct task_struct *p)
scx_bpf_put_idle_cpumask(idle_cpumask);
if (has_idle) {
+ p->scx.slice = layer_slice_ns;
lstat_inc(LSTAT_KEEP, layer, cctx);
return true;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that worked alright, I spent a bit of time trying tuning different layer slice lengths and it's rather interesting to see how the slice can affect throughput vs latency.
Allow setting a different timeslice per layer. Signed-off-by: Daniel Hodges <[email protected]>
4f752f0
to
cc450f1
Compare
Allow setting a different timeslice per layer.
tested by adding some debug logs:
output: