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

C# write benchmark improvements #7658

Conversation

jtattermusch
Copy link
Contributor

  • target netcoreapp3.1 (the newest LTS of .NET core)
  • add a few more useful write benchmarks
  • use BinaryPrimitives.WriteUInt64LittleEndian for writing fixed64 values as starting from .NET Core 3.x, this is much faster than the current workaround.

Changes are mostly taken from JamesNK@337780c (as recommended here #7576 (comment) for more context). Thanks @JamesNK for the improvements!

@jtattermusch
Copy link
Contributor Author

@JamesNK can you please review?

@jtattermusch jtattermusch force-pushed the csharp_benchmark_improvements branch from 6917092 to c582db8 Compare June 29, 2020 07:59
@jtattermusch
Copy link
Contributor Author

Comparison for using BinaryPrimitives.WriteUInt64LittleEndian on .NET Core 3.1

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18362.900 (1903/May2019Update/19H1)
Intel Core i7-7600U CPU 2.80GHz (Kaby Lake), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=3.1.301
  [Host]     : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  DefaultJob : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT

BEFORE:

|                    Method | BytesToWrite |     Mean |    Error |   StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|-------------------------- |------------- |---------:|---------:|---------:|------:|------:|------:|----------:|
| WriteFixed64_WriteContext |        10080 | 14.97 us | 0.156 us | 0.138 us |     - |     - |     - |         - |

AFTER:

|                    Method | BytesToWrite |     Mean |     Error |    StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|-------------------------- |------------- |---------:|----------:|----------:|------:|------:|------:|----------:|
| WriteFixed64_WriteContext |        10080 | 3.097 us | 0.0603 us | 0.1071 us |     - |     - |     - |         - |

@jtattermusch
Copy link
Contributor Author

the CI doesn't have a new-enough version of the SDK (which is something that would need to be fixed first).

dotnet restore csharp/src/Google.Protobuf.sln
/root/.dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(127,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1.  Either target .NET Core 3.0 or lower, or use a version of the .NET SDK that supports .NET Core 3.1. [/tmp/protobuf/protobuf/csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj]

@JamesNK
Copy link
Contributor

JamesNK commented Jun 30, 2020

Opps, I saw 3.x in global.json and assumed it was 3.1.

Build should update to 3.1. It is a LTS release. 3.0 is no longer supported.

@jtattermusch jtattermusch force-pushed the csharp_benchmark_improvements branch from c582db8 to 45c8850 Compare July 1, 2020 05:53
@jtattermusch jtattermusch merged commit 62cf7c6 into protocolbuffers:master Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants