diff options
author | Victor Ren <[email protected]> | 2016-10-06 18:27:07 +0800 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-10-10 15:10:29 +0200 |
commit | c5a826b3d3a80726473fd9c2a7bea58b4363a993 (patch) | |
tree | 8f291b7c726f6d3fdf6ca598bf8841fa37e56407 /erts/emulator/beam | |
parent | 88acd9cbdea2b342206b7a2e5ba8b904dbfd10a7 (diff) | |
download | otp-c5a826b3d3a80726473fd9c2a7bea58b4363a993.tar.gz otp-c5a826b3d3a80726473fd9c2a7bea58b4363a993.tar.bz2 otp-c5a826b3d3a80726473fd9c2a7bea58b4363a993.zip |
Use atom value as hash value in process dictionary
In the origin implementation, the hash value of atom term is retrieved
from the atom table. Reading the atom table is expensive since it is in
memory and leads to more cache missing.
The size of a process dictionary is usually small. The atom value (the
index) is unique and can be hash value for it. Using the atom value
directly should be more efficient.
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/beam_load.c | 2 | ||||
-rw-r--r-- | erts/emulator/beam/erl_process_dict.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c index d69b18e22f..8aecf01bfd 100644 --- a/erts/emulator/beam/beam_load.c +++ b/erts/emulator/beam/beam_load.c @@ -4345,7 +4345,7 @@ hash_internal_genop_arg(LoaderState* stp, GenOpArg Key, Uint32* hx) { switch (Key.type) { case TAG_a: - *hx = atom_tab(atom_val(Key.val))->slot.bucket.hvalue; + *hx = atom_val(Key.val); return 1; case TAG_i: *hx = Key.val; diff --git a/erts/emulator/beam/erl_process_dict.c b/erts/emulator/beam/erl_process_dict.c index d8c2eaba94..e05d81158d 100644 --- a/erts/emulator/beam/erl_process_dict.c +++ b/erts/emulator/beam/erl_process_dict.c @@ -56,7 +56,7 @@ #define MAKE_HASH(Term) \ ((is_small(Term)) ? unsigned_val(Term) : \ ((is_atom(Term)) ? \ - (atom_tab(atom_val(Term))->slot.bucket.hvalue) : \ + atom_val(Term) : \ make_internal_hash(Term))) #define PD_SZ2BYTES(Sz) (sizeof(ProcDict) + ((Sz) - 1)*sizeof(Eterm)) |