Skip to content
New issue

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

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

Already on GitHub? # to your account

use RWMutex when no TTLs are used #94

Open
raulk opened this issue Nov 16, 2020 · 3 comments
Open

use RWMutex when no TTLs are used #94

raulk opened this issue Nov 16, 2020 · 3 comments

Comments

@raulk
Copy link
Contributor

raulk commented Nov 16, 2020

Segments are guarded by a sync.Mutex. If the user promises to not use TTLs at construction time (with an option), these locks could be changed to sync.RWMutex for increased throughput in read-predominant, highly concurrent workloads.

We could also stop tracking the access time entirely, which would allow us to pack more data in the same size, as well as squeeze a little bit more performance (time.Now() translates into a syscall).

@coocood
Copy link
Owner

coocood commented Nov 17, 2020

RWMutex may perform worse than Mutex if there is very little contention.

@SilverHL
Copy link

RWMutex may perform worse than Mutex if there is very little contention.

Can u explain more about why RWMutex may perform worse than Mutex ?

@coocood
Copy link
Owner

coocood commented Sep 26, 2021

RWMutex may perform worse than Mutex if there is very little contention.

Can u explain more about why RWMutex may perform worse than Mutex ?

RWMutex does more work than Mutex for Lock operation.

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

No branches or pull requests

3 participants