Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eYYtb-0005iA-Cy for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Jan 2018 14:59:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eYYta-0004fy-M2 for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Jan 2018 14:59:26 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eYYrT-0006L3-Dd for pgsql-hackers@lists.postgresql.org; Mon, 08 Jan 2018 14:57:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eYYrP-0001xC-Rw for pgsql-hackers@postgresql.org; Mon, 08 Jan 2018 14:57:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w08Ev5me029043; Mon, 8 Jan 2018 09:57:05 -0500 From: Tom Lane To: Thomas Munro cc: Robert Haas , Andres Freund , Pg Hackers Subject: Re: Condition variable live lock In-reply-to: References: <20171229193843.tsbob2xsjfmxkq2g@alap3.anarazel.de> <20180104205447.mdaub47aunp3h3mq@alap3.anarazel.de> <17054.1515126429@sss.pgh.pa.us> <21761.1515132657@sss.pgh.pa.us> <23234.1515134575@sss.pgh.pa.us> <15204.1515166090@sss.pgh.pa.us> <14191.1515173593@sss.pgh.pa.us> <9342.1515181117@sss.pgh.pa.us> <10713.1515182599@sss.pgh.pa.us> <26266.1515272424@sss.pgh.pa.us> <28942.1515275038@sss.pgh.pa.us> <2437.1515368316@sss.pgh.pa.us> <31228.1515378851@sss.pgh.pa.us> Comments: In-reply-to Thomas Munro message dated "Tue, 09 Jan 2018 00:41:36 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29041.1515423425.1@sss.pgh.pa.us> Date: Mon, 08 Jan 2018 09:57:05 -0500 Message-ID: <29042.1515423425@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Munro 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