Re: LLVM miscompiles numeric.c access to short numeric var headers

From: Greg Stark <stark(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: LLVM miscompiles numeric.c access to short numeric var headers
Date: 2015-11-12 16:06:39
Message-ID: CAM-w4HOwy3EfmR+kyT0DLnOnf9u3PhJMOwT-5gVDgM2Gmh8ucA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 12, 2015 at 3:51 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Meh. The palloc to create an aligned array of digits would eat up
> any possible performance win --- it'd be just about as expensive
> as the existing unpack operation.

I suppose we would only need to palloc the digits if we found they
were unaligned which would only happen if the varlena header was
packed. So if the varlena header wasn't packed (or if we were just
lucky with the packed alignment which would happen half the time) we
could share the bytes from the packed varlena in the buffer directly
in the var.

> I think we could fix the immediate issue by redeclaring numeric
> headers as arrays of (u)int16 rather than structs. I'm not
> very excited about the packed-header case.

That would require giving up the pretense that the code supports base
10 and base 100 I suppose. And would still be doing a palloc/memcpy
for data smaller than 128 bytes.

--
greg

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthijs van der Vleuten 2015-11-12 16:41:49 Re: psql: add \pset true/false
Previous Message Tom Lane 2015-11-12 15:51:24 Re: LLVM miscompiles numeric.c access to short numeric var headers