diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2020-06-02 22:00:14 +0100 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2020-07-22 17:57:44 +0100 |
commit | a49c6c6a656c429dc222e04628e085a903194b51 (patch) | |
tree | c2d5bb380ddfbf7745db6619f6aa69fa21a1a2e5 /libctf/ChangeLog | |
parent | 5ceee3dba3422bc8de49768c0c2d8f2608672fe7 (diff) | |
download | gdb-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 'libctf/ChangeLog')
-rw-r--r-- | libctf/ChangeLog | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libctf/ChangeLog b/libctf/ChangeLog index 9e8129a..27987f2 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,5 +1,20 @@ 2020-07-22 Nick Alcock <nick.alcock@oracle.com> + * 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. + +2020-07-22 Nick Alcock <nick.alcock@oracle.com> + * ctf-hash.c (ctf_hashtab_insert): Free the key passed in if there is a key-freeing function and the key already exists. |