Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bbt5k-0006xN-7a for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Aug 2016 17:32:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bbt5j-0004Uw-Jh for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Aug 2016 17:32:55 +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 1bbt5i-0004Up-RX for pgsql-hackers@postgresql.org; Mon, 22 Aug 2016 17:32:54 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bbt5b-0001wJ-Ox for pgsql-hackers@postgresql.org; Mon, 22 Aug 2016 17:32:54 +0000 Received: by mail-wm0-x22a.google.com with SMTP id o80so156177546wme.1 for ; Mon, 22 Aug 2016 10:32:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:from:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=/w+Zvy8Vkc2eQ7lU6xfkIrfzjMtlPplT02wduC5zrdo=; b=i/Nl5sj9DtYHOhH0Wdaff0abYmzbSfW1Tc3aA68prPe8hsGq3Fvf/kNjVJJ5uKWQnJ AOAKv6pC8ayBLJsFy7RHCv2K87PuwrX5Y+CrazyGlY+YTlfAR0KW61QAoDyim4aJrGWP FMsizt4UVK3aAkgocl0A17dlF3+AAJ6iTrewo6JX7PnAmNRnx6etiR34YsgN4qj2Rg5d qvdT+eeZiznI5xNHohplq7LZbkKVTIZzJ4SQSTWs4/14rMjdJv/qYDsrpbJjlkbzgQb2 oap2xgqrjfIgJV4My/IvBbIzOQNPw798F9Uaa8uN4mREoI/6D8F/yu2R5xEv7+wf55qs 3Hmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:from:cc:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=/w+Zvy8Vkc2eQ7lU6xfkIrfzjMtlPplT02wduC5zrdo=; b=USNREOz9RqBQ7SMx32t886MQQG9KYR2hNWyNFhDaBR5p9Q4NActqk4W0Fy0JDM07A/ kbCM18Ve+vBjDca97JlFcS83AljGB+rJleRt6iRHtZuA0GqFP0FVa5PkLurTHSEHX6qs XFR/cRQ0/+w6Y5MJsfZhdAyJ/J19tXDb/EqAMsIh6tjEhzsY/5WaZlovudC7nfk9ZjMJ u1rsKuYZe3CaPNALICvTzHSQWpQ7SMZIgkGkRenmUk/icISEQek4dT8CLb4he3Y7VIwg SoyVXqwE5g4JMu6xgUZRRD72yp+ww/4oHifraCqDgEkazmfJnOl66nj5Kx7uz0kxibKv yFsQ== X-Gm-Message-State: AEkoout2H5Bw7uWi3SOvHcB6qYWL7SUmIW5GH1CwCS7oWaymG/E3cnpaSYYS7T1+I8FEWQ== X-Received: by 10.194.58.112 with SMTP id p16mr17957926wjq.24.1471887166710; Mon, 22 Aug 2016 10:32:46 -0700 (PDT) Received: from [192.168.1.111] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by smtp.gmail.com with ESMTPSA id o4sm25283614wjd.15.2016.08.22.10.32.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Aug 2016 10:32:45 -0700 (PDT) Subject: Re: Proposal for CSN based snapshots To: Robert Haas References: <51B6C97B.1070000@bluegap.ch> <53889CCB.7030005@vmware.com> <20140530152721.GC30516@awork2.anarazel.de> <5388D02D.6040305@vmware.com> <539AD153.9000004@vmware.com> <1409043789.2335.330.camel@jeff-desktop> <53FC6545.7000501@vmware.com> <1409116988.2335.463.camel@jeff-desktop> <53FD7D65.9040602@vmware.com> <53FD7DCC.5020005@vmware.com> <69041c5a-ec60-3c54-49d0-5df071b27f52@iki.fi> <389b45d1-f4f8-a333-03ef-efb94c8d6087@iki.fi> From: Heikki Linnakangas Cc: Alexander Korotkov , Simon Riggs , Dilip Kumar , Jeff Davis , PostgreSQL-development , Alvaro Herrera , Greg Stark , Andres Freund , Rajeev rastogi , Markus Wanner , Ants Aasma , Bruce Momjian , obartunov , Teodor Sigaev Message-ID: Date: Mon, 22 Aug 2016 20:32:42 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 08/22/2016 07:49 PM, Robert Haas wrote: > Nice to see you working on this again. > > On Mon, Aug 22, 2016 at 12:35 PM, Heikki Linnakangas wrote: >> A sequential scan of a table like that with 10 million rows took about 700 >> ms on my laptop, when the hint bits are set, without this patch. With this >> patch, if there's a snapshot holding back the xmin horizon, so that we need >> to check the CSN log for every XID, it took about 30000 ms. So we have some >> optimization work to do :-). I'm not overly worried about that right now, as >> I think there's a lot of room for improvement in the SLRU code. But that's >> the next thing I'm going to work. > > So the worst case for this patch is obviously bad right now and, as > you say, that means that some optimization work is needed. > > But what about the best case? If we create a scenario where there are > no open read-write transactions at all and (somehow) lots and lots of > ProcArrayLock contention, how much does this help? I ran some quick pgbench tests on my laptop, but didn't see any meaningful benefit. I think the best I could see is about 5% speedup, when running "pgbench -S", with 900 idle connections sitting in the background. On the positive side, I didn't see much slowdown either. (Sorry, I didn't record the details of those tests, as I was testing many different options and I didn't see a clear difference either way.) It seems that Amit's PGPROC batch clearing patch was very effective. I remember seeing ProcArrayLock contention very visible earlier, but I can't hit that now. I suspect you'd still see contention on bigger hardware, though, my laptop has oly 4 cores. I'll have to find a real server for the next round of testing. > Because there's only a purpose to trying to minimize the losses if > there are some gains to which we can look forward. Aside from the potential performance gains, this slashes a lot of complicated code: 70 files changed, 2429 insertions(+), 6066 deletions(-) That removed code is quite mature at this point, and I'm sure we'll add some code back to this patch as it evolves, but still. Also, I'm looking forward for a follow-up patch, to track snapshots in backends at a finer level, so that vacuum could remove tuples more aggressively, if you have pg_dump running for days. CSN snapshots isn't a strict requirement for that, but it makes it simpler, when you can represent a snapshot with a small fixed-size integer. Yes, seeing some direct performance gains would be nice too. - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers