-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Optimizing ChunkingCookieManager #31625
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
Merged
12 commits merged into
dotnet:main
from
uabarahona:perf/improve-performance-ChunkingCookieManager
Apr 20, 2021
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6157a0b
Adding initial refactor to improve perfromance on ChunkingCookieManager
uabarahona 7922591
Moving new API to correct file
uabarahona 5f811cd
Adding some interface implementation for tests
uabarahona 57a9b65
Addressing feedback given by asp.net team
uabarahona 9a55381
Remove spaces
uabarahona 2a2d15a
Changing to use readonlyspan
uabarahona df9ee2f
Adding DIM as discussion point
uabarahona 7710230
CollectionMarshal
uabarahona ffb399b
Removing unnecesary implementations and fixing public api
uabarahona 3a11950
Fixing public api for different targets
uabarahona ab3e803
Addressing feedback from asp.net team
uabarahona d312bc9
Update src/Http/Http.Features/src/IResponseCookies.cs
Tratcher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
File renamed without changes.
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
247 changes: 247 additions & 0 deletions
247
src/Http/Http.Features/src/PublicAPI/net6.0/PublicAPI.Shipped.txt
Large diffs are not rendered by default.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
src/Http/Http.Features/src/PublicAPI/net6.0/PublicAPI.Unshipped.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#nullable enable | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.FeatureCollection.Set<TFeature>(TFeature instance) -> void | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IFeatureCollection.Get<TFeature>() -> TFeature | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IFeatureCollection.Set<TFeature>(TFeature instance) -> void | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IHttpBufferingFeature | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IHttpBufferingFeature.DisableRequestBuffering() -> void | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IHttpBufferingFeature.DisableResponseBuffering() -> void | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IHttpSendFileFeature | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IHttpSendFileFeature.SendFileAsync(string! path, long offset, long? count, System.Threading.CancellationToken cancellation) -> System.Threading.Tasks.Task! | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IServerVariablesFeature.this[string! variableName].get -> string! | ||
*REMOVED*Microsoft.AspNetCore.Http.ISession.TryGetValue(string! key, out byte[]! value) -> bool | ||
Microsoft.AspNetCore.Http.Features.FeatureCollection.Set<TFeature>(TFeature? instance) -> void | ||
Microsoft.AspNetCore.Http.Features.IFeatureCollection.Get<TFeature>() -> TFeature? | ||
Microsoft.AspNetCore.Http.Features.IFeatureCollection.Set<TFeature>(TFeature? instance) -> void | ||
Microsoft.AspNetCore.Http.Features.IServerVariablesFeature.this[string! variableName].get -> string? | ||
Microsoft.AspNetCore.Http.ISession.TryGetValue(string! key, out byte[]? value) -> bool | ||
Microsoft.AspNetCore.Http.Features.FeatureCollection.FeatureCollection(int initialCapacity) -> void | ||
Microsoft.AspNetCore.Http.IResponseCookies.Append(System.ReadOnlySpan<System.Collections.Generic.KeyValuePair<string!, string!>> keyValuePairs, Microsoft.AspNetCore.Http.CookieOptions! options) -> void |
247 changes: 247 additions & 0 deletions
247
src/Http/Http.Features/src/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt
Large diffs are not rendered by default.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
src/Http/Http.Features/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#nullable enable | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.FeatureCollection.Set<TFeature>(TFeature instance) -> void | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IFeatureCollection.Get<TFeature>() -> TFeature | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IFeatureCollection.Set<TFeature>(TFeature instance) -> void | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IHttpBufferingFeature | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IHttpBufferingFeature.DisableRequestBuffering() -> void | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IHttpBufferingFeature.DisableResponseBuffering() -> void | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IHttpSendFileFeature | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IHttpSendFileFeature.SendFileAsync(string! path, long offset, long? count, System.Threading.CancellationToken cancellation) -> System.Threading.Tasks.Task! | ||
*REMOVED*Microsoft.AspNetCore.Http.Features.IServerVariablesFeature.this[string! variableName].get -> string! | ||
*REMOVED*Microsoft.AspNetCore.Http.ISession.TryGetValue(string! key, out byte[]! value) -> bool | ||
Microsoft.AspNetCore.Http.Features.FeatureCollection.Set<TFeature>(TFeature? instance) -> void | ||
Microsoft.AspNetCore.Http.Features.IFeatureCollection.Get<TFeature>() -> TFeature? | ||
Microsoft.AspNetCore.Http.Features.IFeatureCollection.Set<TFeature>(TFeature? instance) -> void | ||
Microsoft.AspNetCore.Http.Features.IServerVariablesFeature.this[string! variableName].get -> string? | ||
Microsoft.AspNetCore.Http.ISession.TryGetValue(string! key, out byte[]? value) -> bool | ||
Microsoft.AspNetCore.Http.Features.FeatureCollection.FeatureCollection(int initialCapacity) -> void |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -501,4 +501,4 @@ public override byte[] Serialize(IDictionary<string, object> values) | |
} | ||
} | ||
} | ||
} | ||
} |
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
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
63 changes: 63 additions & 0 deletions
63
src/Security/perf/Microbenchmarks/ChunkingCookieManagerBenchmark.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using Microsoft.AspNetCore.Authentication.Cookies; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.Primitives; | ||
using Microsoft.Net.Http.Headers; | ||
|
||
namespace Microsoft.AspNetCore.Security | ||
{ | ||
public class ChunkingCookieManagerBenchmark | ||
{ | ||
private ChunkingCookieManager _chunkingCookieManager; | ||
private HttpContext _httpContext; | ||
private CookieOptions _cookieOptions; | ||
private string _stringToAdd; | ||
|
||
[GlobalSetup] | ||
public void GlobalSetup() | ||
{ | ||
_chunkingCookieManager = new ChunkingCookieManager() | ||
{ | ||
ChunkSize = 86 | ||
}; | ||
|
||
_httpContext = new DefaultHttpContext(); | ||
|
||
_cookieOptions = new CookieOptions() | ||
{ | ||
Domain = "foo.com", | ||
Path = "/", | ||
Secure = true | ||
}; | ||
|
||
_httpContext.Request.Headers["Cookie"] = new[] | ||
{ | ||
"TestCookie=chunks-7", | ||
"TestCookieC1=abcdefghi", | ||
"TestCookieC2=jklmnopqr", | ||
"TestCookieC3=stuvwxyz0", | ||
"TestCookieC4=123456789", | ||
"TestCookieC5=ABCDEFGHI", | ||
"TestCookieC6=JKLMNOPQR", | ||
"TestCookieC7=STUVWXYZ" | ||
}; | ||
|
||
_stringToAdd = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||
} | ||
|
||
|
||
[Benchmark] | ||
public void AppendCookies() | ||
{ | ||
_chunkingCookieManager.AppendResponseCookie(_httpContext, "TestCookie1", _stringToAdd, _cookieOptions); | ||
_httpContext.Response.Headers[HeaderNames.SetCookie] = StringValues.Empty; | ||
} | ||
|
||
[Benchmark] | ||
public void DeleteCookies() | ||
{ | ||
_chunkingCookieManager.DeleteCookie(_httpContext, "TestCookie", _cookieOptions); | ||
_httpContext.Response.Headers[HeaderNames.SetCookie] = StringValues.Empty; | ||
} | ||
} | ||
} |
7 changes: 4 additions & 3 deletions
7
src/Security/perf/Microbenchmarks/Microsoft.AspNetCore.Security.Microbenchmarks.csproj
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.