Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mqtt311Decoder: use ImmutableList.Builder #186

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

Aaronontheweb
Copy link
Member

Fewer object allocations during packet parsing this way

@Aaronontheweb
Copy link
Member Author

dev


BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4037/23H2/2023Update/SunValley3)
12th Gen Intel Core i7-1260P, 1 CPU, 16 logical and 12 physical cores
.NET SDK 8.0.302
  [Host]     : .NET 8.0.6 (8.0.624.26715), X64 RyuJIT AVX2
  Job-GKHTFW : .NET 8.0.6 (8.0.624.26715), X64 RyuJIT AVX2

InvocationCount=1  LaunchCount=10  RunStrategy=Monitoring  
UnrollFactor=1  WarmupCount=10  

Method QoSLevel PayloadSizeBytes ProtocolVersion Mean Error StdDev Median Req/sec
PublishAndReceiveMessages AtMostOnce 10 V3_1_1 3.519 μs 0.7376 μs 2.175 μs 2.758 μs 284,182.50
PublishAndReceiveMessages AtMostOnce 1024 V3_1_1 3.811 μs 0.6556 μs 1.933 μs 3.095 μs 262,409.13
PublishAndReceiveMessages AtMostOnce 2048 V3_1_1 4.430 μs 0.6173 μs 1.820 μs 3.831 μs 225,738.78
PublishAndReceiveMessages AtMostOnce 8192 V3_1_1 13.250 μs 2.4129 μs 7.114 μs 9.620 μs 75,470.25
PublishAndReceiveMessages AtLeastOnce 10 V3_1_1 23.111 μs 1.9651 μs 5.794 μs 24.182 μs 43,268.72
PublishAndReceiveMessages AtLeastOnce 1024 V3_1_1 23.023 μs 1.9696 μs 5.807 μs 24.033 μs 43,434.29
PublishAndReceiveMessages AtLeastOnce 2048 V3_1_1 27.093 μs 2.9436 μs 8.679 μs 28.678 μs 36,910.36
PublishAndReceiveMessages AtLeastOnce 8192 V3_1_1 32.266 μs 2.3566 μs 6.948 μs 32.402 μs 30,991.97
PublishAndReceiveMessages ExactlyOnce 10 V3_1_1 42.754 μs 2.3814 μs 7.022 μs 40.309 μs 23,389.38
PublishAndReceiveMessages ExactlyOnce 1024 V3_1_1 41.514 μs 1.9078 μs 5.625 μs 39.755 μs 24,088.12
PublishAndReceiveMessages ExactlyOnce 2048 V3_1_1 40.881 μs 5.7051 μs 16.822 μs 40.495 μs 24,461.15
PublishAndReceiveMessages ExactlyOnce 8192 V3_1_1 52.581 μs 2.4027 μs 7.084 μs 51.804 μs 19,018.14

This PR


BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4037/23H2/2023Update/SunValley3)
12th Gen Intel Core i7-1260P, 1 CPU, 16 logical and 12 physical cores
.NET SDK 8.0.302
  [Host]     : .NET 8.0.6 (8.0.624.26715), X64 RyuJIT AVX2
  Job-XKOQDD : .NET 8.0.6 (8.0.624.26715), X64 RyuJIT AVX2

InvocationCount=1  LaunchCount=10  RunStrategy=Monitoring  
UnrollFactor=1  WarmupCount=10  

Method QoSLevel PayloadSizeBytes ProtocolVersion Mean Error StdDev Median Req/sec
PublishAndReceiveMessages AtMostOnce 10 V3_1_1 3.776 μs 0.7134 μs 2.103 μs 2.993 μs 264,832.54
PublishAndReceiveMessages AtMostOnce 1024 V3_1_1 3.528 μs 0.6014 μs 1.773 μs 2.803 μs 283,415.14
PublishAndReceiveMessages AtMostOnce 2048 V3_1_1 4.319 μs 0.6248 μs 1.842 μs 3.870 μs 231,522.29
PublishAndReceiveMessages AtMostOnce 8192 V3_1_1 14.125 μs 2.9633 μs 8.737 μs 10.495 μs 70,798.58
PublishAndReceiveMessages AtLeastOnce 10 V3_1_1 25.145 μs 1.2204 μs 3.598 μs 24.535 μs 39,768.96
PublishAndReceiveMessages AtLeastOnce 1024 V3_1_1 22.786 μs 1.8937 μs 5.584 μs 24.131 μs 43,885.74
PublishAndReceiveMessages AtLeastOnce 2048 V3_1_1 27.929 μs 1.5958 μs 4.705 μs 28.190 μs 35,805.37
PublishAndReceiveMessages AtLeastOnce 8192 V3_1_1 28.807 μs 2.5123 μs 7.408 μs 28.615 μs 34,713.84
PublishAndReceiveMessages ExactlyOnce 10 V3_1_1 39.247 μs 2.3468 μs 6.920 μs 39.792 μs 25,479.42
PublishAndReceiveMessages ExactlyOnce 1024 V3_1_1 39.877 μs 2.1262 μs 6.269 μs 38.985 μs 25,077.39
PublishAndReceiveMessages ExactlyOnce 2048 V3_1_1 43.217 μs 3.9505 μs 11.648 μs 42.917 μs 23,139.00
PublishAndReceiveMessages ExactlyOnce 8192 V3_1_1 51.701 μs 2.3448 μs 6.914 μs 49.587 μs 19,341.96

Looks like about even to me, which isn't a surprise. We should probably add a benchmark that looks at the overhead of decoding multiple packets - that'd be a "cleaner" way of capturing this information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant