Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use Task.WaitAsync in SemaphoreSlim.WaitAsync#55262

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
stephentoub merged 2 commits intodotnet:mainfromstephentoub:semslimperf
Jul 8, 2021

Conversation

@stephentoub
Copy link
Member

MethodToolchainMeanRatioAllocated
WithCT\main\CoreRun.exe1.103 us1.00496 B
WithCT\pr\CoreRun.exe1.032 us0.94440 B
WithTimeout\main\CoreRun.exe1.492 us1.00888 B
WithTimeout\pr\CoreRun.exe1.103 us0.74536 B
WithCTandTimeout\main\CoreRun.exe1.589 us1.00904 B
WithCTandTimeout\pr\CoreRun.exe1.200 us0.75536 B
usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Diagnosers;usingBenchmarkDotNet.Running;usingSystem;usingSystem.Threading.Tasks;usingSystem.Threading;[MemoryDiagnoser]publicclassProgram{publicstaticvoidMain(string[]args)=>BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);privateSemaphoreSlim_sem=newSemaphoreSlim(0,1);privateCancellationTokenSource_cts=newCancellationTokenSource();[Benchmark]publicTaskWithCT(){Taskt=_sem.WaitAsync(_cts.Token);_sem.Release();returnt;}[Benchmark]publicTaskWithTimeout(){Taskt=_sem.WaitAsync(TimeSpan.FromMinutes(1));_sem.Release();returnt;}[Benchmark]publicTaskWithCTandTimeout(){Taskt=_sem.WaitAsync(TimeSpan.FromMinutes(1),_cts.Token);_sem.Release();returnt;}}

@stephentoubstephentoub added this to the6.0.0 milestoneJul 7, 2021
@ghost
Copy link

Tagging subscribers to this area:@mangod9
See info inarea-owners.md if you want to be subscribed.

Issue Details
MethodToolchainMeanRatioAllocated
WithCT\main\CoreRun.exe1.103 us1.00496 B
WithCT\pr\CoreRun.exe1.032 us0.94440 B
WithTimeout\main\CoreRun.exe1.492 us1.00888 B
WithTimeout\pr\CoreRun.exe1.103 us0.74536 B
WithCTandTimeout\main\CoreRun.exe1.589 us1.00904 B
WithCTandTimeout\pr\CoreRun.exe1.200 us0.75536 B
usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Diagnosers;usingBenchmarkDotNet.Running;usingSystem;usingSystem.Threading.Tasks;usingSystem.Threading;[MemoryDiagnoser]publicclassProgram{publicstaticvoidMain(string[]args)=>BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);privateSemaphoreSlim_sem=newSemaphoreSlim(0,1);privateCancellationTokenSource_cts=newCancellationTokenSource();[Benchmark]publicTaskWithCT(){Taskt=_sem.WaitAsync(_cts.Token);_sem.Release();returnt;}[Benchmark]publicTaskWithTimeout(){Taskt=_sem.WaitAsync(TimeSpan.FromMinutes(1));_sem.Release();returnt;}[Benchmark]publicTaskWithCTandTimeout(){Taskt=_sem.WaitAsync(TimeSpan.FromMinutes(1),_cts.Token);_sem.Release();returnt;}}
Author:stephentoub
Assignees:-
Labels:

area-System.Threading,tenet-performance

Milestone:6.0.0

@mangod9
Copy link
Member

Appears that there are some test failures though.

@stephentoub
Copy link
MemberAuthor

Yes, there's one test deterministically failing. I know why. What I need to figure out is why it ever passed prior to this :-)

pentp reacted with laugh emoji

The Cancel_WaitAsync_ContinuationInvokedAsynchronously test was failing,highlighting that we were no longer invoking the continuationasynchronously from the Cancel call.  But in fact we were incompletelydoing so in the past, such that we'd only force that asynchrony if notimeout was provided... if both a timeout and a token were provided,then we wouldn't.  I've enhanced the test to validate both cases, andmade sure we now pass.
@stephentoubstephentoub merged commite30c200 intodotnet:mainJul 8, 2021
@stephentoubstephentoub deleted the semslimperf branchJuly 8, 2021 02:20
@davidfowl
Copy link
Member

Why not Task.Yield()? Do you care about avoiding the sync context?

@stephentoub
Copy link
MemberAuthor

Do you care about avoiding the sync context?

Always :)

@davidfowl
Copy link
Member

What about the extra delegate allocation tho 🙃

@stephentoub
Copy link
MemberAuthor

What about the extra delegate allocation tho

That occurs only if cancellation is requested? I'm not worried about it :)

@ghostghost locked asresolvedand limited conversation to collaboratorsAug 7, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@mangod9mangod9mangod9 approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

6.0.0

Development

Successfully merging this pull request may close these issues.

3 participants

@stephentoub@mangod9@davidfowl

[8]ページ先頭

©2009-2025 Movatter.jp