Amazing performance improvement in .NET 6 when creating one SortedDictionary from another

The performance improvements when cloning one SortedDictionary from another in .NET 6 compared to .NET 5 are amazing.

I’m not sure how commonly devs need to clone a SortedDictionary but on my machine .NET 6 can do this over 25 times faster than .NET 5 so this will definitely help some apps.

Click on the image below for a larger view in a new tab…

For specifics about how this optimisation was achieved check out the GitHub items below:

Add equality override for KeyValuePairComparer by johnthcall · Pull Request #56634 · dotnet/runtime · GitHub

SortedDictionary Copy optimization by johnthcall · Pull Request #45659 · dotnet/runtime · GitHub

Leave a Reply

Your email address will not be published. Required fields are marked *