Re: Adjustment of spinlock sleep delays
От | Tom Lane |
---|---|
Тема | Re: Adjustment of spinlock sleep delays |
Дата | |
Msg-id | 27392.1060188994@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Adjustment of spinlock sleep delays (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-hackers |
I said: > The random component should already help to scatter the wakeups pretty > well, so I'm thinking about just > if (oldtime > 1 sec) > time = 10msec > else > time = oldtime + oldtime * rand() > ie random growth of a maximum of 2x per try, and reset to minimum delay > when you get past 1 sec. This would guarantee at least as many tries > as I'm getting currently with the deterministic algorithm (which is > effectively this if rand() always returned 1). Eventually it occurred to me that when using random delays, we should set the timeout to occur after a fixed number of tries, not after a fixed total time spent. This is because the probability of unwanted failure (ie, the spinlock isn't really stuck, you just managed to always look when someone else had it) depends directly on the number of tries. I've committed code that does the above with a limit of 1000 iterations; timeout seems to take about 3.5 minutes on average. (In the prior code we would make 6000 attempts over a period of 1 minute.) regards, tom lane
В списке pgsql-hackers по дате отправления: