-
Notifications
You must be signed in to change notification settings - Fork 399
off-cpu: Use a probability value for the threshold #460
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
Changes from all commits
edaf5d9
bb7b459
595c8cf
908e235
3c80691
6c7f7b3
0098768
163e76f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import ( | |
| "context" | ||
| "errors" | ||
| "fmt" | ||
| "math" | ||
| "math/rand/v2" | ||
| "strings" | ||
| "sync/atomic" | ||
|
|
@@ -448,11 +449,7 @@ func loadAllMaps(coll *cebpf.CollectionSpec, cfg *Config, | |
| adaption["stack_delta_page_to_info"] = | ||
| 1 << uint32(stackDeltaPageToInfoSize+cfg.MapScaleFactor) | ||
|
|
||
| // To not lose too many scheduling events but also not oversize sched_times, | ||
| // calculate a size based on an assumed upper bound of scheduler events per | ||
| // second (1000hz) multiplied by an average time a task remains off CPU (3s), | ||
| // scaled by the probability of capturing a trace. | ||
| adaption["sched_times"] = (4096 * cfg.OffCPUThreshold) / support.OffCPUThresholdMax | ||
| adaption["sched_times"] = schedTimesSize(cfg.OffCPUThreshold) | ||
|
|
||
| for i := support.StackDeltaBucketSmallest; i <= support.StackDeltaBucketLargest; i++ { | ||
| mapName := fmt.Sprintf("exe_id_to_%d_stack_deltas", i) | ||
|
|
@@ -478,6 +475,25 @@ func loadAllMaps(coll *cebpf.CollectionSpec, cfg *Config, | |
| return nil | ||
| } | ||
|
|
||
| // schedTimesSize calculates the size of the sched_times map based on the | ||
| // configured off-cpu threshold. | ||
| // To not lose too many scheduling events but also not oversize sched_times, | ||
| // calculate a size based on an assumed upper bound of scheduler events per | ||
| // second (1000hz) multiplied by an average time a task remains off CPU (3s), | ||
| // scaled by the probability of capturing a trace. | ||
| func schedTimesSize(threshold uint32) uint32 { | ||
| size := uint32((4096 * uint64(threshold)) / math.MaxUint32) | ||
| if size < 16 { | ||
| // Guarantee a minimal size of 16. | ||
| return 16 | ||
| } | ||
| if size > 4096 { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With a given probability value of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The behavior for |
||
| // Guarantee a maximum size of 4096. | ||
| return 4096 | ||
| } | ||
| return size | ||
| } | ||
|
|
||
| // loadPerfUnwinders loads all perf eBPF Programs and their tail call targets. | ||
| func loadPerfUnwinders(coll *cebpf.CollectionSpec, ebpfProgs map[string]*cebpf.Program, | ||
| tailcallMap *cebpf.Map, tailCallProgs []progLoaderHelper, | ||
|
|
||
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.
[..] an average time a task remains off CPU (3s)- is there some evidence for this number? From local workload I see significant different (lower) values.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 didn't change the text, just moved it. Maybe @christos68k can give some background how exactly he measured this number.
Uh oh!
There was an error while loading. Please reload this page.
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.
Otherwise, what is your preferred number here @florianl?
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 went for relaxed rather than tight sizing here.