From: | John Naylor <johncnaylorls(at)gmail(dot)com> |
---|---|
To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Using pg_bitutils.h in tidbitmap.c. |
Date: | 2025-04-24 01:47:13 |
Message-ID: | CANWCAZaH_SvFJMGaLspXN+HwyiMoGvVOTL8+UJQ9MXajOR65JA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Apr 14, 2025 at 7:42 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
>
> tidbitmap.c's operations loop over all the bits, but could leap over
> zeros with bitmap instructions like bitmapset.c. Hard to imagine that
> matters, but I think it also comes out easier to read?
Interesting idea -- I toyed with something like this when TID store
was being developed. Most of it looks more readable at a glance,
although tbm_advance_schunkbit() may be a wash.
+bmw_pop_rightmost_one(bitmapword *word)
+{
+ int position = bmw_rightmost_one_pos(*word);
+
+ *word &= ~((bitmapword) 1 << position);
+
+ return position;
+}
There's a more succinct way to write the second statement, since here
we only care about the rightmost bit:
*word &= *word - 1;
That has a bonus in that we don't need to know "position" beforehand,
so the CPU can schedule that independently of the bitscan, which is 3
or 4 cycles on modern hardware, but like you said, I'm not sure if
that matters.
--
John Naylor
Amazon Web Services
From | Date | Subject | |
---|---|---|---|
Next Message | jian he | 2025-04-24 02:42:31 | Re: support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint |
Previous Message | Andres Freund | 2025-04-24 00:40:48 | Re: AIO v2.5 |