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 1pXsIF-0004qu-6Q for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Mar 2023 23:24:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pXsID-0007iv-Mu for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Mar 2023 23:24:57 +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 1pXsID-0007il-D0 for pgsql-hackers@lists.postgresql.org; Thu, 02 Mar 2023 23:24:57 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pXsIA-0006kC-C4 for pgsql-hackers@lists.postgresql.org; Thu, 02 Mar 2023 23:24:56 +0000 Received: by mail-ed1-x52e.google.com with SMTP id cy23so3383710edb.12 for ; Thu, 02 Mar 2023 15:24:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=hecgAB22N18L550VpNODPQCMkGkzL5rTcHa7E1M8e/o=; b=iuHePDn8qNvwpDyQxs2/YfbEnHBN9J00DmSdQQZltn7StqJliaMw1QeC31w4vf+sm0 u72SWbC40XR3aKnyzHAjyXT/tI29zrgR8rnciVFLuBxpkmZhDvHaqs4lsqLaDNx4afxg MB2y062VNLkn0ukMROaPf9cTOmbd0i65548GMf1C+qH1xtlWzCqmU6+MMacCx2vur3WW LHTL0v4X2LSkJH4awsRZJs8sMNq0H+WtCfGRE/dUykAXx1lcdgVa28b+3gb2uATgjCN0 jzoY3Kqys+ULnMpb3msZaMomZv/c3LSPSHMudPXLZHC/okMpdzCxFivl/VSt0+uGgaxr HdoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hecgAB22N18L550VpNODPQCMkGkzL5rTcHa7E1M8e/o=; b=1lvDDwKtB2UWCoomWTAOwKotx0oyM6r6Avi5teBq1IfQzJxAqL5ykmb+cwMmvoVut0 CUdSQzOp5o4KEvx+7a+T5YhXtaqYIo2NhnFamSXVThAjejVkErBiuedotBauM7P77tBV PPljKQRePjXclagniEX85YH7HQi+I2d9ZXyTpn1klzbIl1F/nsSHJb9qk9X0/3RkA5EO V+COKmVKJh/tTu4Wc9jRzEjj+JGUmNyA7Wg819qcD/bUhw5SzccmQnNfRG3qBwX21vWd iV4LvJfMG6ArerKTfj3DNCPWyNvEhHZK2lwL+njaZfJXAl5tZg71liUBpXU3mXKpwDZ4 cSOA== X-Gm-Message-State: AO0yUKVi68h4kCUDCVxBaGulne2GbeHXYq86b0OE2VaG+S6Je3WotXm2 ormrkmTrINnyO8DIDiQEU12LGGtJcIS0LMzdMbBYyzgWojG+JtAKHBbX8OjnaraUv4q0xODfdMB bU/t67Upc/9em7Q8ZNfmeguMn70RFj56NPIuVvbSbhzZ114FEEf34FEoDH/mKd+kIYdZ2Wsk0Ay hSFjY9CQvXPERnnsPczxl4c9BWFqZ2Ct59UBA8OoLeqwEKprcYzu/H3vWE5ifjkC0= X-Google-Smtp-Source: AK7set9+RPpUzcirYALNeYnkqDuI8pp4gCcVRrj/nR4eS4/fHO5zwyTVUgNuYz9/ELIb4jc+T1iq6g== X-Received: by 2002:a17:906:9f19:b0:8b1:7de9:b38c with SMTP id fy25-20020a1709069f1900b008b17de9b38cmr15806110ejc.52.1677799491898; Thu, 02 Mar 2023 15:24:51 -0800 (PST) Received: from [10.137.0.17] (ip-86-49-228-162.bb.vodafone.cz. [86.49.228.162]) by smtp.gmail.com with ESMTPSA id ay24-20020a170906d29800b0090953b9da51sm228591ejb.194.2023.03.02.15.24.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Mar 2023 15:24:51 -0800 (PST) Message-ID: <77703e68-6cb2-d843-30e8-2db9750b331f@enterprisedb.com> Date: Fri, 3 Mar 2023 00:24:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: Memory leak from ExecutorState context? Content-Language: en-US To: Jehan-Guillaume de Rorthais Cc: pgsql-hackers@lists.postgresql.org References: <20230228190643.1e368315@karst> <45d453c8-b2d3-b477-36eb-32fdf4455f3c@enterprisedb.com> <20230301184840.0a897a80@karst> <3013398b-316c-638f-2a73-3783e8e2ef02@enterprisedb.com> <20230302001827.66e95dc3@karst> <41c5766d-ed71-b70c-bbbc-d3396c462d62@enterprisedb.com> <20230302130838.717e888d@karst> <77a96d42-00cb-2448-465a-aa1e92d00cac@enterprisedb.com> <20230302191530.781909fe@karst> <20230302235721.54af8258@karst> From: Tomas Vondra In-Reply-To: <20230302235721.54af8258@karst> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 3/2/23 23:57, Jehan-Guillaume de Rorthais wrote: > On Thu, 2 Mar 2023 19:53:14 +0100 > Tomas Vondra wrote: >> On 3/2/23 19:15, Jehan-Guillaume de Rorthais wrote: > ... > >>> There was some thoughts about how to make a better usage of the memory. As >>> memory is exploding way beyond work_mem, at least, avoid to waste it with >>> too many buffers of BufFile. So you expand either the work_mem or the >>> number of batch, depending on what move is smarter. TJis is explained and >>> tested here: >>> >>> https://www.postgresql.org/message-id/20190421161434.4hedytsadpbnglgk%40development >>> https://www.postgresql.org/message-id/20190422030927.3huxq7gghms4kmf4%40development >>> >>> And then, another patch to overflow each batch to a dedicated temp file and >>> stay inside work_mem (v4-per-slice-overflow-file.patch): >>> >>> https://www.postgresql.org/message-id/20190428141901.5dsbge2ka3rxmpk6%40development >>> >>> Then, nothing more on the discussion about this last patch. So I guess it >>> just went cold. >> >> I think a contributing factor was that the OP did not respond for a >> couple months, so the thread went cold. >> >>> For what it worth, these two patches seems really interesting to me. Do you >>> need any help to revive it? >> >> I think another reason why that thread went nowhere were some that we've >> been exploring a different (and likely better) approach to fix this by >> falling back to a nested loop for the "problematic" batches. >> >> As proposed in this thread: >> >> https://www.postgresql.org/message-id/20190421161434.4hedytsadpbnglgk%40development > > Unless I'm wrong, you are linking to the same «frustrated as heck!» discussion, > for your patch v2-0001-account-for-size-of-BatchFile-structure-in-hashJo.patch > (balancing between increasing batches *and* work_mem). > > No sign of turning "problematic" batches to nested loop. Did I miss something? > > Do you have a link close to your hand about such algo/patch test by any chance? > Gah! My apologies, I meant to post a link to this thread: https://www.postgresql.org/message-id/CAAKRu_b6+jC93WP+pWxqK5KAZJC5Rmxm8uquKtEf-KQ++1Li6Q@mail.gmail.com which then points to this BNL patch https://www.postgresql.org/message-id/CAAKRu_YsWm7gc_b2nBGWFPE6wuhdOLfc1LBZ786DUzaCPUDXCA%40mail.gmail.com That discussion apparently stalled in August 2020, so maybe that's where we should pick up and see in what shape that patch is. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company