Skip to content

Suppress ExecutionContext flow on SQLite hot path#53503

Merged
sharwell merged 1 commit intodotnet:mainfrom
sharwell:faster-save
Jun 2, 2021
Merged

Suppress ExecutionContext flow on SQLite hot path#53503
sharwell merged 1 commit intodotnet:mainfrom
sharwell:faster-save

Conversation

@sharwell
Copy link
Contributor

@sharwell sharwell commented May 19, 2021

Avoids approximately 1 million calls to LogicalCallContext.Clone(), which reduces GC and CPU overhead for this heavily asynchronous path.

Fixes AB#1326123

@sharwell sharwell requested a review from a team as a code owner May 19, 2021 00:24
@ghost ghost added the Area-IDE label May 19, 2021
// ⚠ DO NOT AWAIT INSIDE THE USING. The Dispose method that restores ExecutionContext flow must run on the
// same thread where SuppressFlow was originally run.
using var _ = FlowControlHelper.TrySuppressFlow();
return PerformTaskAsync(func, arg, _connectionPoolService.Scheduler.ConcurrentScheduler, cancellationToken);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, just for clarity. it's ok that we're going to return a task here, have the IDIsposable disposed, and hten have the caller to whatever it wants with that task? this is just about setting some values that are only relevant for when teh task is created?

Copy link
Contributor Author

@sharwell sharwell Jun 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the behavior you describe is required for correctness. It's strange and normally a red flag, hence the warning.

Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shippit :)

@sharwell sharwell merged commit cf37fb9 into dotnet:main Jun 2, 2021
@ghost ghost added this to the Next milestone Jun 2, 2021
@sharwell sharwell deleted the faster-save branch June 2, 2021 15:58
@AArnott
Copy link
Contributor

AArnott commented Jun 3, 2021

Is this a change that would be worthwhile to use inside the VS cache service, I wonder?

dibarbet pushed a commit that referenced this pull request Jun 9, 2021
Suppress ExecutionContext flow on SQLite hot path
@RikkiGibson RikkiGibson modified the milestones: Next, 17.0.P2 Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants