Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qcol9-001JE0-KN for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Sep 2023 15:11:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qcol6-003589-1W for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Sep 2023 15:11:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qcol5-00357O-Kr for pgsql-hackers@lists.postgresql.org; Sun, 03 Sep 2023 15:11:27 +0000 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qcol0-002l8y-BI for pgsql-hackers@lists.postgresql.org; Sun, 03 Sep 2023 15:11:26 +0000 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-5736caaf151so419644eaf.3 for ; Sun, 03 Sep 2023 08:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693753879; x=1694358679; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=JmW2hHW3C8owtS6tRsT5SlZnBjH8X8Bua4Quu0LJ4r8=; b=l6Dv4/4PqXL4YTF5ahTElFG/Rlxdf7HyESYk+omY36MBoJC+VBBnJWxli9JtBbDF/X /mKtOtSsaF7lt5xWSLYHrQDjV8dG3ZQaRRzL3XrNVfWerUEnI3L+fF2Mha5yU/a3MJVm u1FK323Mcd03oJtPF9Kx3AMu7RvKTXUKU+TbI2dAohQAy5UC0yd3yow4VAOMpLwKd9l2 1D9us4LutGG9HDX4C9I3tEfRWt20YzdRot3mTOZBn7wBhi48Sy4lzM2L5MZjBI9EwnYY 5CjaJ7pipB51pW2XVqj1aPV9hoQbZ3BXz9UWJqOkQu8mCqd25QZTHXB1Sxv0nU1J2oLa j0nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693753879; x=1694358679; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JmW2hHW3C8owtS6tRsT5SlZnBjH8X8Bua4Quu0LJ4r8=; b=JKXcElqi2pHB7sHHmp/WSSCDmOm6PuEeU4eVpgsslN4gZc0a84J0+NKXhJhPeBAwV6 vstjrwvAhyvmrv4L/T/BPy6FIsSHbNbOtCHlTo7SyAqgcdh3x675BTCTYA6ruXjXuXBt lJekbJA/GJ2b/u1X29A3/9045PPqaPDN4FKezIGJfo0RT4GMWBRgwS284trMSKfnEKvz Cto6JzfXtMR66I0O1Rh6A4GT6zxkNLh1W+7W63BZQME/em2vsrRXke2ovbb5JAThvmI2 U08TFg2ph3JHXa3QySR1UVPT6hJH4xywoe2SPccpve97ocUV2M5fPjk2x3hQlUpiA5IB 8v/w== X-Gm-Message-State: AOJu0YwqUp3c/rsvK9XBt8QmaCdoZMhSLjAbKK8SzwBqNQpQbiyzdGkD EI6aXbl+xhpylKCxJkrcoTc= X-Google-Smtp-Source: AGHT+IE1gLxLfEofKRiEzE3Ho1BklFTFymKN6sdBKd+we/ngX+ySmpCKy5neBw1knQhWZTC57idQ7A== X-Received: by 2002:a4a:91d6:0:b0:570:fdf2:41f0 with SMTP id e22-20020a4a91d6000000b00570fdf241f0mr6561201ooh.1.1693753879452; Sun, 03 Sep 2023 08:11:19 -0700 (PDT) Received: from nathanxps13 ([2600:1700:48f8:340f:1ac:53a4:a196:ccab]) by smtp.gmail.com with ESMTPSA id q65-20020a4a4b44000000b0056688eea98csm4063786ooa.27.2023.09.03.08.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Sep 2023 08:11:18 -0700 (PDT) Date: Sun, 3 Sep 2023 08:11:16 -0700 From: Nathan Bossart To: Alvaro Herrera Cc: Robert Haas , Tom Lane , Andrew Dunstan , pgsql-hackers@lists.postgresql.org Subject: Re: Inefficiency in parallel pg_restore with many tables Message-ID: <20230903151116.GA3460412@nathanxps13> References: <20230902185521.GA3414119@nathanxps13> <20230903100400.nbmajh4ppz5tkzff@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230903100400.nbmajh4ppz5tkzff@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Sep 03, 2023 at 12:04:00PM +0200, Alvaro Herrera wrote: > On 2023-Sep-02, Nathan Bossart wrote: >> I ended up hacking together a (nowhere near committable) patch to see how >> hard it would be to allow using any type with binaryheap. It doesn't seem >> too bad. > > Yeah, using void * seems to lead to interfaces that are pretty much the > same as bsearch() or qsort(). Right. This is what I had in mind. > (Why isn't your payload type const, > though?) It probably should be const. This patch was just a proof-of-concept and still requireѕ a bit of work. > I do wonder why did you change _remove_first and _first to have a > 'result' output argument instead of a return value. Does this change > actually buy you anything? simplehash.h doesn't do that either. > >> -extern void binaryheap_add(binaryheap *heap, Datum d); >> -extern Datum binaryheap_first(binaryheap *heap); >> -extern Datum binaryheap_remove_first(binaryheap *heap); >> -extern void binaryheap_replace_first(binaryheap *heap, Datum d); >> +extern void binaryheap_add(binaryheap *heap, void *d); >> +extern void binaryheap_first(binaryheap *heap, void *result); >> +extern void binaryheap_remove_first(binaryheap *heap, void *result); >> +extern void binaryheap_replace_first(binaryheap *heap, void *d); _first could likely just return a pointer to the data in the binary heap's array. However, _remove_first has to copy the data somewhere, so I think the alternative would be to return a palloc'd value. Is there another way that I'm not thinking of? -- Nathan Bossart Amazon Web Services: https://aws.amazon.com