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

Add custom request header decoder API to Kestrel #23233

Merged
merged 8 commits into from
Jun 27, 2020

Conversation

halter73
Copy link
Member

@halter73 halter73 commented Jun 22, 2020

  • TODONE for this PR:
    • Benchmarks. I want to make sure we agree on this design before benchmarking. In the fast path, it only adds a couple comparisons, so I think we should be good.

  • TODO for future PRs:
    • URL decoding
    • ANCM in-proc support

Partially Addresses #17400

@halter73 halter73 added area-servers feature-kestrel api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Jun 22, 2020
@halter73 halter73 added this to the 5.0.0-preview7 milestone Jun 22, 2020
@halter73 halter73 requested review from Tratcher and jkotalik June 22, 2020 20:01
@dougbu dougbu added the tell-mode Indicates a PR which is being merged during tell-mode label Jun 23, 2020
@halter73 halter73 added api-approved API was approved in API review, it can be implemented and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Jun 26, 2020
@halter73
Copy link
Member Author

Http1ConnectionBenchmark Microbenchmark Results

Before (release/5.0-preview7)

default (UTF-8) encoding

Method Mean Error StdDev Op/s Gen 0 Gen 1 Gen 2 Allocated
LiveAspNet 1.119 us 0.0222 us 0.0458 us 894,046.9 0.0210 - - 880 B

latin1 (ISO-8859-1) encoding

Method Mean Error StdDev Op/s Gen 0 Gen 1 Gen 2 Allocated
LiveAspNet 1.171 us 0.0231 us 0.0549 us 854,282.0 0.0210 - - 880 B

After (halter73/17400)

default (UTF-8) encoding

Method Mean Error StdDev Op/s Gen 0 Gen 1 Gen 2 Allocated
LiveAspNet 1.135 us 0.0180 us 0.0160 us 881,286.2 0.0229 - - 880 B

latin1 (ISO-8859-1) encoding (RequestHeaderEncodingSelector = _ => Encoding.Latin1)

Method Mean Error StdDev Op/s Gen 0 Gen 1 Gen 2 Allocated
LiveAspNet 1.172 us 0.0217 us 0.0203 us 853,229.7 0.0210 - - 880 B

Alternative default (UTF-8) encoding (RequestHeaderEncodingSelector = _ => null)

Method Mean Error StdDev Op/s Gen 0 Gen 1 Gen 2 Allocated
LiveAspNet 1.146 us 0.0166 us 0.0155 us 872,465.7 0.0229 - - 880 B

Alternative defaultish (UTF-8) encoding (RequestHeaderEncodingSelector = _ => Encoding.UTF8)

Method Mean Error StdDev Op/s Gen 0 Gen 1 Gen 2 Allocated
LiveAspNet 1.310 us 0.0173 us 0.0153 us 763,159.7 0.0229 - - 880 B

Given that we're trying to not regress perf rather than improve it with this PR, this all looks reasonable to me.

I made sure to set DisableStringReuse = true and hard-coded the "runtimeFrameworkVersion" to 5.0.0-preview.8.20323.9 for all benchmark runs. See #23000 (comment)

@halter73
Copy link
Member Author

@Pilchie Can you merge this?

@davidfowl
Copy link
Member

Can you run a CPU profile to see if there's anything that stands out?

@davidfowl
Copy link
Member

Also can you run the PR benchmark? This is basically in the hot path.

@halter73
Copy link
Member Author

halter73 commented Jun 26, 2020

Can you run a CPU profile to see if there's anything that stands out?

I don't have time for this today, and I still want this in preview7. It wouldn't be that useful yet anyway, since in the default case, we do 1 extra ReferenceEquals() comparison per request header and follow the old request decoding path. I don't need a CPU profile to tell me that.

@dotnet dotnet deleted a comment from pr-benchmarks bot Jun 26, 2020
@dotnet dotnet deleted a comment from pr-benchmarks bot Jun 26, 2020
@halter73
Copy link
Member Author

@aspnet-hello benchmark

@dotnet dotnet deleted a comment from pr-benchmarks bot Jun 27, 2020
@dotnet dotnet deleted a comment from pr-benchmarks bot Jun 27, 2020
@pr-benchmarks
Copy link

