Age | Commit message (Collapse) | Author |
|
|
|
Needed in cases where the memory from each key is owned by the GHash.
|
|
|
|
Was using pointer hashing when the keys are in fact uint's.
Since they're well distributed from the rangetree,
no need to do bit-shifting tricks. just use int as hash.
Gives ~8% speedup in own tests.
|
|
|
|
|
|
|
|
Spotted by Coverity.
|
|
|
|
utils to API.
This patch is the root of the GHash rework, all other diff will be based on it:
Reduce average load from 3.0 to 0.75
----------------------------------
This is the big performance booster part, e.g. makes tracing a dyntopo stroke between 25% and 30% faster.
Not much to say about it, aside that it obviously increase memory footprint (about 25% - 30% too).
Add optional shrinking
----------------------------------
I.e. ghashes/gsets can now shrink their buckets array when you remove enough entries. This remains optional and OFF by default.
Add code to use masking instead of modulo
----------------------------------
Buckets indices are obtained from hashes by “reducing” the hash value into the valid bucket range. This can be done either by bit-masking, or using modulo operation.
The former is quicker, but requires real hashes, while the later is slower (average 10% impact on ghash operations) but can also be used as a 'fake' hashing on raw values, like e.g. indices.
In Blender currently not all ghash usages actually hash their keys, so we stick to modulo for now (masking is ifdef’ed out), we may however investigate the benefits of switching to masking with systematic very basic hashing later…
Add various missing API helpers
----------------------------------
I.e. a way to deep-copy a ghash/gset, and a way to (re-)reserve entries (i.e. manually grow or shrink the ghash after its creation).
Various code refactoring
----------------------------------
* Get rid of the 'hack' regarding ghash size when used as gset (it’s simpler and safer to have two structs defined here, and cast pointers as needed).
* Various re-shuffle and factorization in low-level internal code.
* Some work on hashing helpers, introducing some murmur2a-based hashing too.
Thanks a bunch to Campbell for the extensive review work. :)
Reviewers: sergey, campbellbarton
Subscribers: psy-fi, lukastoenne
Projects: #bf_blender
Maniphest Tasks: T43766
Differential Revision: https://developer.blender.org/D1178
|
|
Makes usage of those funcs much more clear, we even had mixed '!strcmp(foo, bar)'
and 'strcmp(foo, bar) == 0' in several places...
|
|
|
|
Ghash comp callbacks must return false in case a & b are equal!
Also slightly cleaned up gash code using those comp func,
since those return booleans now, let's compare tham against booleans!
|
|
|
|
|
|
|
|
|
|
|
|
Can use to check on improvements to hash functions.
|
|
also rename BLI_edgeset_reinsert -> BLI_edgeset_add, in this case its the same.
|
|
|
|
Returns a fallback argument when the key isn't found.
|
|
also avoid searching buckets for empty hashes
|
|
|
|
- BLI_ghashutil_strhash_n takes string length, to avoid terminating the string before hashing.
- BLI_ghashutil_inthash/uinthash take ints, to avoid casting to (void *)
This also showed up incorrect use of inthash, which was using a pointer.
|
|
also remove NULL check, only a few areas made use of this.
|
|
|
|
|
|
some systems.
|
|
|
|
place (pragmas were copied around).
also enable more strict warnings for BLF (which had some incorrect casts).
|
|
also quiet compiler warning for BLI_LINKSTACK_FREE macro.
|
|
takes a key as an arg and isnt popping any element from the hash as you might expect).
add BLI_pophead/tail, since getting the first element from a list and removing it is a common task.
|
|
hash from insertion.
|
|
|
|
- no need to zero vars when freeing ghash
- de duplicate ghash remove code.
- edgehash clear now works more like ghash.
|
|
internally without allocating space for the value).
|
|
|
|
|
|
BLI_mempool_clear utility function.
|
|
|
|
some tests with high poly mesh data in hashes.
- empty buckets before 4-5%, after 1-2%
- speedup for hash lookups, in my tests lookups take approx ~60% of the time they did before.
|
|
to try save a few bytes here.
|
|
reserve argument.
|
|
ghash since r57657)
having 2 free buckets for each entry is faster but uses more memory.
use the original size, best case 3 entries per bucket.
|
|
the hash as an arg (avoids resizing in simple cases when the hash is created and filled immediately).
|
|
in same order for ghash/edgehash.
|
|
|
|
|
|
avoids remove,insert and only hashes the key once.
|