Re: avoiding tuple copying in btree index builds

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: avoiding tuple copying in btree index builds
Date: 2014-07-01 14:39:04
Message-ID: CA+TgmoYjrQwTPCVkz=p8SnAwsB8OHwub3sFh_bud7CcAN4huNA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 17, 2014 at 10:08 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Mon, Jun 16, 2014 at 8:10 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> On a micro-optimization level, it might be worth passing the TID as
>>> ItemPointer not ItemPointerData (ie, pass a pointer until we get to
>>> the point of actually inserting the TID into the index tuple).
>>> I'm not sure that copying odd-size structs should be assumed to be
>>> efficient.
>
>> Yeah, true. Checking existing precedent, it looks like we usually
>> pass ItemPointer rather than ItemPointerData, so it's probably a good
>> idea to do this that way too for reasons of style if nothing else. I
>> kind of wonder whether it's really more efficient to pass an 8-byte
>> pointer to a 6-byte structure than to just pass the structure itself,
>> but it might be.
>
> The pointer will certainly be passed in a register, or whatever passes for
> registers on the particular machine architecture. Weird-size structs,
> though, tend to have arcane and not-so-efficient rules for being passed
> by value. It's not unlikely that what the compiler will do under the hood
> is pass a pointer anyhow, and then do a memcpy to make a local copy in
> the called function.

OK, committed with the suggested changes.

(Thanks to Abhijit for pinging me about this, and more generally for
his active and effective management of this CommitFest!)

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2014-07-01 14:46:41 Re: WAL format and API changes (9.5)
Previous Message Robert Haas 2014-07-01 14:13:23 Re: "RETURNING PRIMARY KEY" syntax extension