SwordfishCollections icon indicating copy to clipboard operation
SwordfishCollections copied to clipboard

ConcurrentObservableDictionary is non performant because it also acts like a List

Open stewienj opened this issue 1 year ago • 1 comments

ConcurrentObservableDictionary is not a straight wrapper around an ImmutableDictionary, instead it has a dual personality where it can be used as a Dictionary or a List. This behaviour stems from a very old requirement that has long been forgotten. Unfortunately this behaviour also has significant performance penalties. The ConcurrentObservableDictionary class should be moved to ConcurrentObservableDictionaryList, and a proper ConcurrentObservableDictionary should be created that works the same way as other classes list ConcurrentObservableHashSet.

This change will be a breaking change for anyone using ConcurrentObservableDictionary as a List. I'm wondering how many people this will affect?

stewienj avatar Sep 27 '23 04:09 stewienj

The issue is a bit more complicated. ConcurrentObservableDictionary is non performant in things like BenchmarkDotNet because that is console only, however the IList backing of ConcurrentObservableDictionary allows for Virtualized list panels to load only the required elements. As such I will keep the ConcurrentObservableDictionary as is, but create a ConcurrentObservableDictionaryLite to use instead for small collections which doesn't have the IList interface.

stewienj avatar Sep 28 '23 06:09 stewienj