Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZXSv4-0007P7-Am for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Sep 2015 11:43:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZXSv2-0001E9-WE for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Sep 2015 11:43:05 +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) (envelope-from ) id 1ZXStk-0008Bw-Qm for pgsql-hackers@postgresql.org; Thu, 03 Sep 2015 11:41:44 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZXSth-0004DM-9c for pgsql-hackers@postgresql.org; Thu, 03 Sep 2015 11:41:43 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id D09AB860002; Thu, 3 Sep 2015 13:41:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-5.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p54AF4EF5.dip0.t-ipconnect.de [84.175.78.245]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 987AE860001; Thu, 3 Sep 2015 13:41:37 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id 27309100D9F; Thu, 3 Sep 2015 13:41:37 +0200 (CEST) Date: Thu, 3 Sep 2015 13:41:37 +0200 From: Andres Freund To: Amit Kapila Cc: pgsql-hackers Subject: Re: Speed up Clog Access by increasing CLOG buffers Message-ID: <20150903114137.GE27649@awork2.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Pg-Spam-Score: -4.2 (----) 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 2015-09-01 10:19:19 +0530, Amit Kapila wrote: > pgbench setup > ------------------------ > scale factor - 300 > Data is on magnetic disk and WAL on ssd. > pgbench -M prepared tpc-b > > HEAD - commit 0e141c0f > Patch-1 - increase_clog_bufs_v1 > > Client Count/Patch_ver 1 8 16 32 64 128 256 HEAD 911 5695 9886 18028 27851 > 28654 25714 Patch-1 954 5568 9898 18450 29313 31108 28213 > > > This data shows that there is an increase of ~5% at 64 client-count > and 8~10% at more higher clients without degradation at lower client- > count. In above data, there is some fluctuation seen at 8-client-count, > but I attribute that to run-to-run variation, however if anybody has doubts > I can again re-verify the data at lower client counts. > Now if we try to further increase the number of CLOG buffers to 128, > no improvement is seen. > > I have also verified that this improvement can be seen only after the > contention around ProcArrayLock is reduced. Below is the data with > Commit before the ProcArrayLock reduction patch. Setup and test > is same as mentioned for previous test. The buffer replacement algorithm for clog is rather stupid - I do wonder where the cutoff is that it hurts. Could you perhaps try to create a testcase where xids are accessed that are so far apart on average that they're unlikely to be in memory? And then test that across a number of client counts? There's two reasons that I'd like to see that: First I'd like to avoid regression, second I'd like to avoid having to bump the maximum number of buffers by small buffers after every hardware generation... > /* > * Number of shared CLOG buffers. > * > - * Testing during the PostgreSQL 9.2 development cycle revealed that on a > + * Testing during the PostgreSQL 9.6 development cycle revealed that on a > * large multi-processor system, it was possible to have more CLOG page > - * requests in flight at one time than the number of CLOG buffers which existed > - * at that time, which was hardcoded to 8. Further testing revealed that > - * performance dropped off with more than 32 CLOG buffers, possibly because > - * the linear buffer search algorithm doesn't scale well. > + * requests in flight at one time than the number of CLOG buffers which > + * existed at that time, which was 32 assuming there are enough shared_buffers. > + * Further testing revealed that either performance stayed same or dropped off > + * with more than 64 CLOG buffers, possibly because the linear buffer search > + * algorithm doesn't scale well or some other locking bottlenecks in the > + * system mask the improvement. > * > - * Unconditionally increasing the number of CLOG buffers to 32 did not seem > + * Unconditionally increasing the number of CLOG buffers to 64 did not seem > * like a good idea, because it would increase the minimum amount of shared > * memory required to start, which could be a problem for people running very > * small configurations. The following formula seems to represent a reasonable > * compromise: people with very low values for shared_buffers will get fewer > - * CLOG buffers as well, and everyone else will get 32. > + * CLOG buffers as well, and everyone else will get 64. > * > * It is likely that some further work will be needed here in future releases; > * for example, on a 64-core server, the maximum number of CLOG requests that > * can be simultaneously in flight will be even larger. But that will > * apparently require more than just changing the formula, so for now we take > - * the easy way out. > + * the easy way out. It could also happen that after removing other locking > + * bottlenecks, further increase in CLOG buffers can help, but that's not the > + * case now. > */ I think the comment should be more drastically rephrased to not reference individual versions and numbers. Greetings, Andres Freund -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers