This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Shrink Task.Delay when used without Cancellation (2)#22234
Closed
benaadams wants to merge 2 commits into
Closed
Conversation
Member
|
Thanks. I was thinking of something slightly different. Away from my computer right now but will try it when I'm back. |
Member
|
@benaadams, I was thinking of something like this: |
Member
Author
|
Yeah, that looks much better |
Member
Author
|
Are you submitting PR with it? |
Member
Feel free to copy or cherry-pick, since you already have two PRs open 😄 |
Member
Author
|
Done, went for first as my cherry-picking ability is still a bit primordial 😄 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow up to #22233
Task.Delayis commonly used without cancellation:Task Delay(int)- API Port 22.6%Task Delay(TimeSpan)- API Port 9.8%Task Delay(int, CancellationToken)- API Port 5.6%Task Delay(TimeSpan, CancellationToken)- API Port 9.3%This shaves 24 bytes of allocation off that common path.
Using @SergeyTeplyakov's ObjectLayoutInspector and local copies of the internal objects to make it easier to inspect.
To
/cc @stephentoub