-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Faster strongly typed features for server FeatureCollection #31322
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
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d3be961
Use strongly typed features
benaadams d000e05
Use Unsafe.As to workaround dotnet/runtime#49614
benaadams 675d0b6
Do the casting it for Set<T> as well
benaadams c064ac0
Add more benchmarks
benaadams d5b832d
Better benchmarks
benaadams b5dadd8
Rearrange features
benaadams 138f8b5
Reorder features (order of reset); bump up IRequestBodyPipeFeature
benaadams cba981f
Move interface implement on class to generated (to match order)
benaadams 413bc5b
Remove skip features (always null)
benaadams 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
169 changes: 84 additions & 85 deletions
169
src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.Generated.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -14,11 +14,11 @@ namespace Microsoft.AspNetCore.Connections | |
{ | ||
internal partial class TransportMultiplexedConnection : IFeatureCollection | ||
{ | ||
private object? _currentIConnectionIdFeature; | ||
private object? _currentIConnectionTransportFeature; | ||
private object? _currentIConnectionItemsFeature; | ||
private object? _currentIMemoryPoolFeature; | ||
private object? _currentIConnectionLifetimeFeature; | ||
internal protected IConnectionIdFeature? _currentIConnectionIdFeature; | ||
internal protected IConnectionTransportFeature? _currentIConnectionTransportFeature; | ||
internal protected IConnectionItemsFeature? _currentIConnectionItemsFeature; | ||
internal protected IMemoryPoolFeature? _currentIMemoryPoolFeature; | ||
internal protected IConnectionLifetimeFeature? _currentIConnectionLifetimeFeature; | ||
|
||
private int _featureRevision; | ||
|
||
|
@@ -27,11 +27,11 @@ internal partial class TransportMultiplexedConnection : IFeatureCollection | |
private void FastReset() | ||
{ | ||
_currentIConnectionIdFeature = this; | ||
_currentIConnectionTransportFeature = this; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was an impossible cast; however since they were |
||
_currentIConnectionItemsFeature = this; | ||
_currentIMemoryPoolFeature = this; | ||
_currentIConnectionLifetimeFeature = this; | ||
|
||
_currentIConnectionTransportFeature = null; | ||
} | ||
|
||
// Internal for testing | ||
|
@@ -137,23 +137,23 @@ private void ExtraFeatureSet(Type key, object? value) | |
|
||
if (key == typeof(IConnectionIdFeature)) | ||
{ | ||
_currentIConnectionIdFeature = value; | ||
_currentIConnectionIdFeature = (IConnectionIdFeature?)value; | ||
} | ||
else if (key == typeof(IConnectionTransportFeature)) | ||
{ | ||
_currentIConnectionTransportFeature = value; | ||
_currentIConnectionTransportFeature = (IConnectionTransportFeature?)value; | ||
} | ||
else if (key == typeof(IConnectionItemsFeature)) | ||
{ | ||
_currentIConnectionItemsFeature = value; | ||
_currentIConnectionItemsFeature = (IConnectionItemsFeature?)value; | ||
} | ||
else if (key == typeof(IMemoryPoolFeature)) | ||
{ | ||
_currentIMemoryPoolFeature = value; | ||
_currentIMemoryPoolFeature = (IMemoryPoolFeature?)value; | ||
} | ||
else if (key == typeof(IConnectionLifetimeFeature)) | ||
{ | ||
_currentIConnectionLifetimeFeature = value; | ||
_currentIConnectionLifetimeFeature = (IConnectionLifetimeFeature?)value; | ||
} | ||
else | ||
{ | ||
|
@@ -198,23 +198,23 @@ private void ExtraFeatureSet(Type key, object? value) | |
_featureRevision++; | ||
if (typeof(TFeature) == typeof(IConnectionIdFeature)) | ||
{ | ||
_currentIConnectionIdFeature = feature; | ||
_currentIConnectionIdFeature = (IConnectionIdFeature?)feature; | ||
} | ||
else if (typeof(TFeature) == typeof(IConnectionTransportFeature)) | ||
{ | ||
_currentIConnectionTransportFeature = feature; | ||
_currentIConnectionTransportFeature = (IConnectionTransportFeature?)feature; | ||
} | ||
else if (typeof(TFeature) == typeof(IConnectionItemsFeature)) | ||
{ | ||
_currentIConnectionItemsFeature = feature; | ||
_currentIConnectionItemsFeature = (IConnectionItemsFeature?)feature; | ||
} | ||
else if (typeof(TFeature) == typeof(IMemoryPoolFeature)) | ||
{ | ||
_currentIMemoryPoolFeature = feature; | ||
_currentIMemoryPoolFeature = (IMemoryPoolFeature?)feature; | ||
} | ||
else if (typeof(TFeature) == typeof(IConnectionLifetimeFeature)) | ||
{ | ||
_currentIConnectionLifetimeFeature = feature; | ||
_currentIConnectionLifetimeFeature = (IConnectionLifetimeFeature?)feature; | ||
} | ||
else | ||
{ | ||
|
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benaadams shouldn't the unsafe cast be here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its the
this[Type key] = object
version; so can't guaranteevalue
is the correct type so Unsafe cast here would be badThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It occurs to me that we had this bug today where you could basically store anything in here and it would explode on get