aboutsummaryrefslogtreecommitdiff
path: root/depcomp
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-06-02 22:00:14 +0100
committerNick Alcock <nick.alcock@oracle.com>2020-07-22 17:57:44 +0100
commita49c6c6a656c429dc222e04628e085a903194b51 (patch)
treec2d5bb380ddfbf7745db6619f6aa69fa21a1a2e5 /depcomp
parent5ceee3dba3422bc8de49768c0c2d8f2608672fe7 (diff)
downloadgdb-a49c6c6a656c429dc222e04628e085a903194b51.zip
gdb-a49c6c6a656c429dc222e04628e085a903194b51.tar.gz
gdb-a49c6c6a656c429dc222e04628e085a903194b51.tar.bz2
libctf, hash: save per-item space when no key/item freeing function
The libctf dynhash hashtab abstraction supports per-hashtab arbitrary key/item freeing functions -- but it also has a constant slot type that holds both key and value requested by the user, so it needs to use its own freeing function to free that -- and it has nowhere to store the freeing functions the caller requested. So it copies them into every hash item, bloating every slot, even though all items in a given hash table must have the same key and value freeing functions. So point back to the owner using a back-pointer, but don't even spend space in the item or the hashtab allocating those freeing functions unless necessary: if none are needed, we can simply arrange to not pass in ctf_dynhash_item_free as a del_f to hashtab_create_alloc, and none of those fields will ever be accessed. The only downside is that this makes the code sensitive to the order of fields in the ctf_helem_t and ctf_hashtab_t: but the deduplicator allocates so many hash tables that doing this alone cuts memory usage during deduplication by about 10%. (libiberty hashtab itself has a lot of per-hashtab bloat: in the future we might trim that down, or make a trimmer version.) libctf/ * ctf-hash.c (ctf_helem_t) <key_free>: Remove. <value_free>: Likewise. <owner>: New. (ctf_dynhash_item_free): Indirect through the owner. (ctf_dynhash_create): Only pass in ctf_dynhash_item_free and allocate space for the key_free and value_free fields fields if necessary. (ctf_hashtab_insert): Likewise. Fix OOM errno value. (ctf_dynhash_insert): Only access ctf_hashtab's key_free and value_free if they will exist. Set the slot's owner, but only if it exists. (ctf_dynhash_remove): Adjust.
Diffstat (limited to 'depcomp')
0 files changed, 0 insertions, 0 deletions