pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Reduce branches in heapgetpage()'s per-tuple loop
3+ messages / 2 participants
[nested] [flat]
Commits from this thread:
2024-04-08 e3b69be951 Remove references to old function name
* pgsql: Reduce branches in heapgetpage()'s per-tuple loop
@ 2024-04-07 07:29 Andres Freund <andres@anarazel.de>
2024-04-07 13:14 ` Re: pgsql: Reduce branches in heapgetpage()'s per-tuple loop Melanie Plageman <melanieplageman@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Andres Freund @ 2024-04-07 07:29 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Reduce branches in heapgetpage()'s per-tuple loop
Until now, heapgetpage()'s loop over all tuples performed some conditional
checks for each tuple, even though condition did not change across the loop.
This commit fixes that by moving the loop into an inline function. By calling
it with different constant arguments, the compiler can generate an optimized
loop for the different conditions, at the price of two per-page checks.
For cases of all-visible tables and an isolation level other than
serializable, speedups of up to 25% have been measured.
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: Zhang Mingli <zmlpostgres@gmail.com>
Tested-by: Quan Zongliang <quanzongliang@yeah.net>
Discussion: https://postgr.es/m/20230716015656.xjvemfbp5fysjiea@awork3.anarazel.de
Discussion: https://postgr.es/m/2ef7ff1b-3d18-2283-61b1-bbd25fc6c7ce@yeah.net
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/a97bbe1f1df9eba0b18207c321c67de80b33db16
Modified Files
--------------
src/backend/access/heap/heapam.c | 102 ++++++++++++++++++++++++++++-----------
1 file changed, 74 insertions(+), 28 deletions(-)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: Reduce branches in heapgetpage()'s per-tuple loop
2024-04-07 07:29 pgsql: Reduce branches in heapgetpage()'s per-tuple loop Andres Freund <andres@anarazel.de>
@ 2024-04-07 13:14 ` Melanie Plageman <melanieplageman@gmail.com>
2024-04-07 17:26 ` Re: pgsql: Reduce branches in heapgetpage()'s per-tuple loop Andres Freund <andres@anarazel.de>
0 siblings, 1 reply; 3+ messages in thread
From: Melanie Plageman @ 2024-04-07 13:14 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: pgsql-committers@lists.postgresql.org
On Sun, Apr 7, 2024 at 3:29 AM Andres Freund <andres@anarazel.de> wrote:
>
> Reduce branches in heapgetpage()'s per-tuple loop
>
> Until now, heapgetpage()'s loop over all tuples performed some conditional
> checks for each tuple, even though condition did not change across the loop.
I haven't reviewed exactly what this does, but heapgetpage() was
removed (or split into two functions, rather) in 44086b097537, so I
find the naming of this function, or, at least the comments, commit
message and description a bit confusing.
- Melanie
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: Reduce branches in heapgetpage()'s per-tuple loop
2024-04-07 07:29 pgsql: Reduce branches in heapgetpage()'s per-tuple loop Andres Freund <andres@anarazel.de>
2024-04-07 13:14 ` Re: pgsql: Reduce branches in heapgetpage()'s per-tuple loop Melanie Plageman <melanieplageman@gmail.com>
@ 2024-04-07 17:26 ` Andres Freund <andres@anarazel.de>
0 siblings, 0 replies; 3+ messages in thread
From: Andres Freund @ 2024-04-07 17:26 UTC (permalink / raw)
To: Melanie Plageman <melanieplageman@gmail.com>; +Cc: pgsql-committers@lists.postgresql.org
Hi,
On 2024-04-07 09:14:57 -0400, Melanie Plageman wrote:
> On Sun, Apr 7, 2024 at 3:29 AM Andres Freund <andres@anarazel.de> wrote:
> >
> > Reduce branches in heapgetpage()'s per-tuple loop
> >
> > Until now, heapgetpage()'s loop over all tuples performed some conditional
> > checks for each tuple, even though condition did not change across the loop.
>
> I haven't reviewed exactly what this does, but heapgetpage() was
> removed (or split into two functions, rather) in 44086b097537, so I
> find the naming of this function, or, at least the comments, commit
> message and description a bit confusing.
Oops. That name was so ingrained in my head that despite looking over these
lines quite a few times, I couldn't spot that.
Will send an update to the thread.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2024-04-07 17:26 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-04-07 07:29 pgsql: Reduce branches in heapgetpage()'s per-tuple loop Andres Freund <andres@anarazel.de>
2024-04-07 13:14 ` Melanie Plageman <melanieplageman@gmail.com>
2024-04-07 17:26 ` Andres Freund <andres@anarazel.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox