Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWnOE-0008Ba-EB for pgsql-committers@arkaria.postgresql.org; Wed, 03 Jan 2018 18:03:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWnOE-0000lK-21 for pgsql-committers@arkaria.postgresql.org; Wed, 03 Jan 2018 18:03:46 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eWnOD-0000lA-QP for pgsql-committers@lists.postgresql.org; Wed, 03 Jan 2018 18:03:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eWnOB-0000Rx-6K for pgsql-committers@postgresql.org; Wed, 03 Jan 2018 18:03:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w03I3dYg018805; Wed, 3 Jan 2018 13:03:39 -0500 From: Tom Lane To: Thomas Munro cc: Andres Freund , pgsql-committers Subject: Re: pgsql: Add parallel-aware hash joins. In-reply-to: References: <20171221092940.gbxcszbzsr5khsfr@alap3.anarazel.de> <20171221095550.d3e7xhoakcowhu5b@alap3.anarazel.de> <20171222082203.fl6rpzlqnm4h7h6h@alap3.anarazel.de> <30219.1514428346@sss.pgh.pa.us> <30655.1514673257@sss.pgh.pa.us> <4001.1514678419@sss.pgh.pa.us> <18190.1514943510@sss.pgh.pa.us> Comments: In-reply-to Thomas Munro message dated "Thu, 04 Jan 2018 01:06:38 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18803.1515002619.1@sss.pgh.pa.us> Date: Wed, 03 Jan 2018 13:03:39 -0500 Message-ID: <18804.1515002619@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Munro writes: > On Wed, Jan 3, 2018 at 2:38 PM, Tom Lane wrote: >> Hm. That could do it, except it doesn't really account for the observed >> result that slower single-processor machines seem more prone to the >> bug. Surely they should be less likely to get multiple workers activated. > It plans for 8 batches, and then usually but not always goes to 16 at > execution time depending on timing. It doesn't happen for me with > 128kB (the setting used in the regression test), but I think the > affected BF machines are all 32 bit systems that have MAXIMUM_ALIGNOF > 8 and therefore use a bit more space, whereas my machines have > MAXIMUM_ALIGNOF 4 in a 32 bit build, so that would explain the > different location of this unstable border. Ah, that might do it. You're right that gaur/pademelon are in that class. > We could probably fix the > failures by simply increasing work_mem out of that zone, but I'm > hoping to fix the problem in a more principled way. More soon. Meh. I think we're going to end up having to pick a modified test case that's further away from the chunk size threshold. I do not think it is possible to predict this runtime behavior exactly at plan time, nor am I convinced that expending planner cycles on a somewhat closer estimate is a useful use of planning time. >> I'm also wondering why the non-parallel path seems to prefer to allocate >> in units of HASH_CHUNK_SIZE + HASH_CHUNK_HEADER_SIZE while the parallel >> path targets allocations of exactly HASH_CHUNK_SIZE, > That is intentional: dsa.c sucks at allocating 32KB + a tiny bit > because it works in 4KB pages for large allocations, so I wanted to > make HASH_CHUNK_SIZE the total size that arrives into dsa_allocate(). > The non-parallel path has similar problems on some libc > implementations, as we discussed over here: > https://www.postgresql.org/message-id/flat/29770.1511495642%40sss.pgh.pa.us Oh, right, I'd forgotten about that discussion. I think it would be good to adjust hashjoin so that both paths are targeting 32KB total; but you are right that there's not a lot of point in fooling with the non-parallel path until we add some way of accounting for aset.c's overhead too. We can leave that for later. >> BTW, I'm seeing a few things that look bug-like about >> ExecParallelHashTuplePrealloc, ... > Right. Fixed in the attached. Pushed, plus an additional Assert to clarify that we're expecting ExecParallelHashTuplePrealloc's caller to have already maxalign'ed the request size. regards, tom lane