Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aIuDV-0003pq-Dg for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Jan 2016 08:22:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aIuDV-0002dD-0D for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Jan 2016 08:22:13 +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 1aIuDU-0002aQ-0m for pgsql-hackers@postgresql.org; Tue, 12 Jan 2016 08:22:12 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aIuDR-00020A-Fi for pgsql-hackers@postgresql.org; Tue, 12 Jan 2016 08:22:11 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 47A5121C5761; Tue, 12 Jan 2016 11:22:08 +0300 (MSK) Received: from mail.postgrespro.ru ([127.0.0.1]) by localhost (mail.postgrespro.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qMwzC0v34piT; Tue, 12 Jan 2016 11:22:07 +0300 (MSK) Received: from fujitsu (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 7949721C5760; Tue, 12 Jan 2016 11:22:07 +0300 (MSK) Date: Tue, 12 Jan 2016 11:20:05 +0300 From: Aleksander Alekseev To: Alvaro Herrera Cc: Robert Haas , Teodor Sigaev , Andres Freund , "pgsql-hackers@postgresql.org" Subject: Re: Patch: fix lock contention for HASHHDR.mutex Message-ID: <20160112112005.26675392@fujitsu> In-Reply-To: <20160112001642.GA802875@alvherre.pgsql> References: <20151230160137.034371e0@fujitsu> <20160112001642.GA802875@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) 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 Hello, =C3=81lvaro > So you were saying some posts upthread that the new hash tables would > "borrow" AN elements from the freelist then put AN elements back when > too many got unused. Is that idea embodied in this patch? Right. It didn't satisfy "use all memory" requirement anyway. It's better to sacrifice a few TPS (according only to my benchmark which doesn't represent all possible use cases) than accidentally break someones system after upgrading to the next version of PostgreSQL. See example with pg_dump given by Robert Haas above. >> +/* Number of partitions of the shared buffer mapping hashtable */ >> +#define NUM_BUFFER_PARTITIONS NUM_LOCK_PARTITIONS >> + >> /* Number of partitions the shared predicate lock tables are divided >> into */ #define LOG2_NUM_PREDICATELOCK_PARTITIONS 4 >> #define NUM_PREDICATELOCK_PARTITIONS (1 << >> LOG2_NUM_PREDICATELOCK_PARTITIONS)=20=20 > > I find this odd. Why is it a good idea to define the bufMapping > partitions like this? What's the explanation for the performance > numbers you saw? My mistake. I thought that last table was self-explanatory. We see that a single spinlock for accessing a freeList (current implementation) is obviously a bottleneck. Replacing it with say an array of spinlocks reduces lock contention and therefore gives more TPS (see first row). Also we can increase concurrency level even further by increasing number of lock partitions (see columns "no locks", "lwlock" and "spinlock array"). Previously it couldn't help us (see "master" column) because of a bottleneck. If you have any other questions regarding this patch please don't hesitate to ask. Best regards, Aleksander --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers