Spinlock backoff algorithm

Поиск
Список
Период
Сортировка
От Magne Mæhre
Тема Spinlock backoff algorithm
Дата
Msg-id 473AC13B.1060008@sun.com
обсуждение исходный текст
Ответы Re: Spinlock backoff algorithm
Re: Spinlock backoff algorithm
Список pgsql-hackers
I was playing with a Nevada server and noticed a rush on the FPU
(the Nevada has a single shared FPU for its 32 threads).
Looking at the spinlock code, I found :
 cur_delay += (int) (cur_delay * ((double) random() / (double) MAX_RANDOM_VALUE) + 0.5);

I understand the reasoning for the backoff (as of the discussion on
2003-08-05), but is there any particular reason for using floating
point operations here ?   Maybe a modulo would be just as good (or
better since it doesn't involve the FPU) ?

Something like:   cur_delay  +=  random() % (cur_delay + 1) ;


--Magne


В списке pgsql-hackers по дате отправления: