Re: A few more opportunities to use TupleTableSlotOps fields

From: Antonin Houska <ah(at)cybertec(dot)at>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: A few more opportunities to use TupleTableSlotOps fields
Date: 2019-05-21 14:47:50
Message-ID: 4165.1558450070@spoje.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Tue, May 21, 2019 at 8:02 AM Antonin Houska <ah(at)cybertec(dot)at> wrote:
> > Perhaps it's just a matter of taste, but I think the TupleTableSlotOps
> > structure, once initialized, should be used wherever possible. At least for me
> > personally, when I read the code, the particular callback function name is a
> > bit disturbing wherever it's not necessary.
>
> But it's significantly more efficient.

Do you refer to the fact that for example the address of

tts_virtual_clear(dstslot);

is immediately available in the text section while in this case

dstslot->tts_ops->clear(dstslot);

the CPU first needs to fetch the address of tts_ops and also that of the
->clear function?

I admit I didn't think about this problem. Nevertheless I imagine that due to
constness of the variables like TTSOpsVirtual (and due to several other const
declarations) the compiler might be able to compute the address of the
tts_ops->clear() expression. Thus the only extra work for the CPU would be to
fetch tts_ops from dstslot, but that should not be a big deal because other
fields of dstslot are accessed by the surrounding code (so all of them might
be available in the CPU cache).

I don't pretend to be an expert in this area though, it's possible that I
still miss something.

--
Antonin Houska
Web: https://www.cybertec-postgresql.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2019-05-21 14:55:09 Re: PostgreSQL 12: Feature Highlights
Previous Message Tom Lane 2019-05-21 14:39:12 Re: Parallel Append subplan order instability on aye-aye