Re: Small cleanups to tuplesort.c and a bonus small performance improvement - Mailing list pgsql-hackers

From David Rowley
Subject Re: Small cleanups to tuplesort.c and a bonus small performance improvement
Date
Msg-id CAApHDvrRLjEO3Vmpo79mDihNRMOVBZObOEi7Jy5b=o5QvcPiHw@mail.gmail.com
Whole thread Raw
In response to Small cleanups to tuplesort.c and a bonus small performance improvement  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: Small cleanups to tuplesort.c and a bonus small performance improvement
List pgsql-hackers
On Fri, 26 Aug 2022 at 16:48, David Rowley <dgrowleyml@gmail.com> wrote:
> 0003: Changes writetuple to tell it what it should do in regards to
> freeing and adjusting the memory accounting.
>
> Probably 0003 could be done differently. I'm certainly not set on the
> bool args. I understand that I'm never calling it with "freetup" ==
> true. So other options include 1) rip out the pfree code and that
> parameter; or 2) just do the inlining manually at both call sites.

This patch series needed to be rebased and on looking it at again,
since the pfree() code is never used I felt it makes very little sense
to keep it, so I decided that it might be better just to keep the
WRITETUP macro and just completely get rid of the writetuple function
and have the macro call the function pointed to be the "writetup"
pointer.   The only extra code we needed from writetuple() was the
memory accounting code which was only used in dumptuples(), so I've
just included that code in that function instead.

I also noticed that dumptuples() had a pretty braindead method of
zeroing out state->memtupcount by subtracting 1 from it on each loop.
Since that's not being used to keep track of the loop's progress, I've
just moved it out the loop and changed the code to set it to 0 once
the loop is done.

> I'll throw this in the September CF to see if anyone wants to look.
> There's probably lots more cleaning jobs that could be done in
> tuplesort.c.

My current thoughts are that this is a very trivial patch and unless
there's any objections I plan to push it soon.

David

Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Handle infinite recursion in logical replication setup
Next
From: Amit Langote
Date:
Subject: Re: SQL/JSON features for v15