-
-
Notifications
You must be signed in to change notification settings - Fork 17
small hash #102
Description
optimize hashes with <= 3-5 keys to a simple array of keys and values with linear lookup.
HvSMALL(hv) / XHvSMALL(xhv)
is either checking HvMAX < 7, or a flag. If a flag the very first HE* entry needs to be a non-ptr tag (& 0x1).
We'd need a flag with inlined HEs and overlong keys, to omit HvSMALL optims with such long keys.
We cannot the hv_aux based HvFLAGS with normal HvSMALL hashes, esp. when inlined.
The best would be a he-array alike inlined len/char*/flags/val array to be cache concious. (as in #24 feature/gh24-he-array
). The len really should be run-length encoded, then the flags needed for hash cmp need to come first.
However at first we start with simple HE* arrays. (array of ptrs, not values)
The last array element needs to have an NULL sentinel, so we cannot use all 7 HE*, only 6.
But there are many more simple hash optims, which we do first.
- extract uncommon magical code from hv_common
- add __builtin_ctz support (count trailing zeros) and use it instead of division on DO_HSPLIT (done with the builtin-ctz branch)
- pre-extend hashes as in aassign with av_extend, when the number of keys is on the stack. This speeds up all the big hash inits (e.g. warnings.pm), needing no costly series of splits during initialization.