Skip to content

Conversation

@vcsjones
Copy link
Member

@vcsjones vcsjones commented Apr 19, 2021

The Apple API offers significant performance improvements (an order of magnitude) over reading from /dev/urandom.

Closes #50897

BenchmarkDotNet=v0.12.1.20210419-develop, OS=macOS Big Sur 11.2.3 (20D91) [Darwin 20.3.0]
Intel Core i7-8700B CPU 3.20GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
.NET SDK=6.0.100-preview.3.21202.5
[Host] : .NET 6.0.0 (6.0.21.20104), X64 RyuJIT
Job-JBYKHU : .NET 6.0.0 (42.42.42.42424), X64 RyuJIT
Job-LIKOBM : .NET 6.0.0 (42.42.42.42424), X64 RyuJIT

Method Job Toolchain Mean Error StdDev Ratio Gen 0 Gen 1 Gen 2 Allocated
NewGuid Job-JBYKHU branch 76.92 ns 1.553 ns 1.376 ns 0.12 - - - -
NewGuid Job-LIKOBM main @ ccc47f5 615.33 ns 9.879 ns 9.241 ns 1.00 - - - -

Benchmark code is available at https://github.com/vcsjones/DotNetCryptoBenches/blob/610b5b2c9865e9fa27b7834ce0dcd0666d776e4d/src/RngBench.cs

/cc @GrabYourPitchforks @jkotas

…Bytes.

The Apple API offers significant performance improvements (an order of a magnitude) over
reading from /dev/urandom.
@ghost
Copy link

ghost commented Apr 19, 2021

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Nice.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Looks great. Thank you!

@ghost
Copy link

ghost commented Apr 20, 2021

Hello @jkotas!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@vcsjones
Copy link
Member Author

I think the build is wedged.

@jkotas
Copy link
Member

jkotas commented Apr 21, 2021

This does not affect browser, ignoring runtime-staging Browser leg.

@jkotas jkotas merged commit 81f6bf3 into dotnet:main Apr 21, 2021
@vcsjones vcsjones deleted the guid-perf branch April 21, 2021 01:34
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Guid.CreateNew() has regressed a lot on macOS

6 participants