Skip to content

Off-cpu profiling threshold: Use probability instead of per-mille value #459

@rockdaboot

Description

@rockdaboot
Contributor

As pointed out in #458, the current off-cpu per-mille threshold might be too gritty in some situations.

Suggestion

Replace the per-mille -off-cpu-threshold value float probability value in the range [0..1]. 0 means that off-cpu profiling is not enabled. 1 means that all off-cpu events are processed. For example, 0.1 means that ~ every 10th event is processed.

In off_cpu.ebpf.c we also get rid of the relative expensive division.

  if (bpf_get_prandom_u32() % OFF_CPU_THRESHOLD_MAX >= syscfg->off_cpu_threshold) {
    return 0;
  }

would become

  if (bpf_get_prandom_u32() <= syscfg->off_cpu_threshold) {
    return 0;
  }

where off_cpu_threshold is the value of uint32(p * float64(math.MaxUint32)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @rockdaboot

      Issue actions

        Off-cpu profiling threshold: Use probability instead of per-mille value · Issue #459 · open-telemetry/opentelemetry-ebpf-profiler