{"record":{"id":"76c6c5db5b2a9046","repo":"dotnet/BenchmarkDotNet","slug":"one-overhead-iteration-stop-event-is-missing-unab","errorCode":null,"errorMessage":"One overhead iteration stop event is missing, unable to calculate stats","messagePattern":"One overhead iteration stop event is missing, unable to calculate stats","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet.Diagnostics.Windows/Tracing/TraceLogParser.cs","lineNumber":124,"sourceCode":"            }\n            else if (iterationMode == IterationMode.Workload)\n            {\n                if (!totalOperationsPerIteration.HasValue)\n                    totalOperationsPerIteration = totalOperations;\n                else if (totalOperationsPerIteration.Value != totalOperations)\n                    throw new InvalidOperationException($\"TotalOperations count can't change during the benchmark run! Invalid trace!\");\n\n                workloadTimestamps.Add(timeStamp);\n            }\n        }\n\n        public void HandleNewSample(double timeStamp, ulong instructionPointer, int profileSourceId)\n            => samples.Add((timeStamp, instructionPointer, profileSourceId));\n\n        public IEnumerable<Metric> CalculateMetrics(Dictionary<int, int> profileSourceIdToInterval, PreciseMachineCounter[] counters)\n        {\n            if (overheadTimestamps.Count % 2 != 0)\n                throw new InvalidOperationException(\"One overhead iteration stop event is missing, unable to calculate stats\");\n            if (workloadTimestamps.Count % 2 != 0)\n                throw new InvalidOperationException(\"One workload iteration stop event is missing, unable to calculate stats\");\n            if (!totalOperationsPerIteration.HasValue)\n                throw new InvalidOperationException(\"TotalOperations is missing, unable to calculate stats\");\n\n            var overheadIterations = CreateIterationData(overheadTimestamps);\n            var workloadIterations = CreateIterationData(workloadTimestamps);\n\n            SumCountersPerIterations(profileSourceIdToInterval, workloadIterations, overheadIterations, counters);\n\n            var workloadTotalPerCounter = Sum(workloadIterations);\n            var overheadTotalPerCounter = Sum(overheadIterations);\n\n            return workloadTotalPerCounter.Select(perCounter =>\n            {\n                var pmc = counters.Single(counter => counter.ProfileSourceId == perCounter.Key);\n\n                overheadTotalPerCounter.TryGetValue(perCounter.Key, out var overhead);","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet.Diagnostics.Windows/Tracing/TraceLogParser.cs#L106-L142","documentation":"CalculateMetrics requires overhead (jitting/allocations floor) iterations to come in start/stop pairs. It throws when overheadTimestamps.Count is odd, meaning an OverheadActualStart was seen without its matching OverheadActualStop, so an iteration boundary cannot be reconstructed.","triggerScenarios":"The ETW trace is missing an OverheadActualStop (or Start) event. Caused by event loss in the ETW session, the benchmarked process crashing/exiting mid-iteration, or the trace being captured over only part of the run.","commonSituations":"Capturing an .etl with insufficient buffer size (events dropped); the process under test was killed; trace started after the first overhead iteration or stopped before the last; running the PMC diagnoser on a benchmark that threw an exception partway through.","solutions":["Increase ETW session buffer sizes / use a real-time session with larger buffers to avoid dropped events.","Ensure the benchmark run completes without exceptions so all Start/Stop pairs are emitted.","Re-run the benchmark; transient event loss often does not recur."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* run + parse trace */ }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"overhead iteration stop event is missing\"))\n{\n    log.Warning(\"ETW dropped an overhead stop event; increasing buffers and rerunning.\");\n    // increase ETW buffer sizes and rerun\n}","preventionTips":["Use sufficiently large ETW session buffers to avoid dropped events.","Ensure the benchmark run completes without exceptions so all Start/Stop pairs fire.","Capture the .etl over the full run window."],"tags":["benchmarkdotnet","windows","etw","pmc","tracing","trace-corruption"],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}