From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | John Naylor <john(dot)naylor(at)2ndquadrant(dot)com> |
Cc: | David Fetter <david(at)fetter(dot)org>, Jesse Zhang <sbjesse(at)gmail(dot)com>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Use compiler intrinsics for bit ops in hash |
Date: | 2020-04-07 11:40:52 |
Message-ID: | CAApHDvrCx25xOdX2QHVtG6maT8D0z4o7-9Y_1iRas-ROzOyfHA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, 12 Mar 2020 at 22:59, John Naylor <john(dot)naylor(at)2ndquadrant(dot)com> wrote:
>
> On Thu, Mar 12, 2020 at 7:42 AM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> >
> > I don't think Jesse's proposed solution is that great due to the
> > additional function call overhead for pg_count_leading_zeros_32(). The
> > (num & (num - 1)) == 0 I imagine will perform better, but I didn't
> > test it.
>
> Right, I believe we've all landed on the same page about that. I see
> two ways of doing next_power_of_2_32 without an indirect function
> call, and leaving pg_leftmost_one_pos32 the same as it is now. I
> haven't measured either yet (or tested for that matter):
I've attached an updated patch. It includes the modifications
mentioned above to pre-check for a power of 2 number with the bit
masking hack mentioned above. I also renamed the functions to be more
aligned to the other functions in pg_bitutils.h I'm not convinced
pg_ceil_log2_* needs the word "ceil" in there.
I dropped the part of the patch that was changing longs to ints of a
known size. I went on and did some additional conversion in the 0003
patch. There are more laying around the code base, but I ended up
finding a bit to fix up than i had thought I would. e.g. various
places that repalloc() inside a loop that is multiplying the
allocation size by 2 each time. The repalloc should be done at the
end, not during the loop. I thought I might come back to those some
time in the future.
Is anyone able to have a look at this?
David
Attachment | Content-Type | Size |
---|---|---|
v7-0001-Add-functions-to-calculate-the-next-power-of-2.patch | text/x-patch | 3.0 KB |
v7-0003-Modify-additional-power-2-calculations-to-use-new.patch | text/x-patch | 6.2 KB |
v7-0002-Modify-various-power-2-calculations-to-use-new-he.patch | text/x-patch | 7.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Masahiko Sawada | 2020-04-07 11:47:14 | Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch) |
Previous Message | Kuntal Ghosh | 2020-04-07 11:31:37 | Re: SLRU statistics |