cds_lfht_new() clarification - init vs min
Ondřej Surý via lttng-dev <[email protected]> Wed, 9 Jul 2025 20:57:31 +0200
| Newsgroups | org.lttng.lists.lttng-dev |
|---|---|
| Message-ID | <[email protected]> |
Hi, as the answer to this might be useful to more people, I am asking here: The cds_lfht_new documentation specifies 3 sizes. * cds_lfht_new - allocate a hash table. * @init_size: number of buckets to allocate initially. Must be power of = two. * @min_nr_alloc_buckets: the minimum number of allocated buckets. * (must be power of two) * @max_nr_buckets: the maximum number of hash table buckets allowed. * (must be power of two, 0 is accepted, means * "infinite") The max number of buckets is obvious, but the interaction between init and min is confusing. If I am reading the code right, then init_size < min_nr_alloc_buckets = have no effect, the buckets table will be at least 1 << min_nr_alloc_buckets. But what happens if init_size > min_nr_alloc_buckets? It feels like it = will work as expected if you pre-populate the table, but if you use it "normally", = e.g. there could be single add / del, the table will shrink immediately. Do I understand the code correctly? Ondrej -- Ond=C5=99ej Sur=C3=BD (He/Him) [email protected]