From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
---|---|
To: | Михаил Бахтерев <mob(at)k(dot)imm(dot)uran(dot)ru>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | amborodin(at)acm(dot)org, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, Михаил Бахтерев <mike(dot)bakhterev(at)gmail(dot)com> |
Subject: | Re: GiST penalty functions [PoC] |
Date: | 2016-09-08 07:12:30 |
Message-ID: | be494531-9e63-c36b-79e1-2e2b7c85d13e@iki.fi |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 09/08/2016 09:39 AM, Михаил Бахтерев wrote:
> Excuse me for intervention.
>
> It depends. For instance, i run PostgreSQL on the modern MIPS CPU, which
> does not have sqrt support.
>
> But you are right, it is supported in most cases. And if execution speed
> of this very fuction is of concern, sqrtf(x) should be used instead of
> sqrt(x).
>
> Despite this, Andrew's solution gives more accurate representation of
> values. And as far as i understand, this improves overall performance by
> decreasing the overall amount of instructions, which must be executed.
BTW, I would be OK with the bit-twiddling hack, if we had an autoconf
check for IEEE 754 floats, and a graceful fallback for other systems.
The fallback could be simply the current penalty function. You wouldn't
get the benefit from the better penalty function on non-IEEE systems,
then, but it would still be correct.
> It is possible to speed up Andrew's implementation and get rid of
> warnings by using bit-masks and unions. Something like:
>
> union {
> float f;
> struct {
> unsigned int mantissa:23, exponent:8, sign:1;
> } bits;
> }
>
> I am sorry, i have no time to check this. But it is common wisdom to
> avoid pointer-based memory accesses in high-performance code, as they
> create a lot of false write-to-read dependencies.
The compiler should be smart enough to generate the same instructions
either way. A union might be more readable, though. (We don't need to
extract the mantissa, exponent and sign, so a union of float and int32
would do.)
- Heikki
From | Date | Subject | |
---|---|---|---|
Next Message | Vik Fearing | 2016-09-08 07:22:40 | Re: Sample configuration files |
Previous Message | Tsunakawa, Takayuki | 2016-09-08 07:09:51 | Re: Supporting SJIS as a database encoding |