-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Async Refactor #2958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Async Refactor #2958
Conversation
e973208 to
2244617
Compare
|
|
||
| partial class RunnableEmitter | ||
| { | ||
| // TODO: update this to support runtime-async. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VSadov Should we emit runtime-async methods for this? Is it supported already? If so, what's the pattern?
|
@copilot review |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
I did the minimum changes required for proper async benchmarks, but I'm not sure if we want to take it further. We could make all interface methods async ( @stephentoub Can we get your input here? |
Input on what specifically? |
On the whole async API design. More specifically my previous comment about how much of the surface we should make async and whether it even makes sense to add cancelation token support. |
Core changes:
BenchmarkRunner.RunAsync/BenchmarkSwitcher.Run*AsyncAPIs.IterationSetup/Cleanupnow support async methods.IClockis passed to theWorkloadActionNoUnrolletc. benchmark methods and they pass backClockSpan, instead of theEnginestarting and stopping the clock.Behavior changes:
await Task.Yield()continues on the current synchronization context if it exists, or the current task scheduler. Previously this meant it continued on a ThreadPool thread, now it means it will likely run on the same thread via the newBenchmarkSynchronizationContext. This should be benign.Breaking changes:
IEngineRunResults Run()changed toValueTask<RunResults> RunAsync()EngineParametersWorkloadActionNoUnrolletc. changed fromAction<long>toFunc<long, IClock, ValueTask<ClockSpan>>GlobalSetupActionetc. changed fromActiontoFunc<ValueTask>IExecutorExecuteResult Execute(ExecuteParameters executeParameters)changed toValueTask<ExecuteResult> ExecuteAsync(ExecuteParameters executeParameters)IDiagnoser,IToolchain,IValidatorIEnumerable<ValidationError> Validate(ValidationParameters validationParameters)changed toIAsyncEnumerable<ValidationError> ValidateAsync(ValidationParameters validationParameters);ExecutionValidatorandReturnValueValidatorthat call user code that could be async.Other Changes:
InProcessNoEmitToolchain[AsyncCallerType]allows users to override the type used in the async method that calls their benchmark method.InProcessNoEmitToolchain[AggressivelyOptimizeMethods]instructs the assembly weaver to applyAggressiveOptimizationto all methods in the annotated type and nested types.EngineJitStageReturnValueValidatoris now able to validate async results.Fixes #2442
Unblocks #1808