[DTrace-devel] [PATCH 3/7] htab: add dt_htab_insert_unique
Eugene Loh
eugene.loh at oracle.com
Wed Oct 13 12:46:28 PDT 2021
On 10/13/21 8:19 AM, Nick Alcock wrote:
> Kris thinks I should just drop this entire commit since it's unused
> anywhere. I don't think he's wrong.
Yup. I can for sure live with that. Still, I have that question about
the pre-existing code (for my personal education, I suppose):
>> Also, though this is "unrelated" to the patch, I was wondering if you
>> could explain the pre-existing code. We enter the insert function. We
>> look for a match. If none, we'll add a bucket and therefore check the
>> htab size. If needed, we resize the htab. At that point, we "retry."
>> Why? If we failed to find a bucket the first time, why should we find
>> one now? Or, are we rerunning the search merely for the side effect of
>> recomputing idx?
> The latter :) it avoids having to write the bucket search loop twice.
> We're retrying the bucket search.
I still don't understand. If the bucket search fails the first time,
don't we already know it will fail again after the resizing? The only
side effect I see is the recomputation of idx, which is more easily done
by replacing "goto retry" with "idx = hval & htab->mask".
More information about the DTrace-devel
mailing list