dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.19k stars 9.93k forks source link

SignalR per-invocation allocations #41343

Open davidfowl opened 2 years ago

davidfowl commented 2 years ago

I'm building a game that requires low latency and there's some SignalR overhead (that's pretty low tbh) but impossible to get rid of. The game I'm building is sending LOTS of messages (60 FPS) so these are now the top allocations remaining.

Some of them we can't remove, we might be able to pool objects but others we should leave alone. The ones I am interested in improving:

Type Allocations Bytes Average Size (Bytes)
 - System.Runtime.CompilerServices.AsyncTaskMethodBuilder\<>.AsyncStateMachineBox\<> 2,418 477,152 197.33
 - System.Object[] 1,659 53,928 32.51
 - Microsoft.AspNetCore.SignalR.Protocol.InvocationMessage 1,631 91,336 56
 - System.String 1,629 54,420 33.41
 - System.Byte[] 862 302,374 350.78
 - System.Collections.Concurrent.ConcurrentDictionary\<,>.Enumerator 858 55,040 64.15
 - Microsoft.AspNetCore.SignalR.SerializedHubMessage 825 72,600 88
 - System.Object 825 19,800 24
 - System.Int32[] 808 29,196 36.13
 - System.Collections.Generic.List\<> 808 25,856 32
 - System.Collections.Generic.Dictionary\<,>.Entry[] 806 96,720 120
 - System.Collections.Generic.Dictionary\<,> 806 64,480 80
 - BombRMan.Hubs.GameServer 806 45,136 56
 - Microsoft.AspNetCore.SignalR.Protocol.CompletionMessage 806 45,136 56
 - Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope 806 38,688 48
 - Microsoft.AspNetCore.SignalR.Internal.DefaultHubActivator\<BombRMan.Hubs.GameServer> 806 25,792 32
ghost commented 2 years ago

Thanks for contacting us.

We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost commented 1 year ago

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

davidfowl commented 1 year ago

We should be able to reduce the enumerator allocations with pooling (https://github.com/dotnet/runtime/pull/38296)