Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* cds_lfht_new() clarification - init vs min
@ 2025-07-09 18:57 Ondřej Surý via lttng-dev
  2025-07-10 14:05 ` Mathieu Desnoyers via lttng-dev
  0 siblings, 1 reply; 3+ messages in thread
From: Ondřej Surý via lttng-dev @ 2025-07-09 18:57 UTC (permalink / raw)
  To: lttng-dev

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řej Surý (He/Him)
ondrej@sury.org


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-10 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-09 18:57 cds_lfht_new() clarification - init vs min Ondřej Surý via lttng-dev
2025-07-10 14:05 ` Mathieu Desnoyers via lttng-dev
2025-07-10 14:40   ` Ondřej Surý via lttng-dev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox