Re: Condition variable live lock

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Condition variable live lock
Date: 2018-01-08 14:57:05
Message-ID: 29042.1515423425@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com> writes:
> One very small thing after another look:

> - Assert(cv_sleep_target == NULL);
> + if (cv_sleep_target != NULL)
> + ConditionVariableCancelSleep();

> The test for cv_sleep_target != NULL is redundant since
> ConditionVariableCancelSleep() would return early.

True. I did that because Robert was already objecting to the cost
of an added test-and-branch here, so I figured he'd be really
unhappy with the cost of a function call plus test-and-branch ;-)

> ConditionVariableBroadcast() doesn't do that.

Yup. I considered removing the discrepancy by adding a similar
if-guard in ConditionVariableBroadcast(). The internal test in
ConditionVariableCancelSleep would then be only for the benefit
of outside callers such as AbortTransaction, but that seems fine
and per its documentation.

Or we could remove those if's and save a few bytes at the
cost of some cycles. I don't care much.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ken Huffman 2018-01-08 15:11:02 PL/Python SD dict wiped?
Previous Message David Rowley 2018-01-08 14:08:16 Re: [HACKERS] UPDATE of partition key