Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Conversation

@benaadams
Copy link
Contributor

@benaadams benaadams commented Sep 1, 2018

The ratio of non-async paths in WriteAsync of HttpResponseStreamWriter to async paths (including FlushAsync) for the RazorRendering benchmarkapp aspnet/Mvc#8366

For 1 request in the currently its 8774 non-async to 12 async.

image

This adds a fast-path to skip the async statemahchine creation for when no FlushAsync takes place.

It also means it can be detected upstream in MVC and allow more fast-paths to flow

/cc @davidfowl @rynowak

@JamesNK
Copy link
Member

JamesNK commented Sep 1, 2018

Looks good to me. How much time is spent in that method for a request? 8000k is a fair number of calls but does the state machine overhead add up to much?

@benaadams
Copy link
Contributor Author

8000k statemachines with all their try/catchery

image

@benaadams
Copy link
Contributor Author

benaadams commented Sep 1, 2018

8000k is a fair number of calls but does the state machine overhead add up to much?

Also this is for one request; so that's 8bn for 1M requests; or 8M for 1k requests (though they are larger responses)

}

if (value == null)
var count = value.Length;

Choose a reason for hiding this comment

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

This would now throw if value is null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@benaadams
Copy link
Contributor Author

How much time is spent in that method for a request?

As CopyToCharBuffer is the workhorse part of the function; it does looks significant in terms of where the rest of the time is spent in this class:

image

@benaadams
Copy link
Contributor Author

Any takers for a review/approve? /cc @rynowak

@rynowak
Copy link
Member

rynowak commented Oct 1, 2018

OK it.

if (count == 0)
{
return Task.CompletedTask;
}
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth folding this together with L234?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@JamesNK JamesNK left a comment

Choose a reason for hiding this comment

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

I think the changes look good. Are there unit tests that hit both sync and async paths?

Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

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

LGTM

@muratg muratg added this to the 2.2.0-preview3 milestone Oct 10, 2018
@JunTaoLuo
Copy link
Contributor

Merged in 800c79c. Thanks @benaadams !

@JunTaoLuo JunTaoLuo closed this Oct 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

7 participants