Skip to content
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

Remove unnecessary spills from BufferedStream.ReadAsync #55190

Merged
merged 1 commit into from
Jul 6, 2021

Conversation

stephentoub
Copy link
Member

Saves a field in each state machine.

@ghost
Copy link

ghost commented Jul 6, 2021

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

Saves a field in each state machine.

Author: stephentoub
Assignees: -
Labels:

area-System.IO

Milestone: -

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

LGTM, however I wish our compiler could optimize that for us.

@adamsitnik adamsitnik added this to the 6.0.0 milestone Jul 6, 2021
@adamsitnik
Copy link
Member

the failures are unrelated, I am merging

@adamsitnik adamsitnik merged commit d25af09 into dotnet:main Jul 6, 2021
@stephentoub stephentoub deleted the removespill branch July 6, 2021 10:16
@stephentoub
Copy link
Member Author

I wish our compiler could optimize that for us.

For the most part this is by design: to maintain order of operations, if you have A() + await B() the compiler has to evaluate A() first, at which point it has to store the result somewhere across the await. In this constrained case, where A() is actually a local whose address is never exposed, isn't passed by ref, isn't captured by a closure, etc., it could probably avoid it, and for that I opened dotnet/roslyn#54629. But it's also possible the rewards from such a constrained optimization are limited (e.g. these were the only two occurrences in product code of + await in all of dotnet/runtime), and there may be reasons why even for this case the compiler might face correctness issues.

@adamsitnik
Copy link
Member

@stephentoub thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants