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 1hlDNk-0001UX-3D for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2019 14:15:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hlDNj-00066v-01 for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2019 14:15:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlDNi-00064x-HG for pgsql-hackers@lists.postgresql.org; Wed, 10 Jul 2019 14:15:38 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlDNf-0003UY-NZ for pgsql-hackers@lists.postgresql.org; Wed, 10 Jul 2019 14:15:37 +0000 Received: by mail-qt1-x844.google.com with SMTP id j19so2519476qtr.12 for ; Wed, 10 Jul 2019 07:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=oJpzkIYpjQvqITVXykln6di3xrlBE3vH3u3ccZ/QEp4=; b=0UQmrqdd1MuF664JT3sqLuX8rpJuQMBlXcAWHE7i6TP9+DmL2QZ6EzAwk89mqerFSn 8zjXjLXRE6Lppmn6eoKQ6VhflCfUrkk/NT4BeIEjuki/cLd7oFtWRcMxmeQvnVEyrcs4 gYAhy390zvhvIL4cfQMpQv6fDDSE3WBDnnUJj0RqUPFvVm3cZEFb2ZU02aqpYCXdx/fD 2tOiXykg4dQWUjhAHU6kis0U5kWPU0QCtBkpT4lg0pdgUf9DQdhB1008r9S3iJp7SXN8 prrZl8YHvmvNYDZEnawBsiWeuWzdSnOhfoLis5QPwjL2y6oHT+vjL66Gc6mC8x5nVe/Z x5rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=oJpzkIYpjQvqITVXykln6di3xrlBE3vH3u3ccZ/QEp4=; b=Ld0HVjj4oWNBzJllZCGPRCQ9NnAfdfx/MAqWpCcDOL3LzhOCIDrsnOALP1RRRNd+pc T5Eh13ihQ6d/I7NphKouJ34ccEz293lfNmUknsHD39qzW3yLYwecQjtH1/MuQ6IMyHd4 tpQzRYgAYIwGAChJ8cTgnukf9Jjz8iSrZ6lsiF8CdEg4z768i6e0jw20PZwRApRYut+l 0QDVuAkLrdXBj8GyEKmUwAA9Vd5Hw+hQUcJ0PMGVpd8MLbdHvOdNuNN2alQJwq7wwc1p Bc+5aza6NGEFxjlUMBMHjdTdQzkaAezgfkmwBn5g9UzuoJck+MTsHIVFPFCWbp7x3KrS 3iVw== X-Gm-Message-State: APjAAAXxEJVOKu0wgWtFuzlYL3T/j2pKzHfXjc9q0fP1hBwUFSiKCMAF YglGxnw6pQlk817Na8xofYDPFQ== X-Google-Smtp-Source: APXvYqy/LM3TIAdE6W9hMl7zF3yDgS5iV+fTOWd+ad3+sHw1hKjReRHAk9WFulSqQ65aMWvJi1kfAA== X-Received: by 2002:ac8:2d19:: with SMTP id n25mr24119661qta.180.1562768134650; Wed, 10 Jul 2019 07:15:34 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id u7sm1259017qta.82.2019.07.10.07.15.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 10 Jul 2019 07:15:34 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 85E7D121EBC; Wed, 10 Jul 2019 10:15:31 -0400 (-04) Date: Wed, 10 Jul 2019 10:15:31 -0400 From: Alvaro Herrera To: Julien Rouhaud Cc: Michael Paquier , Peter Eisentraut , Thomas Munro , Daniel Verite , Tom Lane , PostgreSQL Hackers , Kevin Grittner Subject: Re: Add parallelism and glibc dependent only options to reindexdb Message-ID: <20190710141531.GA27615@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Jul-09, Julien Rouhaud wrote: > I finished to do a better refactoring, and ended up with this API in > scripts_parallel: Looking good! I'm not sure about the "Consume" word in ConsumeIdleSlot; maybe "Reserve"? "Obtain"? "Get"? Code commentary: I think the comment that sits atop the function should describe what the function does without getting too much in how it does it. For example in ConsumeIdleSlot you have "If there are multiples slots, here we wait for one connection to become available if none already is, returning NULL if an error occured. Otherwise, we simply use the only slot we have, which we know to be free." which seems like it should be in another comment *inside* the function; make the external one something like "Reserve and return a connection that is currently idle, waiting until one becomes idle if none is". Maybe you can put the part I first quoted as a second paragraph in the comment at top of function and keeping the second part I quoted as first paragraph; we seem to use that style too. Placement: I think it's good if related functions stay together, or there is some other rationale for placement within the file. I have two favorite approaches: one is to put all externally callable functions at top of file, followed by all the static helpers in the lower half of the file. The other is to put each externally accessible immediately followed by its specific static helpers. If you choose one of those, that means that SetupParallelSlots should either move upwards, or move downwards. The current ordering seems a dartboard kind of thing where the thrower is not Green Arrow. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services