Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] Improve performance of LRU.Add() (#6870) #6872

Merged
merged 1 commit into from
Jan 8, 2021

Conversation

ReubenBond
Copy link
Member

LRU is using ConcurrentDictionary to keep elements in memory. The Add method is using ConcurrentDictionary.Count which may create contention if multiple threads are trying to use the object.
This change wraps CurrentDictionary in a ConcurrentDictionary-like object providing faster count updated on additions and removals.
Plus a few cosmetic changes.

LRU is using ConcurrentDictionary to keep elements in memory. The Add method is using ConcurrentDictionary.Count which may create contention if multiple threads are trying to use the object.
This change wraps CurrentDictionary in a ConcurrentDictionary-like object providing faster count updated on additions and removals.
Plus a few cosmetic changes.
# Conflicts:
#	src/Orleans.Core/Utils/LRU.cs
@ReubenBond ReubenBond modified the milestones: 3.4.1, 3.4.0 Jan 7, 2021
@ReubenBond ReubenBond merged commit 0c9cce2 into dotnet:3.4.1 Jan 8, 2021
@ReubenBond ReubenBond deleted the port/6870 branch January 8, 2021 20:41
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants