Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bwcsl-00029h-Ut for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Oct 2016 22:29:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bwcsk-0003sZ-Tp for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Oct 2016 22:29:14 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bwcrL-0002Hz-QV for pgsql-hackers@postgresql.org; Tue, 18 Oct 2016 22:27:47 +0000 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bwcrI-0000eg-1R for pgsql-hackers@postgresql.org; Tue, 18 Oct 2016 22:27:46 +0000 Received: by mail-wm0-x22f.google.com with SMTP id c78so18876553wme.0 for ; Tue, 18 Oct 2016 15:27:43 -0700 (PDT) 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=SLMLNAspfqGskd9iJNomO7dfBqR3lVLjCSZE1ranWYA=; b=aEfRS+H5T8R7/IX9iL3vUlyyydj/FEbfgMnXpIy6jfKhlu7SJwe5eG4Cn7wgQOaF1Z oTl4hklSjcl52Qs+3yWzrB3U7y28XCQkOVA9QRZJCOiIIvevMQGTUXlAfHVVcqNrjdiL Vghp789zSwIHWqr4GQ5l4UZWxzjT3OSDOp50YKro0yfc4HWq0/Yf3Outq9mSkMuEz2DP y+vNR0s/mvqBykgixKmfGASGBlfKdiYf1INTEDK9dznxBx4r/OkJe3JY3C2Mpk+7+i09 w/QvLjHUwMgVOMALFtlUaawHR4GU3nHhtOCjavqudZPdAF2+jv6wiOh4Mkbtw18ifhd4 whPA== 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=SLMLNAspfqGskd9iJNomO7dfBqR3lVLjCSZE1ranWYA=; b=I7cBVdr+yPb2xNymYQ350NAW+6pmBZ5GkKjPUs1EHy1f+ETBt+XQhYyMRsnTGbf811 tLOE7asHZrfIw4TVfYSZTT++AZ2GUDqq/wr9F9k0nSH0xirifZ1KvBhbqz1JW71PfMbc +txvMEcZjwYGChEk8yQnwNNeMZwvqLM8Snaqe3gA7jlYQnPcGsoBakaDXZK4nID4j17/ gsTqpHn6oQIVp8AMC0Nm3TWJsrGC8E0HmKq4t59Rnj+Pw7qyn6oiz8z0tht4aKrxatJu i7tEBzGLfeU+yHLkzA55pSGTUZOZ0m3jC90w0zrTIxRavHly+uH+qSvkuc2lsdUWQjXU YBGA== X-Gm-Message-State: AA6/9RkBwSUgqeRwDdByEDLHm46i8k8Q2MHf2zIsd6lnzgovh0GzrtV9sedO/qz4JJBkMNhFQgo9gdvBPI+msboqIBNcPTYDYV1kqdVogwIROJ9GEgakfJ40dsIBA2wWdnG0vyzQAujMrVWS+N7G4W8H73ZRrKNuQDHvub3wDjw9wkyyaklcxai25UKn2/5JpA== X-Received: by 10.194.179.41 with SMTP id dd9mr1352950wjc.146.1476829661818; Tue, 18 Oct 2016 15:27:41 -0700 (PDT) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id m131sm1650355wmf.23.2016.10.18.15.27.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Oct 2016 15:27:40 -0700 (PDT) Subject: Re: PATCH: two slab-like memory allocators To: Robert Haas , Tomas Vondra References: <68b837a3-ce55-f9a2-f685-9eafac536f21@2ndquadrant.com> <885540a7-ac72-5a21-6dae-a4d5b50672da@2ndquadrant.com> <03110c11-ea72-7b4d-027d-6f19eb300b2a@2ndquadrant.com> <11821eb9-95a5-353e-ccba-13e8e9351e62@2ndquadrant.com> Cc: John Gorman , pgsql-hackers From: Petr Jelinek Message-ID: Date: Wed, 19 Oct 2016 00:27:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 18/10/16 22:25, Robert Haas wrote: > On Wed, Oct 5, 2016 at 12:22 AM, Tomas Vondra > wrote: >> attached is v3 of the patches, with a few minor fixes in Slab, and much >> larger fixes in GenSlab. >> >> Slab (minor fixes) >> ------------------ >> - Removed the unnecessary memset() of new blocks in SlabAlloc(), although we >> still need to zero the free bitmap at the end of the block. >> - Renamed minFreeCount to minFreeChunks, added a few comments explaining >> why/how firstFreeChunk and minFreeChunks are maintained. >> - Fixed / improved a bunch of additional comments, based on feedback. > > I had a look at 0001 today, but it seems to me that it still needs > work. It's still got a lot of remnants of where you've > copy-and-pasted aset.c. I dispute this allegation: > > + * SlabContext is our standard implementation of MemoryContext. > Are you looking at old version of the patch? I complained about this as well and Tomas has changed that. > And then there's this: > > +#ifdef HAVE_ALLOCINFO > +#define SlabFreeInfo(_cxt, _chunk) \ > + fprintf(stderr, "AllocFree: %s: %p, %d\n", \ > + (_cxt)->header.name, (_chunk), (_chunk)->size) > +#define SlabAllocInfo(_cxt, _chunk) \ > + fprintf(stderr, "AllocAlloc: %s: %p, %d\n", \ > + (_cxt)->header.name, (_chunk), (_chunk)->size) > > Well, it's pretty stupid that AllocSetAlloc is reporting it's name as > AllocAlloc, a think that, as far as I can tell, is not real. But > having this new context type also pretend to be AllocAlloc is even > dumber. You are definitely looking at old version. > > More broadly, I'm not sure I like this design very much. The whole > point of a slab context is that all of the objects are the same size. > I wouldn't find it too difficult to support this patch if we were > adding an allocator for fixed-size objects that was then being used to > allocate objects which are fixed size. However, what we seem to be > doing is creating an allocator for fixed-size objects and then using > it for variable-size tuples. That's really pretty weird. Isn't the > root of this problem that aset.c is utterly terrible at handling large > number of allocations? Maybe we should try to attack that problem > more directly. It's used for TXNs which are fixed and some tuples (there is assumption that the decoded tuples have more or less normal distribution). I agree though that the usability beyond the ReoderBuffer is limited because everything that will want to use it for part of allocations will get much more complicated by the fact that it will have to use two different allocators. I was wondering if rather than trying to implement new allocator we should maybe implement palloc_fixed which would use some optimized algorithm for fixed sized objects in our current allocator. The advantage of that would be that we could for example use that for things like ListCell easily (memory management of which I see quite often in profiles). -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, 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