Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPiRP-0005KL-TV for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Nov 2018 06:26:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gPiRO-0004st-KF for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Nov 2018 06:26:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPiRO-0004sh-Dl for pgsql-bugs@lists.postgresql.org; Thu, 22 Nov 2018 06:26:18 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPiRM-0000Ab-7r for pgsql-bugs@lists.postgresql.org; Thu, 22 Nov 2018 06:26:18 +0000 Received: from [192.168.127.1] (port=54416 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1gPiRJ-00091Z-AI; Thu, 22 Nov 2018 06:26:13 +0000 Received: from [127.0.0.1] (port=40576 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1gPiRI-000FVa-Fw; Thu, 22 Nov 2018 06:26:12 +0000 From: Andrew Gierth To: Andres Freund Cc: pgsql-bugs@lists.postgresql.org, jakub.janecek@comgate.cz Subject: Re: BUG #15486: PG11 jit on 50x slower than jit off In-Reply-To: <20181122015409.i4jd6e2ypwmbkyu5@alap3.anarazel.de> (Andres Freund's message of "Wed, 21 Nov 2018 17:54:09 -0800") Message-ID: <87k1l5sl7l.fsf@news-spur.riddles.org.uk> References: <15486-05850f065da42931@postgresql.org> <20181122015409.i4jd6e2ypwmbkyu5@alap3.anarazel.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Thu, 22 Nov 2018 06:26:12 +0000 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Andres" == Andres Freund 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)