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 1rBVQ6-00B8wj-Sj for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Dec 2023 07:37:10 +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 1rBVQ5-005Ruf-Hn for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Dec 2023 07:37:09 +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 1rBVQ5-005Rta-7g for pgsql-hackers@lists.postgresql.org; Fri, 08 Dec 2023 07:37:09 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBVQ3-00Agu3-1P for pgsql-hackers@postgresql.org; Fri, 08 Dec 2023 07:37:08 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id BC0A25C0194; Fri, 8 Dec 2023 02:37:05 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 08 Dec 2023 02:37:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1702021025; x=1702107425; bh=pj hkoRz7VjK+lRqlgjBedj0Id/fEkszG/bs/u9z+Bzo=; b=CFJy0ECK8nbEISlqZi fkz1jlzthXc4fYDBvQVsyn6yKQUTHAomh6nqV0oOP9HEiSEUBCz94sKx6SOVH8ks LqzFQoeNIXtzlpOLFaTL/aan/QqpZHpoTFJr/9HLje2WL4iMHqLcp52bW7UHQd0S KaQr6A27ThpRzB3cGkvfOcSyF+kFhRhWiI4fRo2/NZxJ3Az1Prer39BxcEcwDLwJ /5+Ip7i5soUBIYdtJfNSt6JXCG5pEFEsN4uqUB+Jubb2oDnkjW7kjhhPoBzQTA3A to0pqX5ta8zy7g9cBUJqGCr4uvfjNgBWZDMjC80iSO2FQyOlrQHkLCbOfE0AJxOJ an7g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1702021025; x=1702107425; bh=pjhkoRz7VjK+l RqlgjBedj0Id/fEkszG/bs/u9z+Bzo=; b=amdXQUDabuIBingbtpfSHNoQCPObj sE8g97ObFIx5kVUEWeGpfcxd/bVeZZ1fumNdLqTYUaunlRhLU07yPKYg6uGO9QTA Dt22GYMZIkbxZvL5rFZEJYyCEFjnqyInvfe2UklJUamYhzBbumb+SdTROyqIk9nd vo4JrwWULnx+B0sqe3mVn307x8Hqv9XnIY0RSX8kVEDerSIgLpPUWEn3dJ9qzB6z /Gl4i83g9BQ7PTqY9JJP/a+SV/8U8Zekmiz7azOQjAjNktEu4ZEBzAv9kYOkPv4q gsNGJltnk1QXDPo4Xbh6dhqt13096lLk1y5fW0QNgWt0K7pUWCLBkRS4Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudekhedgheehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtdorredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepffduleehgefhkeefgfeftdfh kedutddvhfdukeeggeehieekffelhfelkeehteefnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 8 Dec 2023 02:37:03 -0500 (EST) Date: Fri, 8 Dec 2023 16:36:52 +0900 From: Michael Paquier To: Nathan Bossart Cc: pgsql-hackers@postgresql.org Subject: Re: introduce dynamic shared memory registry Message-ID: References: <20231205034647.GA2705267@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="toCSjQE5LvDLnrDu" Content-Disposition: inline In-Reply-To: <20231205034647.GA2705267@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --toCSjQE5LvDLnrDu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 04, 2023 at 09:46:47PM -0600, Nathan Bossart wrote: > The attached 0001 introduces a "DSM registry" to solve this problem. The > API provides an easy way to allocate/initialize a segment or to attach to > an existing one. The registry itself is just a dshash table that stores > the handles keyed by a module-specified string. 0002 adds a test for the > registry that demonstrates basic usage. >=20 > I don't presently have any concrete plans to use this for anything, but I > thought it might be useful for extensions for caching, etc. and wanted to > see whether there was any interest in the feature. Yes, tracking that in a more central way can have many usages, so your patch sounds like a good idea. Note that we have one case in core that be improved and make use of what you have here: autoprewarm.c. The module supports the launch of dynamic workers but the library may not be loaded with shared_preload_libraries, meaning that it can allocate a chunk of shared memory worth a size of AutoPrewarmSharedState without having requested it in a shmem_request_hook. AutoPrewarmSharedState could be moved to a DSM and tracked with the shared hash table introduced by the patch instead of acquiring AddinShmemInitLock while eating the plate of other facilities that asked for a chunk of shmem, leaving any conflict handling to dsm_registry_table. +dsm_registry_init_or_attach(const char *key, void **ptr, size_t size, + void (*init_callback) (void *ptr)) This is shaped around dshash_find_or_insert(), but it looks like you'd want an equivalent for dshash_find(), as well. -- Michael --toCSjQE5LvDLnrDu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmVyx5QACgkQnvQgOdby QH2Aiw//Xk05/4qzBiKBexwXgKrir1Tk/lalWB0QGC6otOULfZvfDH/wAxSEQZCl Qt4q6m9poI0bsFNl3MnyL+JUHcX5wf2qRZywJkrA07PrybEt5RGSFtVrAIVOj+cA kwLh1YaPXYrS+viUraHGzVhE+O1kXI8s6zLlONQjzrBVdJK+zyZYGUXOvZ1+7SEc bfKT74F7sKmbVlOYkZyem6b1wlhWTeORQD08fr/tQY2N9jkTdpP4qb0QmTIfSsgt AeYx6ARZkSAiZxWP7VdHB2MfvJnxRBJUhKuaU098q1gA4VNu+0FSK8P1EjZ03OXa FE/nHB03dPAPL6EiGa28qJwTBlmuvsnJIFPcNlFv3AGLWsuL4AzUQFa1HzvTOpYh zHDkwBRRx4m9xulM2xfeRRU3RUzGSKFWTkrwtT5bMnxfNg7P6JeTjYa4oaya0Iqj ErJdqYPabnTGXw3uOWiiSZ0p4VQ2LsE6kr/6HiocTBF9nFVTBW+8fKLB6wREvZ3T xSXAP3SGnXbKcaOTbfW4qD+zxi1lWkD9HvmEY0A70xIs+3EwtcCIzfIqsqFJLMOB 1krkTLZcp/eOy3wFlzR6k7HI+Y2nYdBeikh8CrbEkDlmH+e0SVM8BWoExaf9Mnyj wTRrRweV5qT4h3auNXZbufEijGdbqNk60H+8DXnl+NzibPkTXjQ= =PAlT -----END PGP SIGNATURE----- --toCSjQE5LvDLnrDu--