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

net7.0 & C# style improvements #158

Merged
merged 6 commits into from
Feb 4, 2023
Merged

Conversation

CoreyKaylor
Copy link
Owner

Summary of PR:

  • Added usage of LibraryImport when targeting net7.0
  • Marshall environment name string as UTF-8 with the LibraryImport options
  • Using nint throughout over previous IntPtr
  • File-scoped namespaces
  • Fixed test being excluded on Linux for using environment from multi-process
  • Corrected numerous inconsistencies and analysis warnings where it made sense

Are there other language features this library would benefit from that I missed?

I'm going to run the benchmarks out of curiosity to see the differences between net6.0, net7.0 (master), and net7.0 (net7-csharp-improvements)

@CoreyKaylor
Copy link
Owner Author

(master) net6.0 READ

BenchmarkDotNet=v0.12.1, OS=macOS 13.2 (22D49) [Darwin 22.3.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET Core SDK=7.0.102
  [Host]     : .NET Core 6.0.13 (CoreCLR 6.0.1322.58009, CoreFX 6.0.1322.58009), Arm64 RyuJIT
  DefaultJob : .NET Core 6.0.13 (CoreCLR 6.0.1322.58009, CoreFX 6.0.1322.58009), Arm64 RyuJIT

Method OpsPerTransaction ValueSize KeyOrder Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Read 1 8 Sequential 340.3 ns 2.02 ns 1.89 ns 0.1450 - - 304 B
Read 1 64 Sequential 338.7 ns 3.52 ns 3.30 ns 0.1450 - - 304 B
Read 1 256 Sequential 336.6 ns 3.42 ns 3.03 ns 0.1450 - - 304 B
Read 100 8 Sequential 8,187.4 ns 11.03 ns 10.31 ns 0.1373 - - 304 B
Read 100 64 Sequential 8,129.8 ns 15.42 ns 14.42 ns 0.1373 - - 304 B
Read 100 256 Sequential 8,566.1 ns 22.25 ns 18.58 ns 0.1373 - - 304 B
Read 1000 8 Sequential 116,099.3 ns 439.43 ns 389.55 ns 0.1221 - - 304 B
Read 1000 64 Sequential 124,493.6 ns 293.72 ns 274.75 ns - - - 304 B
Read 1000 256 Sequential 132,650.8 ns 308.18 ns 273.20 ns - - - 304 B

@CoreyKaylor
Copy link
Owner Author

(master) net6.0 WRITE

BenchmarkDotNet=v0.12.1, OS=macOS 13.2 (22D49) [Darwin 22.3.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET Core SDK=7.0.102
  [Host]     : .NET Core 6.0.13 (CoreCLR 6.0.1322.58009, CoreFX 6.0.1322.58009), Arm64 RyuJIT
  DefaultJob : .NET Core 6.0.13 (CoreCLR 6.0.1322.58009, CoreFX 6.0.1322.58009), Arm64 RyuJIT

Method OpsPerTransaction ValueSize KeyOrder Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Write 1 8 Sequential 50.64 μs 0.836 μs 0.741 μs 0.1221 - - 304 B
Write 1 64 Sequential 50.14 μs 0.226 μs 0.212 μs 0.1221 - - 304 B
Write 1 256 Sequential 50.33 μs 0.509 μs 0.425 μs 0.1221 - - 304 B
Write 100 8 Sequential 59.25 μs 0.324 μs 0.271 μs 0.1221 - - 304 B
Write 100 64 Sequential 60.11 μs 0.334 μs 0.296 μs 0.1221 - - 304 B
Write 100 256 Sequential 71.69 μs 0.870 μs 0.814 μs 0.1221 - - 304 B
Write 1000 8 Sequential 195.10 μs 0.589 μs 0.492 μs - - - 304 B
Write 1000 64 Sequential 232.84 μs 1.007 μs 0.893 μs - - - 304 B
Write 1000 256 Sequential 25.15 μs 0.030 μs 0.027 μs 0.1221 - - 304 B

@CoreyKaylor
Copy link
Owner Author

(master) net7.0 READ

BenchmarkDotNet=v0.12.1, OS=macOS 13.2 (22D49) [Darwin 22.3.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET Core SDK=7.0.102
  [Host]     : .NET Core 7.0.2 (CoreCLR 7.0.222.60605, CoreFX 7.0.222.60605), Arm64 RyuJIT
  DefaultJob : .NET Core 7.0.2 (CoreCLR 7.0.222.60605, CoreFX 7.0.222.60605), Arm64 RyuJIT

Method OpsPerTransaction ValueSize KeyOrder Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Read 1 8 Sequential 210.6 ns 0.71 ns 0.66 ns 0.0484 - - 304 B
Read 1 64 Sequential 207.3 ns 3.04 ns 2.85 ns 0.0484 - - 304 B
Read 1 256 Sequential 200.3 ns 2.29 ns 2.03 ns 0.0484 - - 304 B
Read 100 8 Sequential 8,171.7 ns 18.80 ns 17.59 ns 0.0458 - - 304 B
Read 100 64 Sequential 8,036.6 ns 17.22 ns 15.26 ns 0.0458 - - 304 B
Read 100 256 Sequential 8,593.7 ns 16.99 ns 14.19 ns 0.0458 - - 304 B
Read 1000 8 Sequential 116,029.8 ns 201.47 ns 188.45 ns - - - 304 B
Read 1000 64 Sequential 124,566.1 ns 320.33 ns 299.64 ns - - - 304 B
Read 1000 256 Sequential 132,605.0 ns 401.22 ns 375.30 ns - - - 304 B

@CoreyKaylor
Copy link
Owner Author

(master) net7.0 WRITE

BenchmarkDotNet=v0.12.1, OS=macOS 13.2 (22D49) [Darwin 22.3.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET Core SDK=7.0.102
  [Host]     : .NET Core 7.0.2 (CoreCLR 7.0.222.60605, CoreFX 7.0.222.60605), Arm64 RyuJIT
  DefaultJob : .NET Core 7.0.2 (CoreCLR 7.0.222.60605, CoreFX 7.0.222.60605), Arm64 RyuJIT

Method OpsPerTransaction ValueSize KeyOrder Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Write 1 8 Sequential 50.44 μs 0.442 μs 0.414 μs - - - 304 B
Write 1 64 Sequential 50.35 μs 0.261 μs 0.256 μs - - - 304 B
Write 1 256 Sequential 50.02 μs 0.354 μs 0.314 μs - - - 304 B
Write 100 8 Sequential 59.23 μs 0.506 μs 0.422 μs - - - 304 B
Write 100 64 Sequential 60.41 μs 1.147 μs 1.017 μs - - - 304 B
Write 100 256 Sequential 71.16 μs 0.668 μs 0.625 μs - - - 304 B
Write 1000 8 Sequential 193.64 μs 0.866 μs 0.723 μs - - - 304 B
Write 1000 64 Sequential 227.80 μs 0.838 μs 0.743 μs - - - 304 B
Write 1000 256 Sequential 24.33 μs 0.057 μs 0.050 μs 0.0305 - - 304 B

@CoreyKaylor
Copy link
Owner Author

(net7-csharp-improvements) net7.0 READ

BenchmarkDotNet=v0.12.1, OS=macOS 13.2 (22D49) [Darwin 22.3.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET Core SDK=7.0.102
  [Host]     : .NET Core 7.0.2 (CoreCLR 7.0.222.60605, CoreFX 7.0.222.60605), Arm64 RyuJIT
  DefaultJob : .NET Core 7.0.2 (CoreCLR 7.0.222.60605, CoreFX 7.0.222.60605), Arm64 RyuJIT

Method OpsPerTransaction ValueSize KeyOrder Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Read 1 8 Sequential 211.1 ns 1.32 ns 1.24 ns 0.0484 - - 304 B
Read 1 64 Sequential 205.5 ns 3.08 ns 2.88 ns 0.0484 - - 304 B
Read 1 256 Sequential 206.2 ns 2.88 ns 2.69 ns 0.0484 - - 304 B
Read 100 8 Sequential 7,944.8 ns 25.29 ns 19.74 ns 0.0458 - - 304 B
Read 100 64 Sequential 7,955.4 ns 19.95 ns 18.66 ns 0.0458 - - 304 B
Read 100 256 Sequential 8,559.4 ns 17.13 ns 16.02 ns 0.0458 - - 304 B
Read 1000 8 Sequential 115,440.9 ns 135.02 ns 119.70 ns - - - 304 B
Read 1000 64 Sequential 123,140.9 ns 588.45 ns 550.44 ns - - - 304 B
Read 1000 256 Sequential 131,738.7 ns 431.69 ns 382.68 ns - - - 304 B

@CoreyKaylor
Copy link
Owner Author

(net7-csharp-improvements) net7.0 WRITE

BenchmarkDotNet=v0.12.1, OS=macOS 13.2 (22D49) [Darwin 22.3.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET Core SDK=7.0.102
  [Host]     : .NET Core 7.0.2 (CoreCLR 7.0.222.60605, CoreFX 7.0.222.60605), Arm64 RyuJIT
  DefaultJob : .NET Core 7.0.2 (CoreCLR 7.0.222.60605, CoreFX 7.0.222.60605), Arm64 RyuJIT

Method OpsPerTransaction ValueSize KeyOrder Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Write 1 8 Sequential 50.71 μs 0.970 μs 0.908 μs - - - 304 B
Write 1 64 Sequential 50.25 μs 0.585 μs 0.489 μs - - - 304 B
Write 1 256 Sequential 50.40 μs 0.574 μs 0.448 μs - - - 304 B
Write 100 8 Sequential 59.59 μs 0.350 μs 0.292 μs - - - 304 B
Write 100 64 Sequential 60.01 μs 0.367 μs 0.325 μs - - - 304 B
Write 100 256 Sequential 71.29 μs 0.936 μs 0.830 μs - - - 304 B
Write 1000 8 Sequential 194.27 μs 3.038 μs 2.693 μs - - - 304 B
Write 1000 64 Sequential 232.27 μs 1.020 μs 0.852 μs - - - 304 B
Write 1000 256 Sequential 24.14 μs 0.042 μs 0.037 μs 0.0305 - - 304 B

@CoreyKaylor CoreyKaylor merged commit 74df69f into master Feb 4, 2023
@CoreyKaylor CoreyKaylor deleted the net7-csharp-improvements branch February 4, 2023 15:54
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.

None yet

1 participant