pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Improve sift up/down code in binaryheap.c and logtape.c.
Date: Tue, 14 Dec 2021 18:35:28 +0000
Message-ID: <E1mxCe8-00069C-Cm@gemulon.postgresql.org> (raw)

Improve sift up/down code in binaryheap.c and logtape.c.

Borrow the logic that's long been used in tuplesort.c: instead
of physically swapping the data in two heap entries, keep the
value that's being sifted up or down in a local variable, and
just move the other values as necessary.  This makes the code
shorter as well as faster.  It's not clear that any current
callers are really time-critical enough to notice, but we
might as well code heap maintenance the same way everywhere.

Ma Liangzhu and Tom Lane

Discussion: https://postgr.es/m/17336-fc4e522d26a750fd@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a2ff18e89ff8f29677084bffd1e3de9ca6cd7224

Modified Files
--------------
src/backend/lib/binaryheap.c     | 70 +++++++++++++++++++++++-----------------
src/backend/utils/sort/logtape.c | 54 +++++++++++++------------------
2 files changed, 63 insertions(+), 61 deletions(-)



Message-ID: <E1mxCe8-00069C-Cm@gemulon.postgresql.org>
Permalink:  ../E1mxCe8-00069C-Cm@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1mxCe8-00069C-Cm@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Improve sift up/down code in binaryheap.c and logtape.c.
  In-Reply-To: <E1mxCe8-00069C-Cm@gemulon.postgresql.org>
  References: <E1mxCe8-00069C-Cm@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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