concurrent hopscotch hashtable only needs a load-load barrier in lookup
and that is implied by the x86/x64's memory model ... avoiding the mfence instruction is a significant win Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
95f070d097
commit
771eed118b
4 changed files with 15 additions and 9 deletions
|
@ -331,6 +331,11 @@ VDDS_INLINE int os_atomic_casvoidp (volatile os_atomic_voidp_t *x, void *exp, vo
|
|||
VDDS_INLINE void os_atomic_fence (void) {
|
||||
__sync_synchronize ();
|
||||
}
|
||||
VDDS_INLINE void os_atomic_fence_ldld (void) {
|
||||
#if !(defined __i386__ || defined __x86_64__ || defined _M_IX86 || defined _M_X64)
|
||||
__sync_synchronize ();
|
||||
#endif
|
||||
}
|
||||
VDDS_INLINE void os_atomic_fence_acq (void) {
|
||||
os_atomic_fence ();
|
||||
}
|
||||
|
|
|
@ -231,6 +231,9 @@ VDDS_INLINE void os_atomic_fence (void) {
|
|||
membar_exit ();
|
||||
membar_enter ();
|
||||
}
|
||||
VDDS_INLINE void os_atomic_fence_ldld (void) {
|
||||
membar_enter ();
|
||||
}
|
||||
VDDS_INLINE void os_atomic_fence_acq (void) {
|
||||
membar_enter ();
|
||||
}
|
||||
|
|
|
@ -416,6 +416,11 @@ OS_ATOMIC_API_INLINE void os_atomic_fence (void) {
|
|||
InterlockedExchange (&tmp, 0);
|
||||
#pragma warning (pop)
|
||||
}
|
||||
OS_ATOMIC_API_INLINE void os_atomic_fence_ldld (void) {
|
||||
#if !(defined _M_IX86 || defined _M_X64)
|
||||
os_atomic_fence ();
|
||||
#endif
|
||||
}
|
||||
OS_ATOMIC_API_INLINE void os_atomic_fence_acq (void) {
|
||||
os_atomic_fence ();
|
||||
}
|
||||
|
|
|
@ -34,11 +34,7 @@ struct ut_chhBucket {
|
|||
|
||||
struct _Struct_size_bytes_(size) ut_chhBucketArray {
|
||||
uint32_t size; /* power of 2 */
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
struct ut_chhBucket bs[];
|
||||
#else
|
||||
struct ut_chhBucket bs[1];
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ut_chhBackingLock {
|
||||
|
@ -91,9 +87,6 @@ static int ut_chhInit (struct ut_chh *rt, uint32_t init_size, ut_hhHash_fn hash,
|
|||
for (i = 0; i < N_BACKING_LOCKS; i++) {
|
||||
struct ut_chhBackingLock *s = &rt->backingLocks[i];
|
||||
os_mutexInit (&s->lock);
|
||||
}
|
||||
for (i = 0; i < N_BACKING_LOCKS; i++) {
|
||||
struct ut_chhBackingLock *s = &rt->backingLocks[i];
|
||||
os_condInit (&s->cv, &s->lock);
|
||||
}
|
||||
for (i = 0; i < N_RESIZE_LOCKS; i++) {
|
||||
|
@ -205,7 +198,7 @@ static void *ut_chhLookupInternal (struct ut_chhBucketArray const * const bsary,
|
|||
do {
|
||||
uint32_t hopinfo;
|
||||
timestamp = os_atomic_ld32 (&bs[bucket].timestamp);
|
||||
os_atomic_fence ();
|
||||
os_atomic_fence_ldld ();
|
||||
hopinfo = os_atomic_ld32 (&bs[bucket].hopinfo);
|
||||
for (idx = 0; hopinfo != 0; hopinfo >>= 1, idx++) {
|
||||
const uint32_t bidx = (bucket + idx) & idxmask;
|
||||
|
@ -214,7 +207,7 @@ static void *ut_chhLookupInternal (struct ut_chhBucketArray const * const bsary,
|
|||
return data;
|
||||
}
|
||||
}
|
||||
os_atomic_fence ();
|
||||
os_atomic_fence_ldld ();
|
||||
} while (timestamp != os_atomic_ld32 (&bs[bucket].timestamp) && ++try_counter < CHH_MAX_TRIES);
|
||||
if (try_counter == CHH_MAX_TRIES) {
|
||||
/* Note: try_counter would not have been incremented to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue