Re: Improve list manipulation in several places

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, David Rowley <dgrowleyml(at)gmail(dot)com>, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Subject: Re: Improve list manipulation in several places
Date: 2023-04-23 06:42:53
Message-ID: CAMbWs4_-H_6EBnk4LPvEemD48Z4cszLC6KjeyQQH8tjOd=uUUA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Apr 22, 2023 at 12:55 AM Peter Eisentraut <
peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:

> On 21.04.23 09:34, Richard Guo wrote:
> > There was discussion in [1] about improvements to list manipulation in
> > several places. But since the discussion is not related to the topic in
> > that thread, fork a new thread here and attach a patch to show my
> > thoughts.
> >
> > Some are just cosmetic changes by using macros. The others should have
> > performance gain from the avoidance of moving list entries. But I doubt
> > the performance gain can be noticed or measured, as currently there are
> > only a few places affected by the change. I still think the changes are
> > worthwhile though, because it is very likely that future usage of the
> > same scenario can benefit from these changes.
>
> Can you explain the changes?
>
> Maybe this patch should be split up. It seems some of the changes are
> trivial simplifications using existing APIs, while others introduce new
> functions.

Thanks for the suggestion. I've split the patch into two as attached.
0001 is just a minor simplification by replacing lfirst(list_head(list))
with linitial(list). 0002 introduces new functions to reduce the
movement of list elements in several places so as to gain performance
improvement and benefit future callers.

Thanks
Richard

Attachment Content-Type Size
v2-0002-Improve-list-manipulation-in-several-places.patch application/octet-stream 7.9 KB
v2-0001-A-minor-simplification-for-List-manipulation.patch application/octet-stream 1.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2023-04-23 06:57:35 Re: Improve list manipulation in several places
Previous Message Pavel Stehule 2023-04-23 05:31:04 xmlserialize bug - extra empty row at the end