Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/BenchmarkDotNet/Engines/Engine.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BenchmarkDotNet.Attributes.CompilerServices;
using BenchmarkDotNet.Attributes.CompilerServices;
using BenchmarkDotNet.Characteristics;
using BenchmarkDotNet.Helpers;
using BenchmarkDotNet.Jobs;
Expand Down Expand Up @@ -89,16 +89,19 @@ public async ValueTask<RunResults> RunAsync()
}

// This method is extra long because the helper methods were inlined in order to prevent extra async allocations on each iteration.
private async ValueTask<RunResults> RunCore()
private async Task<RunResults> RunCore()
{
// We need to force an async yield here to ensure each benchmark invocation is called with a constant stack size. #1120
await Task.Yield();
Host.CancellationToken.ThrowIfCancellationRequested();

var measurements = new List<Measurement>();

if (EngineEventSource.Log.IsEnabled())
EngineEventSource.Log.BenchmarkStart(Parameters.BenchmarkName);

IterationData extraIterationData = default;
// Enumerate the stages and run iterations in a loop to ensure each benchmark invocation is called with a constant stack size.
// #1120
// Enumerate the stages and run iterations in a loop to ensure each benchmark invocation is called with a constant stack size. #1120
foreach (var stage in EngineStage.EnumerateStages(Parameters))
{
if (stage.Stage == IterationStage.Actual && stage.Mode == IterationMode.Workload)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static async ValueTask<int> Run(IHost host, ExecuteParameters parameters,

var methodInfo = type.GetMethod(nameof(Runnable.RunCore), BindingFlags.Public | BindingFlags.Static)
?? throw new InvalidOperationException($"Bug: method {nameof(Runnable.RunCore)} in {inProcessRunnableTypeName} not found.");
await ((ValueTask) methodInfo.Invoke(null, [host, parameters, benchmarkActionFactory])!).ConfigureAwait(false);
await ((ValueTask) methodInfo.Invoke(null, [host, parameters, benchmarkActionFactory])!).ConfigureAwait(true);

return 0;
}
Expand Down
Loading