Skip to content
Merged
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
18 changes: 8 additions & 10 deletions tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,26 +535,24 @@ func loadAllMaps(coll *cebpf.CollectionSpec, cfg *Config,
adaption := make(map[string]uint32, 4)

const (
// The following sizes X are used as 2^X, and determined empirically

// The following sizes X are used as 2^X, and determined empirically.
// 1 million executable pages / 4GB of executable address space
pidPageMappingInfoSize = 20

pidPageMappingInfoSize = 20
stackDeltaPageToInfoSize = 16
exeIDToStackDeltasSize = 16
)

adaption["pid_page_to_mapping_info"] =
1 << uint32(pidPageMappingInfoSize+cfg.MapScaleFactor)

adaption["stack_delta_page_to_info"] =
1 << uint32(stackDeltaPageToInfoSize+cfg.MapScaleFactor)

// To not loose too many scheduling events but also not oversize
// sched_times, calculate a size based on some assumptions.
// On modern systems /proc/sys/kernel/pid_max defaults to 4194304.
// Try to fit this PID space scaled down with cfg.OffCPUThreshold into
// this map.
adaption["sched_times"] = (4194304 * cfg.OffCPUThreshold) / support.OffCPUThresholdMax
// 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
Comment on lines +553 to +555
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but it is not obvious to me how 4096 reflects the mentioned "average time a task remains off CPU (3s)". How exactly has the number 4096 been determined and is this the the best value or does it need further refinement?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pow2(1000*3)


for i := support.StackDeltaBucketSmallest; i <= support.StackDeltaBucketLargest; i++ {
mapName := fmt.Sprintf("exe_id_to_%d_stack_deltas", i)
Expand Down