Skip to content

fix: add shell-level timeout to perf stat capability probes in metadata collection - #717

Draft
romirdes with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-perfstat-hang-issue
Draft

fix: add shell-level timeout to perf stat capability probes in metadata collection#717
romirdes with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-perfstat-hang-issue

Conversation

Copilot AI commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

On large virtualized x86 instances (e.g. m6i.16xlarge), the hypervisor stalls perf_event_open indefinitely rather than returning an error. Since metadata probe scripts run with no timeout (timeout := 0 in the controller), PerfSpect hangs forever at "collecting metadata" and never reaches "collecting metrics". Smaller VMs (e.g. c6i.2xl) fail fast with a non-zero exit → expected error; bare-metal works normally.

Changes

  • cmd/metrics/metadata.go: Prefix all 9 perf stat capability probe ScriptTemplate values with timeout 30:
// before
ScriptTemplate: "perf stat -a -e instructions sleep 1",

// after
ScriptTemplate: "timeout 30 perf stat -a -e instructions sleep 1",

Affected probes: scriptPerfStatInstructions, scriptPerfStatRefCycles, scriptPerfStatPEBS, scriptPerfStatOCR, scriptPerfStatTMA, scriptPerfStatAMDUncoreProbe, scriptPerfStatFixedInstr, scriptPerfStatFixedCycles, scriptPerfStatFixedRefCycles.

Each probe normally completes in ~1 s (it runs sleep 1 as the workload). All probes run concurrently, so the 30 s budget is ~30× the normal wall-clock cost and poses no risk of false failures on loaded instances. On a hung instance, timeout exits with code 124 (non-zero) → probe treated as unsupported → fast-fail with a clear error instead of an indefinite hang.

Co-authored-by: romirdes <86635949+romirdes@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix indefinite hanging during metadata collection on large VMs fix: add shell-level timeout to perf stat capability probes in metadata collection Aug 31, 2026
Copilot AI requested a review from romirdes August 31, 2026 19:26
…arge virtualized instances

perf list --json can also stall indefinitely on some hypervisors (e.g. m6i.16xlarge),
just like perf stat. The stderr.txt from the failing test showed PerfSpect was stuck
at "collecting metadata", and perf list is the remaining unguarded perf command in
that stage. Wrap both scriptPerfSupportedEvents and scriptPerfAllSupportedEvents
with timeout 30 to bound them consistently with the perf stat probes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants