Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mAJWd-0005In-Dt for pgsql-hackers@arkaria.postgresql.org; Sun, 01 Aug 2021 22:01:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mAJWa-0006lq-Qh for pgsql-hackers@arkaria.postgresql.org; Sun, 01 Aug 2021 22:01:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mAJWa-0006lf-7y for pgsql-hackers@lists.postgresql.org; Sun, 01 Aug 2021 22:01:36 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mAJWV-00004x-RO for pgsql-hackers@postgresql.org; Sun, 01 Aug 2021 22:01:35 +0000 Received: by mail-ed1-x536.google.com with SMTP id cf5so10303693edb.2 for ; Sun, 01 Aug 2021 15:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=qOdGvl8y5bIhnMUtJTr1/hfBIwF4bEkyPnTJkAMrpzY=; b=k6uB1ibH2cRtX6TfYWXakFHg0G1K91KvIsAoPMFTm53j2m2dBkc06w0LwBLvSuMJEJ 9ww1nVW+qGoEMz91qwhBlrC1Hn329DVXxeYwll6qtcTtc5rA5RWydUOPUppbKmADrFEX RQiEPVgmgF2cxURBMuwmEl+LgEEucmKM6R2oY0T9IdyT0AhMxiMeDu2jFg1HaUh5qVDl dPD4rNb+xyTVfszoi5yK7YbCUfUPCIpTABX5VPPwv8YYkVMtp02Zdnvvdt+etiG43+yI v+CqY5z12Q1zb4LMM/KqiKymJ1tTqsz7Qgv2m+RL8NGZDbpl9EyhRyZuPjVj4PcDh07K 1JUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qOdGvl8y5bIhnMUtJTr1/hfBIwF4bEkyPnTJkAMrpzY=; b=o7WBEK72h2A8KO+lzt5OtjKad0/1QkfcL+P+sBvEmz6d8zoahvPiM0N1BDnD3Fn9yv r0jAxZrD78IlvaHbZ8n0ldvyWFrD/X9XtvP0jO67RLbCq+hpqhlcCuZxeP69Ke+Whi4f uGV+9BJUr9DjW75flPMaAcSXuSwkOnK1B0TzjkOD4f4uc8g0Pcy7UTlFtFB9G2+Oxkg3 N2cRxd2OTBtVTiocu7QuY8djZiP5Ov1ry7n+cuh7mxn54lmgFaFaibr1ryTfF33UZVRA 6FLuKjeJ1G2HX7XbZyHooCrQ6dUrg+/Fk+JYgOejeIlCvH4dBcClRQPn362ILXrqkGVC T1RA== X-Gm-Message-State: AOAM532g+7a0PsEu/7sBR7PxZ+bJw+4FCNaRdq/DgCBFVHdldL6IN6sA JDXz5x83gqTI7VYd5Eb1bZADdaQZo1sxNiw9rUlBywse6R+d1XmFtNDDPFEqi1EDvdGlsBoYp/9 43StThx2RI9qRVB2i0n0RPFjEUzIt+HeKjur2A+hKaAr5+tRGEYcM7gVL3WEHCRVbAcYJ5hM7wG xyeEs57jEs6Sir0sFMW0FudxUxR4IZrIKke7q4 X-Google-Smtp-Source: ABdhPJw0j1xT49YA+el56h8XfCcYUA8uDNh0NMemvPvUO14m3+W2ZTOdstNpPQZOkhEc87Im/e3zdw== X-Received: by 2002:a05:6402:cae:: with SMTP id cn14mr15877836edb.31.1627855289547; Sun, 01 Aug 2021 15:01:29 -0700 (PDT) Received: from [10.137.0.18] (ip-86-49-254-183.net.upcbroadband.cz. [86.49.254.183]) by smtp.gmail.com with ESMTPSA id h1sm3566670eji.46.2021.08.01.15.01.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 01 Aug 2021 15:01:29 -0700 (PDT) Subject: Re: slab allocator performance issues To: Andres Freund Cc: pgsql-hackers@postgresql.org, Tomas Vondra References: <20210717194333.mr5io3zup3kxahfm@alap3.anarazel.de> <20210717211405.3ocp2rpxlnozg3tq@alap3.anarazel.de> <02ff3ced-3212-aea1-c7a0-4829f43e58d2@enterprisedb.com> <20210717231019.blfhyqniu6jed3ym@alap3.anarazel.de> <20210718010600.fat2f5j4gvqig56j@alap3.anarazel.de> <37dc9b41-dd75-251d-a77e-16c72c794b00@enterprisedb.com> <20210719205603.lzh5rkuv7lsoq4mp@alap3.anarazel.de> <6717ca90-a2ea-b17d-f544-37f5181b1175@enterprisedb.com> <20210801210722.kctrnyxwwu4mzail@alap3.anarazel.de> From: Tomas Vondra Message-ID: <76ebb476-4060-393b-5bf1-0287ae1464bd@enterprisedb.com> Date: Mon, 2 Aug 2021 00:01:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210801210722.kctrnyxwwu4mzail@alap3.anarazel.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/1/21 11:07 PM, Andres Freund wrote: > Hi, > > On 2021-08-01 19:59:18 +0200, Tomas Vondra wrote: >> In the attached .ods file with results, the "comparison" sheets are the >> interesting ones - the last couple columns compare the main metrics for the >> two patches (labeled patch-1 and patch-2) to master. > > I assume with patch-1/2 you mean the ones after the benchmark patch > itself? > Yes, those are the two WIP patches you shared on 19/7. > >> Overall, the results look quite good - patch-1 is mostly on par with master, >> with maybe 5% variability in both directions. That's expected, considering >> the patch does not aim to improve performance. > > Not for slab anyway... > Maybe the hot/cold separation could have some effect, but probably not for the workloads I've tested. > >> The second patch brings some nice improvements - 30%-50% in most cases (for >> both allocation and free) seems pretty nice. But for the "increase" FIFO >> pattern (incrementally allocating/freeing more memory) there's a significant >> regression - particularly for the allocation time. In some cases (larger >> chunks, block size does not matter too much) it jumps from 25ms to almost >> 200ms. > > I'm not surprised to see some memory usage increase some, but that > degree of time overhead does surprise me. ISTM there's something wrong. > Yeah, the higher amount of allocated memory is due to the couple fields added to the SlabBlock struct, but even that only affects a single case with 480B chunks and 1kB blocks. Seems fine to me, especially if we end up growing the slab blocks. Not sure about the allocation time, though. > It'd probably worth benchmarking the different improvements inside the > WIP: slab performance. patch. There's some that I'd expect to be all > around improvements, whereas others likely aren't quite that clear > cut. I assume you'd prefer that I split the patch up? > Yeah, if you split that patch into sensible parts, I'll benchmark those. Also, we can add more interesting workloads if you have some ideas. > >> This seems unfortunate - the allocation pattern (FIFO, allocating more >> memory over time) seems pretty common, and the slowdown is significant. > > Did you analyze what causes the regressions? > No, not yet. I'll run the same set of benchmarks for the Generation, discussed in the other thread, and then I'll investigate this. But if you split the patch, that'd probably help. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company