You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It may be possible to significantly improve the performance of MemoryCache by using ConcurrentDictionary rather than Dictionary protected by a ReaderWriterLockSlim. Under high load, there is contention acquiring the read lock from ReaderWriterLockSlim.
I created a quick prototype which shows significantly improved performance, though it may not be functionally correct in all scenarios.
Scenario
MemoryCache Implementation
RPS
CPU
Plaintext
N/A
1,167,369
100%
MemoryCachePlaintext
ReaderWriterLockSlim
342,129
60%
MemoryCachePlaintext
ConcurrentDictionary
802,076
100%
The remaining work is to improve and test the ConcurrentDictionary implementation to ensure it's correct under high load, has no race conditions, etc.
It may be possible to significantly improve the performance of MemoryCache by using
ConcurrentDictionaryrather thanDictionaryprotected by aReaderWriterLockSlim. Under high load, there is contention acquiring the read lock fromReaderWriterLockSlim.I created a quick prototype which shows significantly improved performance, though it may not be functionally correct in all scenarios.
The remaining work is to improve and test the ConcurrentDictionary implementation to ensure it's correct under high load, has no race conditions, etc.
Prototype: https://github.com/aspnet/Caching/tree/mikeharder/concurrent-dictionary