SortedList performance #112123
Labels
area-System.Collections
tenet-performance
Performance related issue
untriaged
New issue has not been triaged by the area owner
Description
I am currently migrating my Xamarin.iOS app to .Net for iOS. During testing of this we noticed a performance hit when loading data. Drilling into this we noticed that it was coming from doing a deep copy of SortedLists.
What we do is copy one SortedList to another via its constructor (https://learn.microsoft.com/en-us/dotnet/api/system.collections.sortedlist.-ctor?view=net-9.0#system-collections-sortedlist-ctor(system-collections-idictionary)).
While this does create a deep copy of the SortedList it is significantly slower than it was in our old Xamarin App.
I have created 2 dummy projects to investigate, one in .Net Framework 4.8 and another in .Net 8.
Both are console apps that create a SortedList<Datetime, string> with 1000 dates, then measures the ticks it takes to copy this to a new SortedList. I run this 100 times to get an average.
Here is the example code I used in both the .Net Framework 4.8 and .Net 8 versions.
Are the default comparers slower in the .Net 8 and later versions than they previously were or are there other operations going on that previously weren't?
Are there any reasons why the performance has changed so much and is there any way we can get it performing as well as it previously did?
Configuration
The code is running on both .Net Framework 4.8 and .Net 8 for comparison.
I am running a MacBook Pro M1 Max, which will have an ARM64 architecture.
Current OS version is macOS Sonoma 14.6.1.
This is also being experienced on a number of iPads.
Regression?
The code is running on both .Net Framework 4.8 and .Net 8 for comparison.
Data
Below is the data from a run of both versions
The text was updated successfully, but these errors were encountered: