Re: GiST penalty functions [PoC]
От | Heikki Linnakangas |
---|---|
Тема | Re: GiST penalty functions [PoC] |
Дата | |
Msg-id | be494531-9e63-c36b-79e1-2e2b7c85d13e@iki.fi обсуждение исходный текст |
Ответ на | GiST penalty functions [PoC] (Andrew Borodin <borodin@octonica.com>) |
Ответы |
Re: GiST penalty functions [PoC]
Re: GiST penalty functions [PoC] |
Список | 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
В списке pgsql-hackers по дате отправления: