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

micro-optimizations in ProtocolWriter #329

Merged
merged 3 commits into from Jan 12, 2024
Merged

micro-optimizations in ProtocolWriter #329

merged 3 commits into from Jan 12, 2024

Conversation

caleblloyd
Copy link
Contributor

@caleblloyd caleblloyd commented Jan 12, 2024

Resolves #319

New MicroBenchmark shows benefit in writing UInt 16/32/64. Maybe because I am on a newer CPU on this box? 🤷‍♂️ Looks like it is worth changing though


BenchmarkDotNet v0.13.12, Ubuntu 22.04.3 LTS (Jammy Jellyfish)
AMD Ryzen 5 3600, 1 CPU, 12 logical and 6 physical cores
.NET SDK 8.0.101
  [Host]   : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2
  ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2

Job=ShortRun  IterationCount=3  LaunchCount=1  
WarmupCount=3  

Method Iter Size Mean Error StdDev Allocated
PubCopy 1000000 2 368.9 μs 109.60 μs 6.01 μs -
PubSetIndex 1000000 2 485.2 μs 59.42 μs 3.26 μs -
PubBinaryConst 1000000 2 245.7 μs 18.84 μs 1.03 μs -
PubBinaryReadonly 1000000 2 242.5 μs 56.04 μs 3.07 μs -
PubCopy 1000000 4 483.8 μs 72.14 μs 3.95 μs -
PubSetIndex 1000000 4 969.0 μs 42.56 μs 2.33 μs 1 B
PubBinaryConst 1000000 4 247.9 μs 94.50 μs 5.18 μs -
PubBinaryReadonly 1000000 4 244.6 μs 19.72 μs 1.08 μs -
PubCopy 1000000 8 495.1 μs 107.94 μs 5.92 μs -
PubSetIndex 1000000 8 1,916.3 μs 7.41 μs 0.41 μs 1 B
PubBinaryConst 1000000 8 366.2 μs 87.33 μs 4.79 μs -
PubBinaryReadonly 1000000 8 368.6 μs 128.24 μs 7.03 μs -

Also added Throw Helper to Protocol Writer as suggested in #320

Signed-off-by: Caleb Lloyd <caleb@synadia.com>
Copy link
Collaborator

@mtmk mtmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Caleb Lloyd <caleb@synadia.com>
Signed-off-by: Caleb Lloyd <caleb@synadia.com>
@mtmk mtmk merged commit 1bdf319 into main Jan 12, 2024
8 of 9 checks passed
@mtmk mtmk deleted the send-micro-optimizations branch January 12, 2024 18:12
@mtmk mtmk mentioned this pull request Jan 12, 2024
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.

Benchmark command buffer writes
2 participants