Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ahvXQ-0003Fs-Dw for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Mar 2016 08:50: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 1ahvXP-0005Je-3S for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Mar 2016 08:50:11 +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 1ahvW2-0003nL-D8 for pgsql-hackers@postgresql.org; Mon, 21 Mar 2016 08:48:46 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ahvVt-0003hq-En for pgsql-hackers@postgresql.org; Mon, 21 Mar 2016 08:48:45 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 285D821C70AE; Mon, 21 Mar 2016 11:48:37 +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 YSW-2Q19Raz4; Mon, 21 Mar 2016 11:48:34 +0300 (MSK) Received: from fujitsu (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 4CC9F21C6E81; Mon, 21 Mar 2016 11:48:34 +0300 (MSK) Date: Mon, 21 Mar 2016 11:48:15 +0300 From: Aleksander Alekseev To: Amit Kapila Cc: Robert Haas , pgsql-hackers , Anastasia Lubennikova Subject: Re: Patch: fix lock contention for HASHHDR.mutex Message-ID: <20160321114815.4cd8a089@fujitsu> In-Reply-To: References: <20160208192857.GA316589@alvherre.pgsql> <20160210112400.22c0b677@fujitsu> <20160211171101.33f34160@fujitsu> <20160212183445.716b2845@fujitsu> <20160301174313.218e04c7@fujitsu> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 > This is the point where I think I am missing something about patch. > As far as I can understand, it uses the same freelist index > (freelist_idx) for allocating and putting back the entry, so I think > the chance of increment in one list and decrement in another is there > when the value of freelist_idx is calculated differently for the same > input, is it so, or there is something else in patch which I am > missing? You are right, nentries _can't_ be negative unless we are using getpid() for calculating freelist_idx, since same index of nentries[] is used when we add (increment) and remove (decrement) element from/to hash table. The fact that we also borrow elements from other freelists if there is no more elements in our freelist doesn't change anything. > One idea is to jigger things so that we maintain a count of the total > number of entries that doesn't change except when we allocate, and > then for each freelist partition we maintain the number of entries in > that freelist partition. So then the size of the hash table, instead > of being sum(nentries) is totalsize - sum(nfree). This is an interesting idea. Still I strongly disagree that is should be implemented in this concrete patch and discussed in this concrete thread. Obviously such type of change deserves a separate research and discussing since it has nothing to do with performance and since we agreed that "change LOG2_NUM_LOCK_PARTITIONS value" and "change the calling convention for ShmemInitHash()" patches should be implemented separately. I added it to my TODO list. Once again I suggest we merge this patch already: http://www.postgresql.org/message-id/CA+Tgmobtf9nH566_jjs=jrTyMq5HdQdaRF5j7o+AbdOWQHE_Ow@mail.gmail.com I have a strong feeling that we are just wasting our time here. -- Best regards, Aleksander Alekseev http://eax.me/ -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers