dashmap icon indicating copy to clipboard operation
dashmap copied to clipboard

Implements get_or_insert for write once workloads.

Open geekbeast opened this issue 1 year ago • 7 comments
trafficstars

This change allows retrieving values from the map without having to acquire a write lock, unless the value is missing. For read once (or mostly read) workloads this is superior to taking a write lock everytime the entry is read. It also saves having to allocate value if it is not inserted and having to compute the usize hash / shard index twice versus the approach of calling get then using entry to insert (as there is not try_insert yet)

Unfortunately, it doesn't seem like it is possible to avoid the second read without changing the behavior of HashMap.

geekbeast avatar Feb 09 '24 00:02 geekbeast

I didn't touch dependencies so not sure why home package all of sudden is requiring a newer rustc.

geekbeast avatar Feb 09 '24 01:02 geekbeast

@xacrimon I wonder this pr could ever be merged soonish? if more efforts are needed, i can work on. cc: @geekbeast

ryoqun avatar May 08 '24 07:05 ryoqun

@xacrimon I wonder this pr could ever be merged soonish? if more efforts are needed, i can work on. cc: @geekbeast

@xacrimon (thanks for recent release with perf increase!) friendly reminder. if this api sounds okay, I'm available to work on this pr. cc: @geekbeast

ryoqun avatar Jun 20 '24 05:06 ryoqun

@xacrimon a friendly ping. :)

ryoqun avatar Aug 02 '24 13:08 ryoqun

@xacrimon a friendly ping. sorry for being persistent here. my work is kind of blocked on this. can i jump ahead and recreate a pr?

ryoqun avatar Aug 30 '24 06:08 ryoqun