Re: Unexpected interval comparison

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: adrian(dot)klaver(at)aklaver(dot)com, frazer(at)frazermclean(dot)co(dot)uk, pgsql-general(at)postgresql(dot)org
Subject: Re: Unexpected interval comparison
Date: 2017-04-05 19:51:10
Message-ID: 27982.1491421870@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> writes:
> The attached patch is the revised version.

Hmm, this still isn't right --- testing shows that you had the comparison
rule right the first time.

Looking at what we've got here, it's already a substantial fraction of
what would be needed to provide a compiler-independent implementation
of the int128-based aggregate logic in numeric.c. With that in mind,
I propose that we extract the relevant stuff into a new header file
that is designed as general-purpose int128 support. Something like the
attached. I also attach the test program I put together to verify it.

On my Fedora 25 laptop, it appears that the hand-rolled implementation
is actually respectably fast compared to gcc's "native" functionality;
the test program runs in ~2m for 1B iterations with the native logic,
and ~2.5m with the hand-rolled logic. Allowing for overhead and the
fact that we're doing the arithmetic twice, we're probably within 2X
of the native code. Not bad at all.

I'm not entirely sure what to do with the test program:
1. discard it
2. commit it as utils/adt/int128.c, as suggested in its comment
3. commit it somewhere else, maybe src/tools/.

Thoughts?

regards, tom lane

Attachment Content-Type Size
int128.h text/plain 5.7 KB
int128.c text/plain 3.9 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2017-04-05 19:56:23 Re: Is there a point to having both a normal gist index and an exclude index?
Previous Message Joshua D. Drake 2017-04-05 18:52:49 Re: browser interface to forums please?