-
-
Couldn't load subscription status.
- Fork 1.3k
Reduce async overhead #2664
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
Reduce async overhead #2664
Conversation
|
Thanks for your PR. I'm not against any improvements that don't impact the public API surface, but Have you run the latest benchmarks before and after these changes? We'd want to see some concrete numbers on any improvements and trade-offs that these changes might make. Some parts could potentially be moved out into separate smaller PRs as they're pretty uncontroversial (e.g. using |
- Avoid LINQ to create components. - Do not recreate `Outcome<T>` for chaos. - Avoid predicate allocation. - Use `ArgumentNullException.ThrowIfNull()` where possible. - Add throw helper for `ObjectDisposedException`. - Remove unused `Stopwatch`. - Use `Volatile.Read` instead of `Interlocked.CompareExchange()`. Cherry-picked from #2664. Co-Authored-By: Pent Ploompuu <[email protected]>
- Avoid LINQ to create components. - Do not recreate `Outcome<T>` for chaos. - Avoid predicate allocation. - Use `ArgumentNullException.ThrowIfNull()` where possible. - Add throw helper for `ObjectDisposedException`. - Remove unused `Stopwatch`. - Use `Volatile.Read` instead of `Interlocked.CompareExchange()`. Cherry-picked from #2664. Co-Authored-By: Pent Ploompuu <[email protected]>
|
I've cherry-picked some of the changes here into #2667, which has now been merged. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2664 +/- ##
==========================================
- Coverage 96.23% 96.12% -0.11%
==========================================
Files 311 309 -2
Lines 7322 7118 -204
Branches 1012 1006 -6
==========================================
- Hits 7046 6842 -204
Misses 222 222
Partials 54 54
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
The changes from |
|
|
Some benchmark numbers:
For actually async flows the improvements are significant, but even just sync flows benefit from the reduced overhead. Unfortunately almost all existing benchmarks are synchronous so the async overhead of many layers of (Value)Tasks isn't very visible. |
|
Thanks for taking the time to run the benchmarks - it looks like all the numbers have improved for both duration and memory consumption. |
src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs
Outdated
Show resolved
Hide resolved
src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs
Outdated
Show resolved
Hide resolved
test/Polly.Core.Tests/CircuitBreaker/Controller/ScheduledTaskExecutorTests.cs
Show resolved
Hide resolved
test/Polly.Core.Tests/Utils/Pipeline/PipelineComponentFactoryTests.cs
Outdated
Show resolved
Hide resolved
|
Just one last comment and fixing the mutation tests and this looks good to merge. |
Update benchmark results ahead of merging #2664.
Update benchmark results ahead of merging #2664.
Remove many unnecessary async awaits from the pipeline hot path.
Also cleaned up some excessive use of lambdas.