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

WIP: Add KeyedMutex #4065

Draft
wants to merge 4 commits into
base: series/3.x
Choose a base branch
from

Conversation

BalmungSan
Copy link
Contributor

Extention to the current Mutex class to support one look per key.

I still need to add tests. But first, I would like to receive feedback about the idea and implementation.

Some open questions I have:

  1. Should we use a MapRef instead of a Ref[Map]? Could that help reduce contention?
  2. Should we make the normal Mutex defer to this one, using Unit as the key? If not, should we share the LockQueueCell implementation rather than copy-paste it?

PS: Because this is a copy-paste of Mutex, IMHO it is easier to review each commit rather than the whole thing.

@BalmungSan BalmungSan marked this pull request as draft April 24, 2024 17:49
@SystemFw SystemFw assigned SystemFw and unassigned SystemFw Apr 26, 2024
@iRevive
Copy link
Contributor

iRevive commented Oct 6, 2024

Should we use a MapRef instead of a Ref[Map]? Could that help reduce contention?

I have observed lower memory footprint while using MapRef instead of Ref[F, Map[K, V]] in some cases.

@armanbilge
Copy link
Member

I have observed lower memory footprint while using MapRef instead of Ref[F, Map[K, V]] in some cases.

@iRevive One of the implementations of MapRef is literally a Ref[Map], maybe your observations are related to a ConcurrentHashMap-backed MapRef ?

@iRevive
Copy link
Contributor

iRevive commented Oct 6, 2024

I have observed lower memory footprint while using MapRef instead of Ref[F, Map[K, V]] in some cases.

@iRevive One of the implementations of MapRef is literally a Ref[Map], maybe your observations are related to a ConcurrentHashMap-backed MapRef ?

Yes, it was the MapRaf that uses ConcurrentHashMap under the hood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants