Skip to content

Avoid OrderedIterator when comparing OpenApiSchema.Required equality #57298

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

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

captainsafia
Copy link
Member

Contributes towards #56829.

Required properties in an OpenAPI schema represented in an ISet. Previously, to support order-invariant comparisons we were using .Order() and .SequenceEquals().

It turns out .SetEquals() exists and is order invariant so we can use that directly instead of constructing an OrderedIterator via the Order call.

The SetEquals method ignores duplicate entries and the order of elements in the other parameter.
-- SetEquals API Remarks

Results from a local benchmark run are below:

BenchmarkDotNet v0.13.12, macOS Sonoma 14.6.1 (23G93) [Darwin 23.6.0]
Apple M2 Max, 1 CPU, 12 logical and 12 physical cores
.NET SDK 9.0.100-preview.7.24371.4
[Host] : .NET 9.0.0 (9.0.24.41005), Arm64 RyuJIT AdvSIMD
Job-JUVRYQ : .NET 9.0.0 (9.0.24.36618), Arm64 RyuJIT AdvSIMD

Server=True Toolchain=.NET Core 9.0 RunStrategy=Throughput

Before

Method EndpointCount Mean Error StdDev Op/s Gen0 Gen1 Allocated
GenerateDocument 10 316.7 μs 6.20 μs 6.09 μs 3,157.61 3.9063 - 586.53 KB
GenerateDocument 100 3,066.2 μs 58.45 μs 51.82 μs 326.14 31.2500 - 5336.09 KB
GenerateDocument 1000 32,198.7 μs 387.17 μs 343.22 μs 31.06 333.3333 166.6667 52828.55 KB

After

Server=True Toolchain=.NET Core 9.0 RunStrategy=Throughput

Method EndpointCount Mean Error StdDev Op/s Gen0 Gen1 Allocated
GenerateDocument 10 300.1 μs 0.73 μs 0.65 μs 3,331.88 3.9063 - 538.06 KB
GenerateDocument 100 2,776.9 μs 22.87 μs 21.39 μs 360.11 31.2500 15.6250 4891 KB
GenerateDocument 1000 30,593.4 μs 595.03 μs 636.68 μs 32.69 166.6667 - 48415.86 KB

@captainsafia captainsafia requested a review from a team as a code owner August 13, 2024 03:29
@ghost ghost added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Aug 13, 2024
@captainsafia captainsafia enabled auto-merge (squash) August 13, 2024 04:47
@captainsafia captainsafia merged commit 19ffc77 into main Aug 13, 2024
26 checks passed
@captainsafia captainsafia deleted the oai-comp-perf branch August 13, 2024 14:22
@dotnet-policy-service dotnet-policy-service bot added this to the 9.0-rc1 milestone Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants