Cysharp / MagicOnion

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

Object pooling on StreamingHub #774

Closed mayuki closed 6 months ago

mayuki commented 6 months 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.