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 1nIzG8-00047Y-Mz for pgsql-hackers@arkaria.postgresql.org; Sat, 12 Feb 2022 20:44:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nIzG6-0000Mm-Iz for pgsql-hackers@arkaria.postgresql.org; Sat, 12 Feb 2022 20:44:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIzG5-0000Md-V8 for pgsql-hackers@lists.postgresql.org; Sat, 12 Feb 2022 20:44:42 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nIzG0-0007Xa-VQ for pgsql-hackers@lists.postgresql.org; Sat, 12 Feb 2022 20:44:41 +0000 Received: by mail-ed1-x52e.google.com with SMTP id s7so21419439edd.3 for ; Sat, 12 Feb 2022 12:44:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=aCytNZ/hTpTckhIoUVfTnXTfyzql8KLVeFbfPxA3kmY=; b=OAu6wqi+o1oCZijLAVvMSSyLUx89KfUyGuqfVbdLUZ0ihwRf0cULr+zmdQEEvAN1yZ 3gdNuId2cVdJixW9fK/3uQ9Uw8DbHeUc+9rXW1iH9yzUAIKzKrhSNPAbvzj/tpU6LGZS hw3N9/7iCtk+yiZcu0wT3z5suwBeL6UB5GxTalZPymo5TWfUBAC0nzx0/KKXvyQwPqqB 3WHh6XNwIqBDnE9Z9V7oCXHrWjQYmwX29mcY4A9BSNziKxo4anoKoaB+QJOfMYC2Rxkb S7rT0zk+A0wR6TiDJghSJ5WsiOROgzq1rdAlQVZhZ+0H+2bfEgf3QL6BLrD2RKqmGSqb 5/RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=aCytNZ/hTpTckhIoUVfTnXTfyzql8KLVeFbfPxA3kmY=; b=TxIc65HxUlH+g/famPW+1Sbu+aHGl2k0c99FdOuS7n8z0JTy/kY2K4EnQvgFnPep/z NHhhEhCOXdRUil3+9ZkYjv3DdddoBnf+ZrWraMUFQQOnLKV9IRyHpcdwrp31JuvbZybt eoBrj6Vc9OEVKm8BG7se9YkliqFKzqETx9x2aF/sCogSdFOx98qs4QE3z9BIyoU8D240 mJQGtmvTNaVFGb/Y7+XU63E/V79Y+cVxtcO8x335hF1uf+w37QDup13XQkRKPH6Y6htF LKdgRF+cFQX0aXycaeKswdR/wPPZHT1wLbgZ9RCc3HAQjU0jX408KJ7DUjek0zkiB69D f9ww== X-Gm-Message-State: AOAM530oBEG9dgHcNvH/OMo2+oznB2Kg6gqRpLCyVdzrvSxorCriBYIA /WxrlpIjmSFo0FhwyxfiqNj9Op0OUp7ztzmFdOBYWEHjm86oX/q7T1uYrP1qkT6JOxpf1ISlZbQ 4yHZTW0IjRz2NkDItp/3DB65bdzgrzlGsDCJsAD7Sf81mPqLS0cprvw+vHdqF7AoKBtDdm9jZUk ShJRPiDPUPn719+U+wSsUYSb/sRsmTwiNQ/9ZdieTSbJy0dWAkGt8B X-Google-Smtp-Source: ABdhPJzg48ncCq6LCvGPhlWx40LqFMk19LvNUXAj0tKpm4cQfb8HONslvDwoNdQqYHjkVh9KjM0JNg== X-Received: by 2002:a50:cb8c:: with SMTP id k12mr7890394edi.69.1644698674613; Sat, 12 Feb 2022 12:44:34 -0800 (PST) Received: from [10.137.0.19] (ip-86-49-251-241.net.upcbroadband.cz. [86.49.251.241]) by smtp.gmail.com with ESMTPSA id y6sm2337691ejk.210.2022.02.12.12.44.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 12 Feb 2022 12:44:34 -0800 (PST) Message-ID: <5faa695b-30f2-464b-5a97-90f5b4bff3b4@enterprisedb.com> Date: Sat, 12 Feb 2022 21:44:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: Use generation context to speed up tuplesorts Content-Language: en-US To: Ronan Dunklau , Julien Rouhaud , David Rowley , pgsql-hackers@lists.postgresql.org Cc: Andres Freund , Tomas Vondra References: <4377612.LvFx2qVVIh@aivenronan> <3470027.R56niFO833@aivenronan> From: Tomas Vondra In-Reply-To: <3470027.R56niFO833@aivenronan> Content-Type: text/plain; charset=UTF-8 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 1/25/22 13:34, Ronan Dunklau wrote: > > ... > > I've run the same 1-to-32-columns sort benchmark, using both glibc malloc and > jemalloc, with the standard aset memory manager or with David's generation v2 > patch. To use jemalloc, I just use a LD_PRELOAD env variable before starting > postgres. > > I have not tried to measure jemalloc's memory footprint like I did for glibc's > malloc in the previous benchmark, as I'm not trying to evaluate jemalloc as a > glibc's malloc replacement. > > Please find the results attached. As I suspected, most of the gain observed > with David's patch come from working around glibc's malloc idiosyncracies but > the good news is that it also helps (to a lesser degree) with jemalloc. > > I'm not sure how that would behave with growing block sizes though: as Tomas > patch and stress-testing benchmarks showed, we can hit some particular > thresholds (and regressions) in glibc's self-tuning behaviour. > Interesting results! So just switching to jemalloc can yield much better performance (in some cases), even beating the generation context (on top of glibc malloc). Of course, those are just simple (somewhat synthetic) benchmarks, and there is no info about memory consumption. Perhaps there are cases where this would be slower than glibc malloc, and I doubt many people to switch to a non-default malloc implementation. But I think in general this mostly confirms our suspicion about the patch (somewhat accidentally) working around glibc internal behavior. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company