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

[Perf] Regressions in System.Linq.Tests.Perf_Enumerable #50006

Closed
DrewScoggins opened this issue Mar 22, 2021 · 9 comments
Closed

[Perf] Regressions in System.Linq.Tests.Perf_Enumerable #50006

DrewScoggins opened this issue Mar 22, 2021 · 9 comments
Assignees
Labels
arch-x64 area-System.Linq os-linux Linux OS (any supported distro) tenet-performance Performance related issue tenet-performance-benchmarks Issue from performance benchmark untriaged New issue has not been triaged by the area owner
Milestone

Comments

@DrewScoggins
Copy link
Member

Run Information

Architecture x64
OS ubuntu 18.04
Baseline 3553284bea7b650874c8dcc3f78d6be085a047bb
Compare 59594697a94b5add2d91f292283141574e4d0f16

Regressions in System.Linq.Tests.Perf_Enumerable

Benchmark Baseline Test Test/Base Baseline IR Compare IR IR Ratio Baseline ETL Compare ETL
TakeLastHalf 1.23 μs 1.34 μs 1.09

graph
Historical Data in Reporting System

Repro

git clone https://github.com/dotnet/performance.git
python3 .\performance\scripts\benchmarks_ci.py -f netcoreapp5.0 --filter 'System.Linq.Tests.Perf_Enumerable*'

.

Payloads

Baseline
Compare

Histogram

System.Linq.Tests.Perf_Enumerable.TakeLastHalf(input: IEnumerable)

[1222.875 ; 1258.448) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
[1258.448 ; 1302.591) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
[1302.591 ; 1341.917) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
[1341.917 ; 1388.505) | @@@@@@@@@@@@@@@@@@@

Docs

Profiling workflow for dotnet/runtime repository
Benchmarking workflow for dotnet/runtime repository

@DrewScoggins DrewScoggins added os-linux Linux OS (any supported distro) tenet-performance Performance related issue tenet-performance-benchmarks Issue from performance benchmark arch-x64 labels Mar 22, 2021
@dotnet-issue-labeler
Copy link

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

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Mar 22, 2021
@DrewScoggins
Copy link
Member Author

#48634 looks like the culprit

@ghost
Copy link

ghost commented Mar 23, 2021

Tagging subscribers to this area: @eiriktsarpalis
See info in area-owners.md if you want to be subscribed.

Issue Details

Run Information

Architecture x64
OS ubuntu 18.04
Baseline 3553284bea7b650874c8dcc3f78d6be085a047bb
Compare 59594697a94b5add2d91f292283141574e4d0f16

Regressions in System.Linq.Tests.Perf_Enumerable

Benchmark Baseline Test Test/Base Baseline IR Compare IR IR Ratio Baseline ETL Compare ETL
TakeLastHalf 1.23 μs 1.34 μs 1.09

graph
Historical Data in Reporting System

Repro

git clone https://github.com/dotnet/performance.git
python3 .\performance\scripts\benchmarks_ci.py -f netcoreapp5.0 --filter 'System.Linq.Tests.Perf_Enumerable*'

.

Payloads

Baseline
Compare

Histogram

System.Linq.Tests.Perf_Enumerable.TakeLastHalf(input: IEnumerable)

[1222.875 ; 1258.448) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
[1258.448 ; 1302.591) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
[1302.591 ; 1341.917) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
[1341.917 ; 1388.505) | @@@@@@@@@@@@@@@@@@@

Docs

Profiling workflow for dotnet/runtime repository
Benchmarking workflow for dotnet/runtime repository

Author: DrewScoggins
Assignees: -
Labels:

arch-x64, area-System.Linq, os-linux, tenet-performance, tenet-performance-benchmarks, untriaged

Milestone: -

@eiriktsarpalis eiriktsarpalis self-assigned this Mar 23, 2021
@eiriktsarpalis eiriktsarpalis added this to the 6.0.0 milestone Mar 23, 2021
@eiriktsarpalis
Copy link
Member

This is expected, TakeLast is now doing slightly more work because it is being defined in terms of the Take(Range) method which optimizes for ICollection inputs. This can be seen if we compare with other inputs of the same benchmark:

e52568d

Method input Mean Error StdDev Median Min Max Gen 0 Gen 1 Gen 2 Allocated
TakeLastHalf IEnumerable 1.360 us 0.0566 us 0.0651 us 1.314 us 1.301 us 1.456 us 0.0733 - - 752 B
TakeLastHalf List 1.669 us 0.1329 us 0.1530 us 1.658 us 1.505 us 1.992 us 0.0743 - - 760 B

f7308f0

Method input Mean Error StdDev Median Min Max Gen 0 Gen 1 Gen 2 Allocated
TakeLastHalf IEnumerable 1,424.4 ns 23.57 ns 19.68 ns 1,419.6 ns 1,406.8 ns 1,465.5 ns 0.0741 - - 776 B
TakeLastHalf List 693.1 ns 21.78 ns 25.08 ns 681.0 ns 669.6 ns 742.8 ns 0.0109 - - 136 B

@adamsitnik adamsitnik reopened this Apr 8, 2021
@eiriktsarpalis
Copy link
Member

Yes, this is in line with the trade-offs in that particular change. Notice in #50006 (comment) that for IEnumerable inputs performance regresses slightly, however for IList inputs it improves significantly, both in time and memory consumption.

I would recommend closing this as by-design.

@eiriktsarpalis
Copy link
Member

I just realized you referred to List inputs. I'll take a look.

@adamsitnik
Copy link
Member

@eiriktsarpalis sorry I forgot to provide the repro:

git clone https://github.com/dotnet/performance.git
python3 .\performance\scripts\benchmarks_ci.py -f net5.0 net6.0 --filter 'System.Linq.Tests.Perf_Enumerable.TakeLastHalf'

@eiriktsarpalis
Copy link
Member

Looking at the graph, the initial regression in September definitely correlates with this change: #42506.

This was reverting an optimization since it was behaving incorrectly in the context of source mutations. The more recent changes improve performance (as expected), but it is unlikely we can recover the performance of the (incorrect) .NET 5 implementation.

Again, this regression is to be expected, closing the issue.

cc @stephentoub

@ghost ghost locked as resolved and limited conversation to collaborators May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-x64 area-System.Linq os-linux Linux OS (any supported distro) tenet-performance Performance related issue tenet-performance-benchmarks Issue from performance benchmark untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

4 participants