Cysharp / MagicOnion

Unified Realtime/API framework for .NET platform and Unity.
MIT License
3.68k stars 417 forks source link

Object pooling on StreamingHub #774

Closed mayuki closed 1 month ago

mayuki commented 1 month ago

This PR makes aggressive use of object pooling in the StreamingHub to reduce memory and object allocation.

Results

Call StreamingHub method / 10 seconds

dotnet run -c Release --no-build -- -u http://localhost:5000 -s StreamingHubComplex

Before

image

After

image

Name Baseline PR Ratio
Memory allocation 699.36 MB 264.66 MB 0.37
Objects allocation 6.01 M 3.02 M 0.5

[!NOTE] At first glance, the rps (requests/sec) values look better in After, but the accuracy of the rps measurement is not guaranteed and is therefore ignored this time.