pr-benchmarks bot commented Jun 27, 2020

Starting 'Default' pipelined plaintext benchmark with session ID 'cf5b7aeeed484d849f9228c166698b36'. This could take up to 30 minutes...

@pr-benchmarks
Copy link

pr-benchmarks bot commented Jun 27, 2020

Baseline

stdout: Starting baseline run on '4465a8efc853ffb0062e316032e5e907e04736a6'...
The specified server url 'http://10.0.0.9:5001' is invalid or not responsive.
[12:15:44.889] Interrupting due to an unexpected exception
[12:15:44.911] System.Net.Http.HttpRequestException: Connection refused
 ---> System.Net.Sockets.SocketException (111): Connection refused
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.DecompressionHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at BenchmarksDriver.Program.Run(Uri serverUri, Uri[] clientUris, String sqlConnectionString, ServerJob serverJob, String session, String description, Int32 iterations, Int32 exclude, String shutdownEndpoint, TimeSpan span, List`1 downloadFiles, Boolean fetch, String fetchDestination, Boolean collectR2RLog, String traceDestination, CommandOption outputFileOption, CommandOption sourceOption, CommandOption scriptFileOption, CommandOption markdownOption, CommandOption writeToFileOption, Nullable`1 requiredOperatingSystem, CommandOption archOption, CommandOption saveOption, CommandOption diffOption) in /app/src/BenchmarksDriver/Program.cs:line 1445


stderr: Baseline benchmark run on '4465a8efc853ffb0062e316032e5e907e04736a6' failed.

PR


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.

Watch the benchmarks and lets make sure we profile this

@halter73
Copy link
Member Author

I'm also talking to @sebastienros about the benchmark server issue. I agree with him that we should move over to the new driver so we can use the same servers as everything else. We just need to budget time to make the changes.

@sebastienros
Copy link
Member

@aspnet-hello benchmark

@pr-benchmarks
Copy link

pr-benchmarks bot commented Jun 27, 2020

Starting 'Default' pipelined plaintext benchmark with session ID '1357ac5cf4f14d2c80c16f4120a48094'. This could take up to 30 minutes...

@pr-benchmarks
Copy link

pr-benchmarks bot commented Jun 27, 2020

Baseline

Starting baseline run on '4465a8efc853ffb0062e316032e5e907e04736a6'...
RequestsPerSecond:           791,229
Max CPU (%):                 99
WorkingSet (MB):             88
Avg. Latency (ms):           3.11
Startup (ms):                534
First Request (ms):          134.75
Latency (ms):                0.4
Total Requests:              11,889,004
Duration: (ms)               15,030
Socket Errors:               0
Bad Responses:               0
Build Time (ms):             22,045
Published Size (KB):         120,307
SDK:                         5.0.100-preview.6.20310.4
Runtime:                     5.0.0-preview.8.20326.2
ASP.NET Core:                5.0.0-preview.8.20326.8


PR

Starting PR run on 'b9404b03ad150bbeb3c99b19aabf716969c5bbb5'...
| Description |     RPS | CPU (%) | Memory (MB) | Avg. Latency (ms) | Startup (ms) | Build Time (ms) | Published Size (KB) | First Request (ms) | Latency (ms) | Errors | Ratio |
| ----------- | ------- | ------- | ----------- | ----------------- | ------------ | --------------- | ------------------- | ------------------ | ------------ | ------ | ----- |
|      Before | 791,229 |      99 |          88 |              3.11 |          534 |           22045 |              120307 |             134.75 |          0.4 |      0 |  1.00 |
|       After | 798,803 |      99 |          87 |              3.24 |          503 |            6002 |              120307 |             127.88 |         0.34 |      7 |  1.01 |


@Pilchie Pilchie merged commit b446ab7 into release/5.0-preview7 Jun 27, 2020
@Pilchie Pilchie deleted the halter73/17400 branch June 27, 2020 02:49
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved API was approved in API review, it can be implemented area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-kestrel tell-mode Indicates a PR which is being merged during tell-mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants