freecache icon indicating copy to clipboard operation
freecache copied to clipboard

use RWMutex when no TTLs are used

Open raulk opened this issue 5 years ago • 3 comments

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).

raulk avatar Nov 16 '20 12:11 raulk

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

coocood avatar Nov 17 '20 04:11 coocood

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

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

SilverHL avatar Sep 24 '21 09:09 SilverHL

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.

coocood avatar Sep 26 '21 03:09 coocood