akkadotnet / Alpakka

Akka Streams Connectors - Alpakka
https://alpakka.getakka.net/
Apache License 2.0
108 stars 40 forks source link

Minor read-side RabbitMQ perf optimization #1905

Closed Aaronontheweb closed 3 months ago

Aaronontheweb commented 3 months ago

Changes

The BIG improvements will come from making ByteString less bad inside Akka.NET, as there is a TON of memory copying that is unecessary right now.

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Latest dev Benchmarks

BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3296/23H2/2023Update/SunValley3)
12th Gen Intel Core i7-1260P, 1 CPU, 16 logical and 12 physical cores
.NET SDK 8.0.101
  [Host]     : .NET 6.0.26 (6.0.2623.60508), X64 RyuJIT AVX2
  Job-WOEZAU : .NET 6.0.26 (6.0.2623.60508), X64 RyuJIT AVX2

InvocationCount=1  IterationCount=10  RunStrategy=ColdStart  
UnrollFactor=1  WarmupCount=0  
Method Mean Error StdDev Gen0 Allocated
RabbitMqReadFlow 87.19 μs 5.047 μs 3.338 μs 0.1700 1.56 KB

This PR's Benchmarks


BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3296/23H2/2023Update/SunValley3)
12th Gen Intel Core i7-1260P, 1 CPU, 16 logical and 12 physical cores
.NET SDK 8.0.101
  [Host]     : .NET 6.0.26 (6.0.2623.60508), X64 RyuJIT AVX2
  Job-NDZWOM : .NET 6.0.26 (6.0.2623.60508), X64 RyuJIT AVX2

InvocationCount=1  IterationCount=10  RunStrategy=ColdStart  
UnrollFactor=1  WarmupCount=0  
Method Mean Error StdDev Gen0 Allocated
RabbitMqReadFlow 104.7 μs 28.80 μs 19.05 μs 0.1600 1.53 KB

Ignore the mean perf number - I was focused solely on memory allocs here and was doing a ton of other work in the background. Those numbers are not reliable.