Skip to content

Restore sync-over-async task consumption#3142

Open
timcassell wants to merge 2 commits into
masterfrom
sync-task-consume
Open

Restore sync-over-async task consumption#3142
timcassell wants to merge 2 commits into
masterfrom
sync-task-consume

Conversation

@timcassell

@timcassell timcassell commented May 23, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3139

Job.WithConsumeTasksSynchronously(true) or --consumeTasksSynchronously true or [ConsumeTasksSynchronously(true)] option restores the previous task.GetAwaiter().GetResult() benchmark behavior.

  • The default is false. I could be convinced to change the default to true if we think preserving historical comparisons is more important than correct await behavior. @adamsitnik

No longer installs a SynchronizationContext. This restores sync-over-async behavior in Params/ArgumentsSource (#3117), and it results in faster async measurements by default. Users can install a sync context themselves if they want that behavior. (Basically we still use the single-thread-pump context for internal awaits, but we don't leak it to user code/benchmarks.)

@timcassell timcassell added this to the v0.16.0 milestone May 23, 2026
@timcassell timcassell requested a review from adamsitnik May 23, 2026 11:39
@timcassell timcassell force-pushed the sync-task-consume branch from 6f6fe11 to 16ce011 Compare May 29, 2026 17:14
@timcassell timcassell marked this pull request as draft June 15, 2026 23:22
@timcassell timcassell force-pushed the sync-task-consume branch 2 times, most recently from 2bdde9c to 22c527e Compare June 16, 2026 07:54
Refactor BenchmarkSynchronizationContext to not install SynchronizationContext.Current.
@timcassell timcassell marked this pull request as ready for review June 16, 2026 22:51
@filzrev

filzrev commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Is it able to include docs/articles/guides/console-args.md update in this PR?

 * `--consumeTasksSynchronously` (Default: false) Specifies whether to consume (Value)Task-returning benchmarks synchronously.

After this PR is merged, I'll update #3162 to include this changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Async benchmarks show regressions using 0.16.0 prereleases

2 participants