Re: remove ATTRIBUTE_FIXED_PART_SIZE

From: Andres Freund <andres(at)anarazel(dot)de>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: remove ATTRIBUTE_FIXED_PART_SIZE
Date: 2018-08-20 10:46:22
Message-ID: 20180820104622.xo5eelrdy2lprs6x@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2018-08-20 12:34:15 +0200, Peter Eisentraut wrote:
> On 20/08/2018 12:32, Peter Eisentraut wrote:
> > On 18/08/2018 23:05, Tom Lane wrote:
> >> Possibly we need to be more careful than we are now about whether
> >> there's padding at the end of the fixed-size fields ... but just
> >> ripping out the code that attempts to deal with that is hardly
> >> an improvement.
> >
> > I don't think the tuple packing issue has to do with the tuple
> > descriptor code. The tuple descriptors already use allocations of size
> > sizeof(FormData_pg_attribute) (CreateTemplateTupleDesc), just the memcpy
> > and memset calls use (potentially) less. That might have saved a few
> > bytes for omitting the varlena fields, but I don't think it affects
> > alignment correctness. If we, say, added a trailing char field now, the
> > only thing this code
>
> [oops]
>
> ... the only thing the current code would accomplish is not copying the
> last three padding bytes, which might even be slower than copying all four.

That's not generally the case though, there's code like:

static VacAttrStats *
examine_attribute(Relation onerel, int attnum, Node *index_expr)
{
...
/*
* Create the VacAttrStats struct. Note that we only have a copy of the
* fixed fields of the pg_attribute tuple.
*/
stats = (VacAttrStats *) palloc0(sizeof(VacAttrStats));
stats->attr = (Form_pg_attribute) palloc(ATTRIBUTE_FIXED_PART_SIZE);
memcpy(stats->attr, attr, ATTRIBUTE_FIXED_PART_SIZE);

Accesses to stats->attr can legitimately assume that the padding at the
tail end of attr is present (i.e. widening a load / store).

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-08-20 10:48:25 Re: ALTER TABLE on system catalogs
Previous Message Peter Eisentraut 2018-08-20 10:43:20 Re: ALTER TABLE on system catalogs