Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXTuv-0001Pq-BL for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jan 2018 15:28:21 +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 1eXTuu-00084j-Nt for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jan 2018 15:28:20 +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 1eXTuu-00084Z-ER for pgsql-hackers@lists.postgresql.org; Fri, 05 Jan 2018 15:28:20 +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 1eXTuo-0000zW-1m for pgsql-hackers@postgresql.org; Fri, 05 Jan 2018 15:28:19 +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 w05FSAgK015205; Fri, 5 Jan 2018 10:28:10 -0500 From: Tom Lane To: Thomas Munro cc: Andres Freund , Robert Haas , 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> Comments: In-reply-to Thomas Munro message dated "Fri, 05 Jan 2018 23:14:25 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <15203.1515166090.1@sss.pgh.pa.us> Date: Fri, 05 Jan 2018 10:28:10 -0500 Message-ID: <15204.1515166090@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Munro writes: > Could we install the sentinel and pop the first entry at the same > time, so that we're not adding an extra spinlock acquire/release? Hm, maybe. Other ideas in that space: * if queue is empty when we first acquire the spinlock, we don't have to do anything at all. * if queue is empty after we pop the first entry, we needn't bother installing our sentinel, just signal that proc and we're done. It's a question of how complicated you're willing to make this logic, and whether you trust that we'll be able to test all the code paths. regards, tom lane