Replies: 1 comment 9 replies
-
It's interesting that the difference manifests consistently, even in dictionaries with just one entry. This makes me think that it's an inherent property of the lookup implementation and not something related to collisions occurring. Looking at the implementation I would guess it has something to do with the added concurrent operation tracking logic, which isn't necessary in the case of I think this has been pointed out already in the SO discussion, but this is no reason for recommending users to switch to CD -- assuming updates are needed these are substantially more expensive compared to a regular dictionary and assuming they are not users would be even better off using a FrozenDictionary instead. |
Beta Was this translation helpful? Give feedback.
-
Not sure if this is actually an issue but in some cases
ConcurrentDictionary.TryGetValue
seems to be faster than it's non-concurrent counterpart (maybe due to different collisions handling).From this SO question.
Description
Configuration
BenchmarkDotNet v0.13.11, Windows 11 (10.0.22621.2861/22H2/2022Update/SunValley2)
Intel Core i7-9750H CPU 2.60GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
Regression?
N/A
Data
With ints:
With strings (have not checked for collisions generated):
Analysis
Beta Was this translation helpful? Give feedback.
All reactions