diff options
author | Sverker Eriksson <[email protected]> | 2015-12-03 18:50:20 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2015-12-07 18:02:52 +0100 |
commit | a2b28094081f1b185a31b33e3c1bcb377d6761bb (patch) | |
tree | 8095ba9ef442633ab5df527ffba74e2be7168c52 /erts/emulator/beam/erl_map.h | |
parent | ce8279d6a48d41f9de577825844f499bb3084b96 (diff) | |
download | otp-a2b28094081f1b185a31b33e3c1bcb377d6761bb.tar.gz otp-a2b28094081f1b185a31b33e3c1bcb377d6761bb.tar.bz2 otp-a2b28094081f1b185a31b33e3c1bcb377d6761bb.zip |
erts: Tweak hashmap heap size estimation
1. Change order between mul and div to not lose too much
in integer divisions.
2. Fix estimation in DEBUG to really be an *under* estimation.
Diffstat (limited to 'erts/emulator/beam/erl_map.h')
-rw-r--r-- | erts/emulator/beam/erl_map.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/erts/emulator/beam/erl_map.h b/erts/emulator/beam/erl_map.h index c391de3f11..4d9d74bc37 100644 --- a/erts/emulator/beam/erl_map.h +++ b/erts/emulator/beam/erl_map.h @@ -195,14 +195,17 @@ typedef struct hashmap_head_s { [one cons cell + one list term in parent node] per key [one header + one boxed term in parent node] per inner node [one header + one size word] for root node + Observed average number of nodes per key is about 0.35. */ -#define HASHMAP_HEAP_SIZE(KEYS,NODES) ((KEYS)*3 + (NODES)*2) +#define HASHMAP_WORDS_PER_KEY 3 +#define HASHMAP_WORDS_PER_NODE 2 #ifdef DEBUG -# define HASHMAP_ESTIMATED_NODE_COUNT(KEYS) (KEYS) +# define HASHMAP_ESTIMATED_TOT_NODE_SIZE(KEYS) \ + (HASHMAP_WORDS_PER_NODE * (KEYS) * 3/10) /* slightly under estimated */ #else -# define HASHMAP_ESTIMATED_NODE_COUNT(KEYS) (2*(KEYS)/5) +# define HASHMAP_ESTIMATED_TOT_NODE_SIZE(KEYS) \ + (HASHMAP_WORDS_PER_NODE * (KEYS) * 4/10) /* slightly over estimated */ #endif #define HASHMAP_ESTIMATED_HEAP_SIZE(KEYS) \ - HASHMAP_HEAP_SIZE(KEYS,HASHMAP_ESTIMATED_NODE_COUNT(KEYS)) - + ((KEYS)*HASHMAP_WORDS_PER_KEY + HASHMAP_ESTIMATED_TOT_NODE_SIZE(KEYS)) #endif |