Skip to content

[off-CPU stack 3/3] Add duration-filtered off-CPU profiling with task-state labels - #75

Closed
dalehamel wants to merge 1 commit into
dale/offcpu-omnibus-probe-apifrom
dale/offcpu-omnibus
Closed

dalehamel wants to merge 1 commit into
dale/offcpu-omnibus-probe-apifrom
dale/offcpu-omnibus

Conversation

@dalehamel

@dalehamel dalehamel commented Jul 24, 2026 •

Copy link
Copy Markdown
Member

Stack

  1. #73 → #50
  2. dale/offcpu-omnibus-probe-api — minimal Probe runtime foundation
  3. This PR — duration-filtered off-CPU probe + task-state labels

What

Add off_cpu_time as a dynamic custom probe on the LuaJIT omnibus stack. It retains the upstream built-in profile's duration-valued semantics, while adding:

  • duration-aware min_duration filtering before unwind/export;
  • completion-side sample rate;
  • migration-safe global LRU correlation;
  • configurable map capacity and a safe 1ms default minimum;
  • per-path health/drop metrics;
  • thread.state labels separating voluntary blocking from runnable/preempted scheduler delay.

Important semantic clarification

The built-in upstream off_cpu profile already emits one selected wakeup event weighted by exact elapsed nanoseconds. This probe does not change count→duration. Its differences are selection timing, migration correctness, state visibility, and operational accounting. The README documents both paths and the no-inverse-scaling caveat.

Minimal ABI adaptation

The Hack Days implementation carried thread state through the async I/O ABI. This clean stack instead adds one generic probe_user_data field and an optional per-origin TraceLabeler. It has no dependency on async I/O, process observers, lock-wait, memory profiling, or other Hack Days probes. Probe-private ELF resources follow the <configured name>_* prefix contract and are removed from the main collection by the caller-supplied dynamic resource prefix.

Configuration

custom_probes:
  off_cpu_time:
    min_duration: 5ms  # safe default is 1ms; 0s is explicit exhaustive mode
    sample_rate: 1
    max_entries: 65536

Validation

  • clang-17 deterministic amd64 + arm64 BPF rebuild; format lint green.
  • Unit/build/vet sweep across offcpu, generic probes, tracer, support, reporter, traceutil, controller.
  • Privileged arm64 integration: positive duration+hybrid-stack+thread.state=interruptible path in 0.92s; 10-minute threshold emits no short waits.
  • Existing one-node staging tophat of the equivalent HD40 implementation: 585,084 interruptible rows / 140,162.52s, plus idle, uninterruptible, running, and preempted states, filterable as process.context.label.thread.state.

Upstream convergence

This remains a separate profile while we evaluate upstreaming the useful pieces into built-in off_cpu. Upstream history already requests duration-threshold sampling (open-telemetry#144) and documents the per-CPU migration amplification (open-telemetry#1348). Do not enable both built-in off_cpu and off_cpu_time simultaneously unless deliberately comparing them.

Add the off_cpu_time dynamic probe on top of the omnibus ProbeContext
foundation. Correlate every switch-out through a migration-safe global
LRU map, apply min-duration and sampling after elapsed time is known,
and report exact nanosecond values with per-path metrics. Capture the
validated sched_switch prev_state as thread.state so blocking and CPU
saturation can be filtered independently.

Use a minimal generic probe_user_data trace field for the optional
per-origin TraceLabeler; this branch does not depend on the Hack Days
async I/O or process-observer ABIs. Clarify that upstream built-in
off_cpu is already duration-valued and document the actual differences.

Assisted-By: devx/2d48a84f-4aab-48eb-9009-5dd68fa593f3
@dalehamel
dalehamel force-pushed the dale/offcpu-omnibus-probe-api branch from 3a279c8 to 30b61c7 Compare July 24, 2026 20:33
@dalehamel
dalehamel force-pushed the dale/offcpu-omnibus branch from f4a4895 to 67caea4 Compare July 24, 2026 20:33
@github-actions

Copy link
Copy Markdown

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions Bot added the Stale label Aug 22, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions Bot closed this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant