Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1byKgi-0001Qg-Gb for pgsql-hackers@arkaria.postgresql.org; Sun, 23 Oct 2016 15:27:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1byKgh-000070-QN for pgsql-hackers@arkaria.postgresql.org; Sun, 23 Oct 2016 15:27:51 +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 1byKfJ-00071G-CM for pgsql-hackers@postgresql.org; Sun, 23 Oct 2016 15:26:25 +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 1byKfG-0001J0-Jx for pgsql-hackers@postgresql.org; Sun, 23 Oct 2016 15:26:24 +0000 Received: by mail-wm0-x22f.google.com with SMTP id f193so71408674wmg.0 for ; Sun, 23 Oct 2016 08:26:22 -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=Y3NWKUg9DFCicd1SJzKFPcrDEqz4DUgAX+FXlkMOAfw=; b=dhHVg9278kA+7fFe9zvxFgKXE5AX6ZNnG1XTmOaI8x3hxTamSZ8WCZvuQwAqBavyn8 /C/IzQBDuDyckKqZqP+1FUa0uIT7EbY3FW37JjIv+9JufozCeEck7/InhpZaTBJRZPPc i4NdCn79NAfnPe1QsKVvX1h/pt6vXkMTvQF/YgY9jSoOOYCH8V9u1SQZrQ4lzHQVyibb lxqef9g1Ju5NBakE5N62wYbF72wZ2dXQsKnEBQ4GqFB0sbEY9Vaw/r8QniLOyoi26Gfu T2bzQkKDZpoWfFdpa+ul5NybWVyvBgRgnICmW20ED908xlrfhydk1pGPoXv6wciXEAxR oNiQ== 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=Y3NWKUg9DFCicd1SJzKFPcrDEqz4DUgAX+FXlkMOAfw=; b=OpvWVCkiY+ccZ1UyWXC4g6Awy71PzscCg4yX8eoKGyWtikVkIDm93xZw3tgvh2yFLo Jto9eNHQrs1d+j8FM0JbPU5A6Jvx0ATnP35Ma+u4PxDEH+9UbuP3vIOpIN1gt3qGcXjK xwdxuMy3xxeOaicM6p+pG4ECFDoBib1hGgQW7dBLxM3+LSYCeyVfTa45NIFHmAoqAs5r XjszEvYrAfSkbna3qtbfUe7DF5qID7Z1m+wGaieP6WrZr2jDo49xcxQfHzhFPhf5GwS6 BZ33iEAr5E90DdWhbEHvpGYaC86abe+ju5JhCL6JfJQStt4FvCyzC5deFszOK+MYbOIT yjDw== X-Gm-Message-State: ABUngvcwd1zbF8I4EozJRVq1tYweiFAtJCOFxHMevqd/z4JAi/+qmXDNASRPNmWadYDeSiGcsggRGGs7MqYnTkQioqpn/4mroSAUN2J3ICprAwBggvB/PGkFpv/LBt6Mn48MDrNFjFKPGxdURub7sLQsDHypejfRnOO3vzafUHQBU9N192pzeKMBbWHwm56rqg== X-Received: by 10.194.119.233 with SMTP id kx9mr10141057wjb.112.1477236380198; Sun, 23 Oct 2016 08:26:20 -0700 (PDT) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id yo1sm14311255wjc.16.2016.10.23.08.26.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Oct 2016 08:26:18 -0700 (PDT) Subject: Re: PATCH: two slab-like memory allocators To: Tomas Vondra , Robert Haas 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> <9818b54a-fcb6-f018-0b16-96d6a1d1da27@2ndquadrant.com> <34a6d4ea-7f3d-a62c-fff1-7a9108c078d7@2ndquadrant.com> Cc: John Gorman , pgsql-hackers From: Petr Jelinek Message-ID: Date: Sun, 23 Oct 2016 17:26:18 +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: <34a6d4ea-7f3d-a62c-fff1-7a9108c078d7@2ndquadrant.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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 23/10/16 16:26, Tomas Vondra wrote: > On 10/22/2016 08:30 PM, Tomas Vondra wrote: >> On 10/20/2016 04:43 PM, Robert Haas wrote: >>> >>> ... >>> >>> The sb_alloc allocator I proposed a couple of years ago would work >>> well for this case, I think. >>> >> >> Maybe, but it does not follow the Memory Context design at all, if I >> understand it correctly. I was willing to give it a spin anyway and see >> how it compares to the two other allocators, but this is a significant >> paradigm shift and certainly much larger step than what I proposed. >> >> I'm not even sure it's possible to implement a MemoryContext based on >> the same ideas as sb_alloc(), because one of the important points of >> sb_alloc design seems to be throwing away the chunk header. While that >> may be possible, it would certainly affect the whole tree (not just the >> reorderbuffer bit), and it'd require way more work. >> >> Moreover, the two allocators I proposed significantly benefit from the >> "same lifespan" assumption. I don't think sb_alloc can do that. >> > > I've given the sb_alloc patch another try - essentially hacking it into > reorderbuffer, ignoring the issues mentioned yesterday. And yes, it's > faster than the allocators discussed in this thread. Based on a few very > quick tests on my laptop, the difference is usually ~5-10%. > > That might seem like a significant improvement, but it's negligible > compared to the "master -> slab/gen" improvement, which improves > performance by orders of magnitude (at least for the tested cases). > > Moreover, the slab/gen allocators proposed here seem like a better fit > for reorderbuffer, e.g. because they release memory. I haven't looked at > sb_alloc too closely, but I think it behaves more like AllocSet in this > regard (i.e. keeping the memory indefinitely). > For reorderbuffer, from what I've seen in practice, I'd prefer proper freeing to 5% performance gain as I seen walsenders taking GBs of memory dues to reoderbuffer allocations that are never properly freed. About your actual patch. I do like both the Slab and the Gen allocators and think that we should proceed with them for the moment. You definitely need to rename the Gen one (don't ask me to what though) as it sounds like "generic" and do some finishing touches but I think it's the way to go. I don't see any point in GenSlab anymore. -- 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