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

Prefer memory overloads for Stream.ReadAsync/WriteAsync #3525

Merged
merged 3 commits into from
May 18, 2020

Conversation

turbedi
Copy link
Contributor

@turbedi turbedi commented May 7, 2020

Benefits from the returning type being ValueTask<int>.

@bdach
Copy link
Collaborator

bdach commented May 7, 2020

Have you benchmarked this? What are the measurable performance gains from these changes?

From what I can see from the docs using ValueTask<T> instead of Task<T> is not an automatically free optimisation.

@turbedi
Copy link
Contributor Author

turbedi commented May 7, 2020

I haven't done any benchmarks yet, I should be able to do some this weekend.

As far as I understood, it should be a free optimization in cases where where Stream.Read/WriteAsync methods are used.

@peppy
Copy link
Member

peppy commented May 8, 2020

These are seldom used paths and the operation performed inside the task is magnitudes more intensive than creating a Task instance. I'd be wary of making this change just because-we-can in one location – I may think differently if this was applied along with a performance rule on inspectcode or roslyn to ensure these changes are made anywhere/everywhere.

@smoogipoo smoogipoo merged commit d3a842d into ppy:master May 18, 2020
@turbedi turbedi deleted the read_writeAsync_changes branch May 18, 2020 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants