Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1assoa-00028D-PB for pgsql-committers@arkaria.postgresql.org; Wed, 20 Apr 2016 14:09:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1assoa-0002KH-0E for pgsql-committers@arkaria.postgresql.org; Wed, 20 Apr 2016 14:09:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1assoZ-0002J0-6N for pgsql-committers@postgresql.org; Wed, 20 Apr 2016 14:09:11 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1assoR-000853-QH for pgsql-committers@postgresql.org; Wed, 20 Apr 2016 14:09:10 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 3241B20744 for ; Wed, 20 Apr 2016 10:09:01 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Wed, 20 Apr 2016 10:09:01 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=87fThTsDOTAS+PbIFZeVeOze3jg=; b=E/MfG EstyEwCcQoOeUPAfh3Hh8qiaw57zF9uOpnFPGqsw8Xe+suJgtEbvubnaVzDiNNkb wBC2zSMdnD+N0fn9e0iYTeHVuZ3LfWaURckPeYrCPQV8d5bXvO7QLkycvp/JhGGf uq8RWNsDQgP1xHtIVbbaM8gScYt1xxTe4S/KCE= X-Sasl-enc: GqcNs7RY1HEckr86s7d83wx/k6oTfE/4dXZUYq8Ryo0g 1461161340 Received: from intern.anarazel.de (unknown [64.80.128.10]) by mail.messagingengine.com (Postfix) with ESMTPA id B378C68013B; Wed, 20 Apr 2016 10:09:00 -0400 (EDT) Date: Wed, 20 Apr 2016 07:09:00 -0700 From: Andres Freund To: Amit Kapila Cc: Noah Misch , Kevin Grittner , Robert Haas , Kevin Grittner , "pgsql-hackers@postgresql.org" , "pgsql-committers@postgresql.org" Subject: Re: [HACKERS] Re: pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold < Message-ID: <20160420140900.srcy57hfmumjswqy@alap3.anarazel.de> References: <20160413171955.i53me46fqqhdlztq@alap3.anarazel.de> <20160413192110.fogwesjti3kxycnu@alap3.anarazel.de> <20160413200148.bawmwjdmggbllhha@alap3.anarazel.de> <20160416204452.GA1910190@tornado.leadboat.com> <20160416205630.puxsglckxi3sn5ec@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org On 2016-04-19 20:27:31 +0530, Amit Kapila wrote: > On Sun, Apr 17, 2016 at 2:26 AM, Andres Freund wrote: > > > > On 2016-04-16 16:44:52 -0400, Noah Misch wrote: > > > That is more controversial than the potential ~2% regression for > > > old_snapshot_threshold=-1. Alvaro[2] and Robert[3] are okay releasing > > > that way, and Andres[4] is not. > > > > FWIW, I could be kinda convinced that it's temporarily ok, if there'd be > > a clear proposal on the table how to solve the scalability issue around > > MaintainOldSnapshotTimeMapping(). > > > > It seems that for read-only workloads, MaintainOldSnapshotTimeMapping() > takes EXCLUSIVE LWLock which seems to be a probable reason for a > performance regression. Yes, that's the major problem. > Now, here the question is do we need to acquire that lock if xmin is > not changed since the last time value of > oldSnapshotControl->latest_xmin is updated or xmin is lesser than > equal to oldSnapshotControl->latest_xmin? If we don't need it for > above cases, I think it can address the performance regression to a > good degree for read-only workloads when the feature is enabled. I think the more fundamental issue is that the time->xid mapping is built at GetSnapshotData() time (via MaintainOldSnapshotTimeMapping()), and not when xids are assigned. Snapshots are created a lot more frequently in nearly all use-cases than xids are assigned. That's what forces the exclusive lock to be in the read path, rather than the write path. What's the reason for this? Greetings, Andres Freund -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers