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

Avoid static overhead for switch-over-string optimization #69673

Merged
merged 6 commits into from
Sep 20, 2023

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Aug 23, 2023

Fixes AB#1874059

Baseline

BenchmarkDotNet=v0.13.0, OS=Windows 10.0.22621
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
.NET SDK=8.0.100-preview.7.23376.3
  [Host]     : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT
  Job-SDXWZP : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT

InvocationCount=1  RunStrategy=Throughput  UnrollFactor=1
Method SwitchCount Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
BindFile 100 21.11 ms 0.407 ms 0.380 ms - - - 3 MB
BindFile 1000 472.88 ms 9.296 ms 9.130 ms 21000.0000 8000.0000 1000.0000 125 MB
BindFile 5000 10,243.52 ms 52.573 ms 49.177 ms 292000.0000 45000.0000 4000.0000 2,746 MB
BindFile 10000 45,215.70 ms 583.825 ms 546.110 ms 1042000.0000 74000.0000 5000.0000 11,298 MB

Avoid retaining large arrays with few elements

BenchmarkDotNet=v0.13.0, OS=Windows 10.0.22621
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
.NET SDK=8.0.100-preview.7.23376.3
  [Host]     : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT
  Job-CLGAKY : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT

InvocationCount=1  RunStrategy=Throughput  UnrollFactor=1
Method SwitchCount Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
BindFile 100 21.07 ms 0.416 ms 0.541 ms - - - 3 MB
BindFile 1000 456.06 ms 8.680 ms 8.525 ms 21000.0000 5000.0000 1000.0000 125 MB
BindFile 5000 10,411.66 ms 80.092 ms 74.918 ms 296000.0000 40000.0000 8000.0000 2,746 MB
BindFile 10000 42,928.17 ms 326.267 ms 254.728 ms 1046000.0000 72000.0000 9000.0000 11,298 MB

Avoid intermediate HashSet

BenchmarkDotNet=v0.13.0, OS=Windows 10.0.22621
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
.NET SDK=8.0.100-preview.7.23376.3
  [Host]     : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT
  Job-ZMBVHX : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT

InvocationCount=1  RunStrategy=Throughput  UnrollFactor=1
Method SwitchCount Mean Error StdDev Median Gen 0 Gen 1 Gen 2 Allocated
BindFile 100 20.68 ms 0.413 ms 0.843 ms 20.30 ms - - - 3 MB
BindFile 1000 417.38 ms 7.990 ms 10.936 ms 418.08 ms 20000.0000 5000.0000 1000.0000 114 MB
BindFile 5000 8,663.36 ms 89.757 ms 79.568 ms 8,660.18 ms 253000.0000 41000.0000 7000.0000 2,484 MB
BindFile 10000 37,244.51 ms 423.100 ms 375.067 ms 37,137.94 ms 978000.0000 72000.0000 9000.0000 10,253 MB

@sharwell sharwell requested a review from a team as a code owner August 23, 2023 14:06
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 23, 2023
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 3)

@333fred
Copy link
Member

333fred commented Aug 23, 2023

@sharwell were you able to collect the full benchmark numbers from this change? Looking at the baseline->commit 1 diff in your numbers, I'm unsure why this is an overall win.

@sharwell sharwell requested a review from a team as a code owner August 24, 2023 12:53
@sharwell
Copy link
Member Author

@333fred Yes, the benchmarks have been updated

@jcouv
Copy link
Member

jcouv commented Sep 5, 2023

@sharwell Please address the remaining feedback when possible or move to draft. Thanks

@sharwell sharwell closed this Sep 20, 2023
@sharwell sharwell reopened this Sep 20, 2023
@sharwell sharwell merged commit 1e1f73d into dotnet:main Sep 20, 2023
27 checks passed
@ghost ghost added this to the Next milestone Sep 20, 2023
@Cosifne Cosifne modified the milestones: Next, 17.8 P3 Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants