pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-bugs@lists.postgresql.org
Cc: jakub.janecek@comgate.cz
Subject: Re: BUG #15486: PG11 jit on 50x slower than jit off
Date: Thu, 22 Nov 2018 06:26:12 +0000
Message-ID: <87k1l5sl7l.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <20181122015409.i4jd6e2ypwmbkyu5@alap3.anarazel.de>
References: <15486-05850f065da42931@postgresql.org>
	<20181122015409.i4jd6e2ypwmbkyu5@alap3.anarazel.de>

>>>>> "Andres" == Andres Freund <andres@anarazel.de> writes:

 Andres> This actually isn't great outside of JIT compilation as well -
 Andres> we waste a substantial portion of time rebuilding the
 Andres> expression everytime, and the hashtable grows every time as
 Andres> well.

Why would the hashtable grow? All of BuildTupleHashTable's callers
follow this pattern: the hashtable is allocated in a memory context that
will be reset on every rescan. Everything the hash table initialization
does is assumed to be completely discardable.

Which means that if you want to add a ResetTupleHashTable, it'll mean
significant reorganization of the callers' use of memory contexts, since
the hashtable will have to go into per-query memory (and presumably
create a child context of its own).

(There's an implicit assumption by all of BuildTupleHashTable's callers
that it will not allocate anything outside of the passed-in tablecxt,
which will be reset. Having BuildTupleHashTable allocate anything in its
caller's context is effectively an API break. But I notice this
_already_ got broken in pg11: the ExprContext that now gets allocated in
BuildTupleHashTable will be leaked into per-query memory on each cycle.)

-- 
Andrew (irc:RhodiumToad)




view thread (6+ messages)  latest in thread

Message-ID: <87k1l5sl7l.fsf@news-spur.riddles.org.uk>
Permalink:  ../87k1l5sl7l.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87k1l5sl7l.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, andres@anarazel.de, pgsql-bugs@lists.postgresql.org, jakub.janecek@comgate.cz
  Subject: Re: BUG #15486: PG11 jit on 50x slower than jit off
  In-Reply-To: <87k1l5sl7l.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox