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

Guid Generation Performance Deteriorated in 2.1 vs 2.0 on OSX #26041

Closed
conradakunga opened this issue May 1, 2018 · 9 comments
Closed

Guid Generation Performance Deteriorated in 2.1 vs 2.0 on OSX #26041

conradakunga opened this issue May 1, 2018 · 9 comments
Assignees
Labels
Milestone

Comments

@conradakunga
Copy link

Running some benchmarks on Guid Generation on OSX 10.13.4 High Sierra shows quite some performance degradation between .NET Core 2.0.6 and 2.1.0-preview2, as reported using benchmark.net

The code itself:

[Benchmark]
public Guid GenerateGuid()
{
    return Guid.NewGuid();
}

Below are the results on OSX

Method Toolchain Mean Allocated
GenerateGuid .NET Core 2.1 2,601.0 ns 0 B
GenerateGuid .NET Core 2.0 279.0 ns 0 B

Below are the results for the same benchmark on Ubuntu 16.04

Method Toolchain Mean Allocated
GenerateGuid .NET Core 2.0 9.513 us 0 B
GenerateGuid .NET Core 2.1 3.053 us 0 B

The variance between the OSX and Linux aside, what could lead to a 10x performance degradation?

@stephentoub
Copy link
Member

cc: @janvorli

@ghost
Copy link

ghost commented May 1, 2018

what could lead to a 10x performance degradation

dotnet/coreclr#16643

In 2.1, GUID is re-implemented in CoreCLR using a custom made CoCreateGuid function: https://github.com/janvorli/coreclr/blob/3b9f14d569182ac46a049965a630dfcd9e57d1dd/src/palrt/guid.cpp#L28-L48

In 2.0 is using libuuid.

@conradakunga
Copy link
Author

If we ignore the slowdown frpm 2.0 to 2.1 for a moment, is that to say Guid generation on OSX regardless of generation technique (libuuid or custom function) is inherently slow? Let me re-post the benchmark numbers with the specs of the machines I run them on, using the same versions of .NET Core 2.0. and 2.1

BenchmarkDotNet=v0.10.14, OS=macOS High Sierra 10.13.4 (17E202) [Darwin 17.5.0]
Intel Core i7-3740QM CPU 2.70GHz (Ivy Bridge), 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=2.1.300-preview2-008533
[Host] : .NET Core 2.0.6 (CoreCLR 4.6.0.0, CoreFX 4.6.26212.01), 64bit RyuJIT
Job-LGSHYZ : .NET Core 2.1.0-preview2-26406-04 (CoreCLR 4.6.26406.07, CoreFX 4.6.26406.04), 64bit RyuJIT
Job-EVVLKQ : .NET Core 2.0.6 (CoreCLR 4.6.0.0, CoreFX 4.6.26212.01), 64bit RyuJIT

Method Toolchain Mean Allocated
GenerateGuid .NET Core 2.1 2,601.0 ns 0 B
GenerateGuid .NET Core 2.0 279.0 ns 0 B

BenchmarkDotNet=v0.10.14, OS=ubuntu 16.04
Intel Core i3-4005U CPU 1.70GHz (Haswell), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=2.1.300-preview2-008533
[Host] : .NET Core 2.0.6 (CoreCLR 4.6.0.0, CoreFX 4.6.26212.01), 64bit RyuJIT
Job-DMZZXU : .NET Core 2.0.6 (CoreCLR 4.6.0.0, CoreFX 4.6.26212.01), 64bit RyuJIT
Job-WHVDVG : .NET Core 2.1.0-preview2-26406-04 (CoreCLR 4.6.26406.07, CoreFX 4.6.26406.04), 64bit RyuJIT

Method Toolchain Mean Allocated
GenerateGuid .NET Core 2.0 9.274 us 0 B
GenerateGuid .NET Core 2.1 3.043 us 0 B

Couple of things

  1. On Core 2.1 Pefrormance has actually improved 3x on the Linux box
  2. On Core 2.0 performance is ~ 30x slower on the Mac, and the Linux machine is much lower spec

@ghost
Copy link

ghost commented May 2, 2018

is that to say Guid generation on OSX ... is inherently slow

I think no. That's why this issue was marked with label bug and added to the current milestone 2.1, which means it will most like be fixed before 2.1 release.
Would be interesting to find out what is the hotpath in macOS causing this regression using micro benchmark.

@stephentoub
Copy link
Member

@janvorli is working on a fix.

@janvorli
Copy link
Member

janvorli commented May 2, 2018

Fixed

@janvorli janvorli closed this as completed May 2, 2018
@stephentoub
Copy link
Member

Re-opening to track port to release/2.1.

@stephentoub stephentoub reopened this May 2, 2018
@danmoseley
Copy link
Member

Ported

@danmoseley
Copy link
Member

Thanks @conradakunga perhaps you can try latest daily build tomorrow and confirm it's fixed?

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants