Re: LWLock contention: I think I understand the problem

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: LWLock contention: I think I understand the problem
Дата
Msg-id 19542.1009655128@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: LWLock contention: I think I understand the problem  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: LWLock contention: I think I understand the problem  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-hackers
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> I still need to think about this, but the above idea doesn't seem good. 
> Right now, we wake only one waiting process who gets the lock while
> other waiters stay sleeping, right?  If we don't give them the lock,
> don't we have to wake up all the waiters?

No.  We'll still wake up the same processes as now: either one would-be
exclusive lock holder, or multiple would-be shared lock holders.
But what I'm proposing is that they don't get granted the lock at that
instant; they have to try to get the lock once they actually start to
run.

Once in a while, they'll fail to get the lock, either because the
original releaser reacquired the lock, and then ran out of his time
quantum before releasing it, or because some third process came along
and acquired the lock.  In either of these scenarios they'd have to
block again, and we'd have wasted a process dispatch cycle.  The
important thing though is that the current arrangement wastes a process
dispatch cycle for every acquisition of a contended-for lock.

What I had not really focused on before, but it's now glaringly obvious,
is that on modern machines one process time quantum (0.01 sec typically)
is enough time for a LOT of computation, in particular an awful lot of
trips through the buffer manager or other modules with shared state.
We want to be sure that a process can repeatedly acquire and release
the shared lock for as long as its time quantum holds out, even if there
are other processes waiting for the lock.  Otherwise we'll be swapping
processes too often.
        regards, tom lane


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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: LWLock contention: I think I understand the problem
Следующее
От: Tom Lane
Дата:
Сообщение: Re: LWLock contention: I think I understand the problem