Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eVJoW-0001wI-C6 for pgsql-committers@arkaria.postgresql.org; Sat, 30 Dec 2017 16:16:48 +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 1eVJoU-0006ql-3R for pgsql-committers@arkaria.postgresql.org; Sat, 30 Dec 2017 16:16: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 1eVJoT-0006qa-Db for pgsql-committers@lists.postgresql.org; Sat, 30 Dec 2017 16:16:45 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eVJoL-0003Dd-9M for pgsql-committers@postgresql.org; Sat, 30 Dec 2017 16:16:43 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id F159321B27; Sat, 30 Dec 2017 11:16:35 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Sat, 30 Dec 2017 11:16:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=+DeiUGnbXgsyK3BoHsJqmDUJJ25rX o6M2Z1lsnuTrLw=; b=LslINRsFmac9Pge96IoxcYpyIbnhNCVwEJx8ZY0UlqRN/ lho+xXTjGAZzG6DpcjbaAF8ACQjJRzo58cp7efmheX0XIde+jNLTfCtlfWTXfV8U Xg8PRR2aaRcWA8FgK4q/ySQZGKwjJpcNNdPoTJEnvDuWx3ZwwxpgdbKQQRuqR/Up 7Bbc1U6TZag1D7n0GcgffVPOHBNgrpvL4HMssJWykZpa03uqHFzu7GeUdlNV5WpZ EDmMXHZWQQLagXp16TxHjaOk10/j6gjmqqpWqhVqP6tFpXnjP2fpHRjxGWpQPtNT JWhhkd7U3vvXkSp1hevDAcvwtijihewTa2mAYSSnA== X-ME-Sender: Received: from intern.anarazel.de (unknown [136.24.76.189]) by mail.messagingengine.com (Postfix) with ESMTPA id 900757E347; Sat, 30 Dec 2017 11:16:35 -0500 (EST) Date: Sat, 30 Dec 2017 08:16:34 -0800 From: Andres Freund To: Thomas Munro Cc: Tom Lane , pgsql-committers Subject: Re: pgsql: Add parallel-aware hash joins. Message-ID: <20171230161634.3lpvgerqsysricaa@alap3.anarazel.de> References: <20171221092940.gbxcszbzsr5khsfr@alap3.anarazel.de> <20171221095550.d3e7xhoakcowhu5b@alap3.anarazel.de> <20171222082203.fl6rpzlqnm4h7h6h@alap3.anarazel.de> <30219.1514428346@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2017-12-31 02:51:26 +1300, Thomas Munro wrote: > You mentioned that prairiedog sees the problem about one time in > thirty. Would you mind checking if it goes away with this patch > applied? > > -- > Thomas Munro > http://www.enterprisedb.com > From cbed027275039cc5debf8db89342a133a831c9ca Mon Sep 17 00:00:00 2001 > From: Thomas Munro > Date: Sun, 31 Dec 2017 02:03:07 +1300 > Subject: [PATCH] Fix EXPLAIN ANALYZE output for Parallel Hash. > > In a race case, EXPLAIN ANALYZE could fail to display correct nbatch and size > information. Refactor so that participants report only on batches they worked > on rather than trying to report on all of them, and teach explain.c to > consider the HashInstrumentation object from all participants instead of > picking the first one it can find. This should fix an occasional build farm > failure in the "join" regression test. This seems buggy independent of whether it fixes the issue on prairedog, right? So I'm inclined to go ahead and just fix it... > + /* > + * Merge results from workers. In the parallel-oblivious case, the > + * results from all participants should be identical, except where > + * participants didn't run the join at all so have no data. In the > + * parallel-aware case, we need to aggregate the results. Each worker may > + * have seen a different subset of batches and we want to report the peak > + * memory usage across all batches. > + */ It's not necessarily the peak though, right? The largest batches might not be read in at the same time. I'm fine with approximating it as such, just want to make sure I understand. > + if (hashstate->shared_info) > { > SharedHashInfo *shared_info = hashstate->shared_info; > int i; > > - /* Find the first worker that built a hash table. */ > for (i = 0; i < shared_info->num_workers; ++i) > { > - if (shared_info->hinstrument[i].nbatch > 0) > + HashInstrumentation *worker_hi = &shared_info->hinstrument[i]; > + > + if (worker_hi->nbatch > 0) > { > - hinstrument = &shared_info->hinstrument[i]; > - break; > + /* > + * Every participant should agree on the buckets, so to be > + * sure we have a value we'll just overwrite each time. > + */ > + hinstrument.nbuckets = worker_hi->nbuckets; > + hinstrument.nbuckets_original = worker_hi->nbuckets_original; > + /* > + * Normally every participant should agree on the number of > + * batches too, but it's possible for a backend that started > + * late and missed the whole join not to have the final nbatch > + * number. So we'll take the largest number. > + */ > + hinstrument.nbatch = Max(hinstrument.nbatch, worker_hi->nbatch); > + hinstrument.nbatch_original = worker_hi->nbatch_original; > + /* > + * In a parallel-aware hash join, for now we report the > + * maximum peak memory reported by any worker. > + */ > + hinstrument.space_peak = > + Max(hinstrument.space_peak, worker_hi->space_peak); I bet pgindent will not like this layout. Ho hum. Is this really, as you say above, an "aggregate the results"? Greetings, Andres Freund