Re: Memory leak on subquery as scalar operand

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, lauri(dot)laanmets(at)eesti(dot)ee, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Memory leak on subquery as scalar operand
Date: 2022-11-01 05:51:32
Message-ID: 20221101055132.pjjsvlkeo4stbjkq@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On 2022-11-01 00:52:16 -0400, Tom Lane wrote:
> David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> > The single subquery version also crashes for me, so perhaps it's just
> > the amount of memory that's being used and when the OOM killer is
> > triggering.
> > It crashes even when I set jit_inline_above_cost and
> > jit_optimize_above_cost above the query's cost.
>
> Hmm, maybe we're not seeing the same thing?

I can't reproduce that either.

> For me, the behavior seems similar to what the OP reported: there's a
> per-query leakage but it's less than 100kB per query. It'd take more than a
> handful of repetitions to get to an OOM failure. This is with LLVM 13.0.1
> on RHEL 8.6.

This I can reproduce. Here's an updated patchset addressing this. This query,
for some reason, leaks a lot more aggressively than what I've seen in the
past, so I needed to reduce the amount of time until an llvm context is
recycled substantially. A bit of benchmarking showed no negative consequences
of going to 100 uses till recycling, even with absurd settings
(i.e. jit_*_cost = 0), but did show impact on lower values.

Greetings,

Andres Freund

Attachment Content-Type Size
v3-0001-wip-llvmjit-Use-explicit-LLVMContextRef.patch text/x-diff 23.3 KB
v3-0002-wip-llvmjit-remove-unnecessary-types.patch text/x-diff 1.3 KB
v3-0003-wip-llvmjit-Make-llvm_types_module-variable-stati.patch text/x-diff 1.4 KB
v3-0004-wip-llvmjit-Plug-memory-leak-when-performing-inli.patch text/x-diff 7.4 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Gunnar "Nick" Bluth 2022-11-01 13:13:38 Re: Strange sort node/explain result
Previous Message Tom Lane 2022-11-01 04:52:16 Re: Memory leak on subquery as scalar operand