Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cB4Py-0007lG-VG for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Nov 2016 18:43:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cB4Px-0004tA-Lk for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Nov 2016 18:43: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_2) (envelope-from ) id 1cB4Pv-0004sJ-6f for pgsql-hackers@postgresql.org; Sun, 27 Nov 2016 18:43:11 +0000 Received: from mail-wj0-x229.google.com ([2a00:1450:400c:c01::229]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cB4Pn-0007Fr-43 for pgsql-hackers@postgresql.org; Sun, 27 Nov 2016 18:43:09 +0000 Received: by mail-wj0-x229.google.com with SMTP id v7so98127785wjy.2 for ; Sun, 27 Nov 2016 10:43:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=2A65Y1Kr3BgbPWWyvogYWMklyHu9lbnF9ifrOoDRI3Q=; b=jxnFpmDDjF6afqboPwGwKOWeSThngCy9se94CMAKdLXF9b+qosBK2oQq2byM9pKeV/ dJe3sn+wUi6Al8yATijcqI049g/pd5+4d0/jEoo/FDbwZ06ZvSZAN7NJRi2mimj64vBV V3Bt5wwBRtfwnQ4Auu9ZwnP2ypTyb8fs6MRfA7KRlUb64YdhgNSA3lbCR2cytOY1o8U0 sp0ez+I8/VuU2kJ5ChVWtDPZ++a38FqZpYuVp9QWQoABY/2ADpop440MvW1GFzsIEEjU WSuGBJERUlqLFrkLhjx5WaC6Ib5d/nluoWuLWf1rJNpuICxfG6yL5MboMG4D7L+9Jjql RYcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=2A65Y1Kr3BgbPWWyvogYWMklyHu9lbnF9ifrOoDRI3Q=; b=f5Uu84pwri0uMhcEfV1NK4rHWl26keePTV+fIzMOXLto5GqGXnMnnVq7q15iphvZ4d PrKSlc3cwuV+BNSEjLEJJ8+gPBH9PYcdr0PUNp+T2uyzLNg3UQvQX3G1xhHiQ56xcsob e/3ZDka45t9LpRfnDwVz0FPxl3bxGzaHw9U50MAJ3si+bD0iOZLpwDVctdWdEiZ5QlcP QdcIbhBxa+XDhzoTpmarDePCz2kQbVL2XDnevlWmmDUO0JdvoqXpQG5JIpJQvrxFCoBt OIP+pqs62pQ/CsDv7e7v4dBdYZjyIukkSricAysHAOIUI4VDEjx1mJIkEQ5Esrhnqes2 ubpQ== X-Gm-Message-State: AKaTC03YFaKwHep8jyNSEQddBemvjn9dsAJcJMKATzfVLD9vi7oCnpXL/cQDcU4tK8R8PmulHrH1XhPteIZ16u2U/73w2vUm2E7bNTtpAt3LJzk16BZWDCnScaFpJT82Vj8tgDfPv9L9HVamVzEbNVUaK1Ky/U1ltXj5JCONwBkvxFCAJtmUGiwX8NiEaEKK9mmp9w77lnES X-Received: by 10.194.201.133 with SMTP id ka5mr17183719wjc.151.1480272181800; Sun, 27 Nov 2016 10:43:01 -0800 (PST) Received: from [10.137.2.17] (ip-89-177-46-65.net.upcbroadband.cz. [89.177.46.65]) by smtp.gmail.com with ESMTPSA id w18sm24810158wme.9.2016.11.27.10.43.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Nov 2016 10:43:01 -0800 (PST) Subject: Re: PATCH: two slab-like memory allocators To: Petr Jelinek , Andres Freund References: <11821eb9-95a5-353e-ccba-13e8e9351e62@2ndquadrant.com> <9818b54a-fcb6-f018-0b16-96d6a1d1da27@2ndquadrant.com> <34a6d4ea-7f3d-a62c-fff1-7a9108c078d7@2ndquadrant.com> <4f176a6c-c197-165d-dee4-5de8f279f1f4@2ndquadrant.com> <20161112191257.3a4n6kzegvu637qn@alap3.anarazel.de> <0b14e90b-1985-bb04-0261-2fcdc28755ab@2ndquadrant.com> <9cdbe694-1b49-0c61-b0b2-d95ef2b3cb31@2ndquadrant.com> Cc: Robert Haas , John Gorman , pgsql-hackers From: Tomas Vondra Message-ID: <98735a6c-c376-86bb-8cb2-1878a0c13bdb@2ndquadrant.com> Date: Sun, 27 Nov 2016 19:42:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <9cdbe694-1b49-0c61-b0b2-d95ef2b3cb31@2ndquadrant.com> Content-Type: text/plain; charset=utf-8; format=flowed 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 On 11/27/2016 07:25 PM, Petr Jelinek wrote: > On 15/11/16 01:44, Tomas Vondra wrote: >> Attached is v6 of the patch series, fixing most of the points: >> >> * common bits (valgrind/randomization/wipe) moved to memdebug.h/c >> >> Instead of introducing a new header file, I've added the prototypes to >> memdebug.h (which was already used for the valgrind stuff anyway), and >> the implementations to a new memdebug.c file. Not sure what you meant by >> "static inlines" though. > > I think Andres wanted to put the implementation to the static inline > functions directly in the header (see parts of pg_list or how atomics > work), but I guess you way works too. > I see. Well turning that into static inlines just like in pg_list is possible. I guess the main reason is performance - for pg_list that probably makes sense, but the memory randomization/valgrind stuff is only ever used for debugging, which already does a lot of expensive stuff anyway. >> >> I've however kept SlabContext->freelist as an array, because there may >> be many blocks with the same number of free chunks, in which case moving >> the block in the list would be expensive. This way it's simply >> dlist_delete + dlist_push. >> > > +1 > > I get mxact isolation test failures in test_decoding with this version > of patch: > step s0w: INSERT INTO do_write DEFAULT VALUES; > + WARNING: problem in slab TXN: number of free chunks 33 in block > 0x22beba0 does not match bitmap 34 > step s0start: SELECT data FROM > pg_logical_slot_get_changes('isolation_slot', NULL, NULL, > 'include-xids', 'false'); > data > and > step s0alter: ALTER TABLE do_write ADD column ts timestamptz; > step s0w: INSERT INTO do_write DEFAULT VALUES; > + WARNING: problem in slab TXN: number of free chunks 33 in block > 0x227c3f0 does not match bitmap 34 > step s0start: SELECT data FROM > pg_logical_slot_get_changes('isolation_slot', NULL, NULL, > 'include-xids', 'false'); > data > D'oh! I believe this is a simple thinko in SlabCheck, which iterates over chunks like this: for (j = 0; j <= slab->chunksPerBlock; j++) ... which is of course off-by-one error (and the 33 vs. 34 error message is consistent with this theory). > > Also, let's just rename the Gen to Generation. > OK. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers