Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bqUnG-0001X3-6C for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Oct 2016 00:38:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bqUnF-0005es-PF for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Oct 2016 00:38:13 +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 1bqUlq-00047T-JM for pgsql-hackers@postgresql.org; Sun, 02 Oct 2016 00:36:46 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bqUln-0000NF-Um for pgsql-hackers@postgresql.org; Sun, 02 Oct 2016 00:36:45 +0000 Received: by mail-wm0-x22b.google.com with SMTP id k125so88951175wma.1 for ; Sat, 01 Oct 2016 17:36: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=B7oHDNV+W87oMmFMcFi0Ryqhs65uvKXPTYd83ovvmUc=; b=Lke2ceTIw1WZ1C4lopZNpfpkopu7rlzlnklnK4GcQwusHHrljPeNJVvv1zuq4/vkQG yKCHZiUvP0qTQtLmGY1JbJt/N+edzoL6DM9+gjz38sb/YuxEuCtchMtLM7qLKMyS94mA fIdQXOHhnvF62kgA5dt+Jk+/CNQxP8NmTPcs3CBTEhURIZLGX47e0GMrtu+n7FkwOM+B 2FAm5Uf/uo00HajILywkwvvO7l8gbxrkquJCcdxN6ii84J2DmU1H6TWnVzCJCjL+PsML 2LK54H8z8gO8GDFrGxsUbecyvCHrWA/ln8SeXjU71jIblvQ2x1UYXIKuX+Xfwsd48ifm RpEA== 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=B7oHDNV+W87oMmFMcFi0Ryqhs65uvKXPTYd83ovvmUc=; b=Xtu1hSemgKzkHePCQve43R8KT4PxsXbcgxAN3PLOF9ZbPNG0Sr/Ll1xzyX0ASmnwX1 Phxv2rrspqdW7zyc+fbXhHoaDG4tSjExF58RsvkfYD7392OvsWZuKYdgxlKw+o480yYo EuT4vDBSUnCl3XG7Dtxycq48K3TGwx+YXfMMzfev3OcUO9D893M6FAtCYAMoiiBVfSYT qf49OO0fn0k3+KPAI5RkZKjP6CQ4EPLfwswFS+JRkciElFPyX4+ego8+VITLf+3xoL3q PmZbbmH8c9JkNYuHCeBYkMXtRsC06vcEkuem2CZAtp/tYIuNHCtRc36+9tZf4JchLwci lyJw== X-Gm-Message-State: AA6/9RnJAcFrP3UfqVvMhtLiS/jI+Swxv4hf0W0l+ly3zc5ju7XKQ58UhBi01lW8u8pvFxYI0djWTI5o0aHwwfoKIPfJRx+W6aYTELWOhWnFS4lH0NfvYMkPEqyd7n+xigqOL4gytqMMsdakve8KuKmWV8qPxcRTQlQbVKdRBe36Rz7vPj8O1IMuYTIFiZ0T6x3qJ6a0Iz6x X-Received: by 10.28.31.144 with SMTP id f138mr931823wmf.90.1475368602417; Sat, 01 Oct 2016 17:36:42 -0700 (PDT) Received: from [10.137.2.17] (ip-89-177-44-58.net.upcbroadband.cz. [89.177.44.58]) by smtp.gmail.com with ESMTPSA id y2sm26965551wji.42.2016.10.01.17.36.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Oct 2016 17:36:41 -0700 (PDT) Subject: Re: PATCH: two slab-like memory allocators To: John Gorman References: <68b837a3-ce55-f9a2-f685-9eafac536f21@2ndquadrant.com> <885540a7-ac72-5a21-6dae-a4d5b50672da@2ndquadrant.com> <03110c11-ea72-7b4d-027d-6f19eb300b2a@2ndquadrant.com> Cc: Petr Jelinek , pgsql-hackers From: Tomas Vondra Message-ID: <9b74fc50-940f-8ca5-36e4-32010fcde2c4@2ndquadrant.com> Date: Sun, 2 Oct 2016 02:36:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:46.0) Gecko/20100101 Thunderbird/46.0a2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed 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 10/02/2016 12:23 AM, John Gorman wrote: > I reproduced the quadradic pfree performance problem and verified > that these patches solved it. > > The slab.c data structures and functions contain no quadradic > components. > > I noticed the sizing loop in SlabContextCreate() and came up with a > similar formula to determine chunksPerBlock that you arrived at. > ;-) >> Firstly, I've realized there's an issue when chunkSize gets too >> large - once it exceeds blockSize, the SlabContextCreate() fails >> as it's impossible to place a single chunk into the block. In >> reorderbuffer, this may happen when the tuples (allocated in >> tup_context) get larger than 8MB, as the context uses >> SLAB_LARGE_BLOCK_SIZE (which is 8MB). >> >> But maybe there's a simpler solution - we may simply cap the >> chunkSize (in GenSlab) to ALLOC_CHUNK_LIMIT. That's fine, because >> AllocSet handles those requests in a special way - for example >> instead of tracking them in freelist, those chunks got freed >> immediately. > > I like this approach because it fixes the performance problems > with smaller allocations and doesn't change how larger > allocations are handled. > Right. > In slab.c it looks like a line in the top comments could be clearer. > Perhaps this is what is meant. > > < * (plus alignment), now wasting memory. >> * (plus alignment), not wasting memory. > > In slab.c some lines are over 80 characters could be folded. > > It would be nice to give each patch version a unique file name. > OK, will fix. > Nice patch, I enjoyed reading it! > ;-) -- 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