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 1rMtEr-007S7M-Cm for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Jan 2024 17:16:37 +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 1rMtEq-006Z6G-E5 for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Jan 2024 17:16:36 +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 1rMtEq-006Z67-4j for pgsql-hackers@lists.postgresql.org; Mon, 08 Jan 2024 17:16:36 +0000 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rMtEl-000VYl-Eq for pgsql-hackers@postgresql.org; Mon, 08 Jan 2024 17:16:35 +0000 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7bc332d49f6so108103539f.1 for ; Mon, 08 Jan 2024 09:16:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704734189; x=1705338989; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ZQfB6O1lcDgrahPGmiTc3VR8xUxymtdoOGfXB3FVNNU=; b=NzNa0Mw2SYp1RtYLIu4OHpYw6+m6mFcdh3hzTrV5Fm/626/cfZNAWiyNUrqU2UZGo4 8obz5CMNWB30TMa8X7xh9WOdKp0qx2rjmc+H3/n6jR5qVR9TezNWys67fgMrwdaEv3e1 oiGiNugNAmGH9tw3uhHKF7IWE+fSYZMMe4TBfnHulompytZHJB3azUvGvvYaoukKrpkR z4aJ7CBY1tQVcoSusHxgPN5256yWg8BTH8/4e9KlN6bwq4iDp/M6yspQGTZmAbd8bPaY irpGiWFy7xPfob8RE+VkWnjBI2W/KXeHjiyPJwnbNHKPHB3QiR04QiirLQFIg61aYdbk xc6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704734189; x=1705338989; h=in-reply-to: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=ZQfB6O1lcDgrahPGmiTc3VR8xUxymtdoOGfXB3FVNNU=; b=J+/jzjhP2dN7jrUHosscXzJT3z0KloUspbFyirOqBtS32KtY5d+XcYSa7/1Awi530l vrDqHi46NeveeuWZ8TzVnjAkoHK2I+fVbvQnx3p6RLNKOh9ZdoWS6j5IRqz6yY4lpj1P WGNBlNmq/QZZZiav03q2I3SROZlba2l0ml9tcMg3dWMluEVoIW5bFfYee8Xft+YWSBCr wbD03hBapVNbw1grNLfjuW+hwXKlnBWjTPsKYesHIIOEaTiQuhMW7YXB3ZOeSSgU5mpG k2gs0iwRPQJvWZ41Qkz8I3+eNmY61JL0arpKJGjefKHA9zXrgXffHP2AGNKU2aoJGT/K bCaA== X-Gm-Message-State: AOJu0YzMITi05FTeIjBvXAl4KIrqljLzEsl/L5rDW04c1dAqmtVQBq/3 dciD0i7Kixle3a87ErY1crU= X-Google-Smtp-Source: AGHT+IGDrTaAL+93y6fiJ5EpCYItZq9Z0iBmNx57596hyCdsUDfj5wjOwI4ra6a5Wby4cCsHdPzrGQ== X-Received: by 2002:a5e:df49:0:b0:7bc:25d7:2bc6 with SMTP id g9-20020a5edf49000000b007bc25d72bc6mr5422687ioq.20.1704734189181; Mon, 08 Jan 2024 09:16:29 -0800 (PST) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ei9-20020a05663829a900b0046dcaba1adesm73534jab.62.2024.01.08.09.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 09:16:28 -0800 (PST) Date: Mon, 8 Jan 2024 11:16:27 -0600 From: Nathan Bossart To: Bharath Rupireddy Cc: Robert Haas , pgsql-hackers@postgresql.org Subject: Re: introduce dynamic shared memory registry Message-ID: <20240108171627.GA2611898@nathanxps13> References: <20231205034647.GA2705267@nathanxps13> <20231220160324.GB833819@nathanxps13> <20240102162054.GB955987@nathanxps13> <20240102224907.GA1246933@nathanxps13> <20240106163516.GB2435448@nathanxps13> 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: Archived-At: Precedence: bulk On Mon, Jan 08, 2024 at 10:53:17AM +0530, Bharath Rupireddy wrote: > 1. I think we need to add some notes about this new way of getting > shared memory for external modules in the Shared Memory and > LWLocks section in xfunc.sgml? This will at least tell there's > another way for external modules to get shared memory, not just with > the shmem_request_hook and shmem_startup_hook. What do you think? Good call. I definitely think this stuff ought to be documented. After a quick read, I also wonder if it'd be worth spending some time refining that section. > 2. FWIW, I'd like to call this whole feature "Support for named DSM > segments in Postgres". Do you see anything wrong with this? Why do you feel it should be renamed? I don't see anything wrong with it, but I also don't see any particular advantage with that name compared to "dynamic shared memory registry." > 3. IIUC, this feature eventually makes both shmem_request_hook and > shmem_startup_hook pointless, no? Or put another way, what's the > significance of shmem request and startup hooks in lieu of this new > feature? I think it's quite possible to get rid of the shmem request > and startup hooks (of course, not now but at some point in future to > not break the external modules), because all the external modules can > allocate and initialize the same shared memory via > dsm_registry_init_or_attach and its init_callback. All the external > modules will then need to call dsm_registry_init_or_attach in their > _PG_init callbacks and/or in their bg worker's main functions in case > the modules intend to start up bg workers. Am I right? Well, modules might need to do a number of other things (e.g., adding hooks) that can presently only be done when preloaded, in which case I doubt there's much benefit from switching to the DSM registry. I don't really intend for it to replace the existing request/startup hooks, but you're probably right that most, if not all, could use the registry instead. IMHO this is well beyond the scope of this thread, though. > 4. With the understanding in comment #3, can pg_stat_statements and > test_slru.c get rid of its shmem_request_hook and shmem_startup_hook > and use dsm_registry_init_or_attach? It's not that this patch need to > remove them now, but just asking if there's something in there that > makes this new feature unusable. It might be possible, but IIUC you'd still need a way to know whether the library was preloaded, i.e., all the other necessary hooks were in place. It's convenient to just be able to check whether the shared memory was set up for this purpose. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com