mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 09:20:25 +00:00
Merge pull request #796 from qlyoung/fix-hash-stats
lib: use 32-bit atomics, s/pow/mul
This commit is contained in:
commit
f4b0619dc6
@ -87,13 +87,8 @@ hash_alloc_intern (void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define hash_update_ssq(hz, old, new) \
|
#define hash_update_ssq(hz, old, new) \
|
||||||
do { \
|
atomic_fetch_add_explicit(&hz->stats.ssq, (new + old)*(new - old),\
|
||||||
long double res; \
|
memory_order_relaxed);
|
||||||
res = powl(old, 2.0); \
|
|
||||||
hz->stats.ssq -= (uint64_t) res;\
|
|
||||||
res = powl(new, 2.0); \
|
|
||||||
hz->stats.ssq += (uint64_t) res; \
|
|
||||||
} while (0); \
|
|
||||||
|
|
||||||
/* Expand hash if the chain length exceeds the threshold. */
|
/* Expand hash if the chain length exceeds the threshold. */
|
||||||
static void hash_expand (struct hash *hash)
|
static void hash_expand (struct hash *hash)
|
||||||
|
@ -53,9 +53,9 @@ struct hash_backet
|
|||||||
struct hashstats
|
struct hashstats
|
||||||
{
|
{
|
||||||
/* number of empty hash buckets */
|
/* number of empty hash buckets */
|
||||||
_Atomic int empty;
|
_Atomic uint_fast32_t empty;
|
||||||
/* sum of squares of bucket length */
|
/* sum of squares of bucket length */
|
||||||
_Atomic uint64_t ssq;
|
_Atomic uint_fast32_t ssq;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hash
|
struct hash
|
||||||
|
Loading…
Reference in New Issue
Block a user