Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rOMuj-003bo8-2a for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jan 2024 19:09:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rOMui-004k0r-4n for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jan 2024 19:09:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rOMuh-004k0h-Rf for pgsql-hackers@lists.postgresql.org; Fri, 12 Jan 2024 19:09:55 +0000 Received: from mail-yb1-xb33.google.com ([2607:f8b0:4864:20::b33]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rOMuf-001Exw-OA for pgsql-hackers@postgresql.org; Fri, 12 Jan 2024 19:09:55 +0000 Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-dbed5d2ad18so6075824276.0 for ; Fri, 12 Jan 2024 11:09:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705086592; x=1705691392; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=lYa6iZByZpZ9jqKRFBhym2Zz8/EKeX00X54YVVHJ6TA=; b=ilu+tCeMtuNY577nT6r0sSzyF/6aq5XwDdmgIt1ODnS1KeLJVJC7kXMgHKwj6CAH/H KcQab5agB3fkAg5aFWCTE728D3LkIg6YHNNcfoAyndFeN+jkFjmb0YHFxwo18ydLRx1J TmcGwOw3P0tnzWay1PC8N0M9s75cIqe0jIvZDaNGFCX/Seb67sK8qkgVsW0/WrwzqQ+8 nAqvRJmLVKMPv1VLazgKYjn7Dgo6eOxljvinyKin8SrjkLEHRIAoWFYZxcbTtT4icEUT SVlQIFmY9X6NyvhHrwhZ1gdxcpGkyGCKl8iwiHjgW8W3FCfoYyBfmHL2/7e1hZdwf2Xc zL2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705086592; x=1705691392; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lYa6iZByZpZ9jqKRFBhym2Zz8/EKeX00X54YVVHJ6TA=; b=ZuyXK2+4mfXm8ICIgwOwXRsxf/99rNWK65KVsYsIdQLj+GygmK4La4iRKynPuckW9Q k1D4bBhhRRfRVjQvfQbRf00COHQd81ZukwKDO1qe3IibzlRkIWqs2s4C3jMJ1BHnw92Z 9wFix5kXNzQL+UCaF8Y1GDt+k+ajX0O7mCS4QmLm08IK+3PtIz6QK2StIl75ehCEFWoy A1EuNFHL5inEfec9dBJFHdkwu+zGTEQQiIt47cuAlSdCmmhFjnFQ2mIML2p26iYSfLxs boCdW/dmwct+tTcfEP3Jes7fIpu3yy0IhuBHd0EfvaNmjzPhMLs460vPTvt8ikNqgHWH OXrA== X-Gm-Message-State: AOJu0Yyh73MFVtfkj0bbuolMn92lvP0NJc8U3G6UUY98Kos39765qyly PrYp6w3B/+7biUVxbjnG3K0ZkXoSpH9z0Am6j94= X-Google-Smtp-Source: AGHT+IHHMhg2w7OaVRqdrHhpKsYDjrRrKru/BCL0KVCaVYiKJSF1S6AYXwnKnql7JoBQVjJNyTzh1LmUMyaQ15Wilhk= X-Received: by 2002:a25:8747:0:b0:dbd:b165:5433 with SMTP id e7-20020a258747000000b00dbdb1655433mr991497ybn.96.1705086592193; Fri, 12 Jan 2024 11:09:52 -0800 (PST) MIME-Version: 1.0 References: <65a11a66.170a0220.fd97.5da6@mx.google.com> <65a14469.050a0220.fead0.7c6d@mx.google.com> In-Reply-To: <65a14469.050a0220.fead0.7c6d@mx.google.com> From: Pavel Stehule Date: Fri, 12 Jan 2024 20:09:14 +0100 Message-ID: Subject: Re: plpgsql memory leaks To: Michael Banck Cc: PostgreSQL Hackers Content-Type: multipart/alternative; boundary="000000000000a3990a060ec468ee" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a3990a060ec468ee Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable p=C3=A1 12. 1. 2024 v 14:53 odes=C3=ADlatel Michael Banck = napsal: > Hi, > > On Fri, Jan 12, 2024 at 01:35:24PM +0100, Pavel Stehule wrote: > > p=C3=A1 12. 1. 2024 v 11:54 odes=C3=ADlatel Michael Banck napsal: > > > Which version of Postgres is this and on which platform/distribution? > > > > It was tested on master branch (pg 17) on Fedora 39 > > > > > Did you try keep jit on but set jit_inline_above_cost to 0? > > > > > > The back-branches have a fix for the above case, i.e. llvmjit memleak= s > > > that can be worked-around by setting jit_inline_above_cost=3D0. > > I got that wrong, it needs to be -1 to disable it. > > But if you are already running the master branch, it is probably a > separate issue. > I tested code CREATE OR REPLACE FUNCTION public.fx(iter integer) RETURNS void LANGUAGE plpgsql AS $function$ declare c cursor(m bigint) for select distinct i from generate_series(1, m) g(i); t bigint; s bigint; begin for i in 1..iter loop s :=3D 0; for r in c(i*10000) loop s :=3D s + r.i; end loop; raise notice '%=3D%', i, s; end loop; end; $function$ default master branch - res 190MB ram jit_inline_above_cost =3D -1 doesn't helps disabling JIT doesn't helps too, so it looks like the wrong hypothesis , and the problem is maybe somewhere else :-/ Regards Pavel > > > Michael > --000000000000a3990a060ec468ee Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
p=C3=A1 12. 1. 2024 v=C2=A014:53 odes= =C3=ADlatel Michael Banck <mbanck@gmx.= net> napsal:
Hi,

On Fri, Jan 12, 2024 at 01:35:24PM +0100, Pavel Stehule wrote:
> p=C3=A1 12. 1. 2024 v 11:54 odes=C3=ADlatel Michael Banck <mbanck@gmx.net> napsal:=
> > Which version of Postgres is this and on which platform/distribut= ion?
>
> It was tested on master branch (pg 17) on Fedora 39
>
> > Did you try keep jit on but set jit_inline_above_cost to 0?
> >
> > The back-branches have a fix for the above case, i.e. llvmjit mem= leaks
> > that can be worked-around by setting jit_inline_above_cost=3D0.
I got that wrong, it needs to be -1 to disable it.

But if you are already running the master branch, it is probably a
separate issue.

I tested code

CREATE OR REPLACE FUNCTION public.fx(iter integer)
=C2= =A0RETURNS void
=C2=A0LANGUAGE plpgsql
AS $function$
declare
= =C2=A0 c cursor(m bigint) for select distinct i from generate_series(1, m) = g(i);
=C2=A0 t bigint;
=C2=A0 s bigint;
begin
=C2=A0 for i in 1= ..iter
=C2=A0 loop
=C2=A0 =C2=A0 s :=3D 0;
=C2=A0 =C2=A0 for r in= c(i*10000)
=C2=A0 =C2=A0 loop
=C2=A0 =C2=A0 =C2=A0 s :=3D s + r.i;=C2=A0 =C2=A0 end loop;
=C2=A0 =C2=A0 raise notice '%=3D%', i,= s;
=C2=A0 end loop;
end;
$function$

= default master branch - res 190MB ram
jit_inline_above_cost =3D -= 1 doesn't helps
disabling JIT doesn't helps too,

so it looks like the wrong hypothesis , and the problem is= maybe somewhere else :-/

Regards

Pavel

=C2=A0


Michael
--000000000000a3990a060ec468ee--