dotnet/BenchmarkDotNet · error · NotSupportedException
Sampling interval change is not supported!
Error message
Sampling interval change is not supported!
What it means
Thrown by TraceLogParser.OnPmcIntervalChange when an ETW Precise Machine Counter (PMC) profile source reports a new sampling interval that differs from the one recorded earlier in the same run. The Windows ETW PMC diagnoser assumes a fixed per-counter interval for the whole run so it can normalize sample counts; a mid-run change makes the math invalid.
Source
Thrown at src/BenchmarkDotNet.Diagnostics.Windows/Tracing/TraceLogParser.cs:76
private void OnOverheadActualStop(IterationEvent obj) => HandleIterationEvent(obj.ProcessID, obj.TimeStampRelativeMSec, IterationMode.Overhead, obj.TotalOperations);
private void OnWorkloadActualStart(IterationEvent obj) => HandleIterationEvent(obj.ProcessID, obj.TimeStampRelativeMSec, IterationMode.Workload, obj.TotalOperations);
private void OnWorkloadActualStop(IterationEvent obj) => HandleIterationEvent(obj.ProcessID, obj.TimeStampRelativeMSec, IterationMode.Workload, obj.TotalOperations);
private void HandleIterationEvent(int processId, double timeStampRelative, IterationMode iterationMode, long totalOperations)
{
// if given process emits Benchmarking events it's the process that we care about
if (!processIdToData.ContainsKey(processId))
processIdToData.Add(processId, new ProcessMetrics());
processIdToData[processId].HandleIterationEvent(timeStampRelative, iterationMode, totalOperations);
}
private void OnPmcIntervalChange(SampledProfileIntervalTraceData data)
{
if (profileSourceIdToInterval.TryGetValue(data.SampleSource, out int storedInterval) && storedInterval != data.NewInterval)
throw new NotSupportedException("Sampling interval change is not supported!");
profileSourceIdToInterval[data.SampleSource] = data.NewInterval;
}
private void OnPmcEvent(PMCCounterProfTraceData data)
{
// if given process did not emit Benchmarking events before, we don't care about it
if (!processIdToData.ContainsKey(data.ProcessID))
return;
processIdToData[data.ProcessID].HandleNewSample(data.TimeStampRelativeMSec, data.InstructionPointer, data.ProfileSource);
}
}
public class ProcessMetrics
{
private readonly List<double> overheadTimestamps = new List<double>(20);
private readonly List<double> workloadTimestamps = new List<double>(20);View on GitHub (pinned to b515068b61)
Solutions
- Disable other profiling/tracing tools (PerfView, VTune, dotTrace sampling) while the benchmark runs.
- Pin CPU frequency and disable turbo/C-states in power settings (powercfg) so the PMU interval stays constant.
- Run on bare metal instead of a virtualized environment that virtualizes the PMU.
- Reduce the number of PMC counters requested so the OS does not re-balance them mid-run.
Defensive patterns
Strategy: validation
Try / catch
// NotSupportedException from OnPmcIntervalChange is fatal for the run; surface to the user:
try { /* run PMC diagnoser */ }
catch (NotSupportedException ex) when (ex.Message.Contains("Sampling interval"))
{
log.Error($"PMC interval changed mid-run; rerun on bare metal without competing profilers. {ex.Message}");
} Prevention
- Run benchmarks with PMC counters on bare metal, not in a VM with virtualized PMU.
- Stop PerfView/VTune/xperf before running BDN with HardwareCounters.
- Pin CPU frequency and disable C-states/turbo to keep the PMU interval stable.
When it happens
Trigger: Using the HardwareCounters / ETW PMC diagnoser on Windows while the OS, firmware, or another profiler rescales the PMU sample interval mid-capture. Triggered inside OnPmcIntervalChange(SampledProfileIntervalTraceData) when profileSourceIdToInterval[data.SampleSource] already holds a value != data.NewInterval.
Common situations: Running another sampling profiler (PerfView, VTune, xperf) concurrently; aggressive CPU power-management (throttling) on a laptop/server that retunes PMU config; running under a VM with passthrough PMU virtualization that reconfigures counters; very long benchmark runs that span a power-state transition.
Related errors
- TotalOperations count can't change during the benchmark run!
- One overhead iteration stop event is missing, unable to calc
- One workload iteration stop event is missing, unable to calc
- TotalOperations is missing, unable to calculate stats
- Please use Targets property
AI-assisted analysis of dotnet/BenchmarkDotNet@b515068b61 (2026-08-13).
Data as JSON: /api/errors/7d179b21df0b0cea.
Report an issue: GitHub.