-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
Perfapi-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-signalrIncludes: SignalR clients and serversIncludes: SignalR clients and serversold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Milestone
Description
Background and Motivation
Looking at profiles for one of my SignalR applications I see lots of string allocations showing up and most of them seem to come from the protocol implementation:
It's:
- Hub method names
Invocation idsNot worth it unless we could optimize the number path and never allocate them.
We end up invoking these methods over and over and allocating the same strings for both invocation ids (numbers in our clients) and for hub method names (which are known at startup).
We should be using cached strings for these. Right now we don't have a clean extensibility model to inject this behavior. Maybe we can add something to the options.
Proposed API
namespace Microsoft.AspNetCore.SignalR;
public interface IInvocationBinder
{
+ #if NETCOREAPP
+ string? GetTarget(ReadOnlySpan<byte> utf8Bytes) => null;
+ #endif
}Usage Examples
Called by SignalR protocols to get the cached hub name from the binder (if there exists any).
Alternative Designs
An alternative would be a new interface that can be optionally implemented on the IInvocationBinder:
public interface ITargetResolver
{
string? GetTarget(ReadOnlySpan<byte> utf8Bytes);
}
Risks
None
Metadata
Metadata
Assignees
Labels
Perfapi-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-signalrIncludes: SignalR clients and serversIncludes: SignalR clients and serversold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
