From: "Ondřej Surý via lttng-dev" <lttng-dev@lists.lttng.org>
To: lttng-dev <lttng-dev@lists.lttng.org>
Subject: cds_lfht_new() clarification - init vs min
Date: Wed, 9 Jul 2025 20:57:31 +0200 [thread overview]
Message-ID: <0178CA60-19CE-4E0A-AEEB-5E9DEAAB460E@sury.org> (raw)
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
next reply other threads:[~2025-07-09 18:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-09 18:57 Ondřej Surý via lttng-dev [this message]
2025-07-10 14:05 ` Mathieu Desnoyers via lttng-dev
2025-07-10 14:40 ` Ondřej Surý via lttng-dev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0178CA60-19CE-4E0A-AEEB-5E9DEAAB460E@sury.org \
--to=lttng-dev@lists.lttng.org \
--cc=ondrej@sury.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox