Re: Micro-optimizations to avoid some strlen calls.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Micro-optimizations to avoid some strlen calls.
Date: 2021-07-21 00:48:07
Message-ID: CAKFQuwaeGnRJxb75ntK5V9hWrCvDV6wf4+=ooH5qLiq6ApNOYg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 20, 2021 at 5:28 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:

> On Mon, Jul 19, 2021 at 07:48:55PM -0300, Ranier Vilela wrote:
> > There are some places, where strlen can have an overhead.
> > This patch tries to fix this.
> >
> > Pass check-world at linux ubuntu (20.04) 64 bits.
>
> Why does it matter? No code paths you are changing here are
> performance-critical, meaning that such calls won't really show up
> high in profiles.
>
> I don't think there is anything to change here.
>

Agreed. To borrow from a nearby email of a similar nature (PGConn
information retrieval IIRC) - it is not generally a benefit to avoid
function call access to data multiple times in a block by substituting in a
saved local variable. The function call tends to be more readable then
having yet one more unimportant name to keep in short-term memory. As much
code already conforms to that the status quo is a preferred state unless
there is a demonstrable performance gain to be had. The readability, and
lack of churn, is otherwise more important.

David J.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2021-07-21 01:07:35 Re: [PATCH] Use optimized single-datum tuplesort in ExecSort
Previous Message Michael Paquier 2021-07-21 00:34:12 Re: CLUSTER on partitioned index