Provided (simplified description)
One of our services has many instances in memory. About 85% are unique. We need very quick access to the key elements of these elements, since they are requested very often in one stack / call. This single context is extremely optimized for performance.
So, we started putting them into the dictionary. Performance was fine.
Access to items as quickly as possible is most important in this case. Ensures no write operations while reading.
Problem
At the same time, we fall within the limits of the number of elements that the dictionary can store.
Die Arraydimensionen haben den unterstützten Bereich überschritten. bei System.Collections.Generic.Dictionary`2.Resize(Int32 newSize, Boolean forceNewHashCodes) bei System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
What does the The array dimensions have exceeded the supported range mean.
Solutions like Memcached are too slow in this particular case. This is an isolated very specific use case encapsulated in one service.
So, we are looking for a dictionary replacement for this particular scenario.
I cannot find support at this time. Am I missing something? Can someone point me to one?
Alternatively, if no one exists, we think about their implementation.
We thought of two possibilities. Create it from scratch or wrap several dictionaries.
Wrapping multiple dictionaries
When searching for an element, we can look at the HasCode keys and use its starting number as an index for the list of wrapper dictionaries. Although this seems easy, it smells to me, and it will mean that the hash code is computed twice (once by us once in the internal dictionary) (this scenario is really really cool in performance).
I know that replacing a base type, such as a dictionary, is the last last option, and I want to avoid it. But at present, it seems like there is no way to make objects more unique or get dictionary performance from a database or save performance elsewhere.
I also know that “keep abreast of optimizations”, but lower performance will greatly affect the business requirements behind it.