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 1uYxqh-00E6Xe-F5 for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jul 2025 02:14:23 +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 1uYxqf-005iqQ-5P for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jul 2025 02:14:21 +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 1uYxqe-005iqG-Q6 for pgsql-hackers@lists.postgresql.org; Tue, 08 Jul 2025 02:14:21 +0000 Received: from mailfr00.databene.net ([31.170.12.19]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uYxqc-006N5J-36 for pgsql-hackers@lists.postgresql.org; Tue, 08 Jul 2025 02:14:21 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mailfr00.databene.net (Postfix) with ESMTP id 437235F2D2; Tue, 8 Jul 2025 04:14:18 +0200 (CEST) X-Virus-Scanned: by Amavis at mailfr00.databene.net Received: from mailfr00.databene.net ([127.0.0.1]) by localhost (databene-mailfr00.evolix.net [127.0.0.1]) (amavis, port 10024) with LMTP id CnSglQ2DJCbe; Tue, 8 Jul 2025 04:14:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=data-bene.io; s=2024; t=1751940856; bh=pzNzXtQViEN+/adRbuiHqSQ6eGzi1+OtV1KPxcD1AvM=; h=Date:Subject:From:To:References:In-Reply-To:From; b=oQRLfriwlWQl5oUfWg0gao4F479EkJUcXnrfsOGTSYfz+W+cp57CQwim8nKIMiFfE BgjghsfimAWaRtwQmdfI/34Ym6jtLqwXUli8ZfxzDp7Neb0o2jvDz0gTV4d5WUl1lZ XIE9kWYlcqMh8TTtdMxeLSJHec+0erAFCyH6tqRKOkvw6CJRjA8QSp4QqtTlIJaYUY uA773zqoNGQz4Sbgrj76srOb4+4mU5/JbDcFDsL5Bk7PPVAn5umu6WV5147Y9OOYiB TuX4bg5tGqOoPtlA/J+tChlo/zmPrCrZFJFCU5bTbdMQFy643Jq6q2mNqLcxvFQ3Np WUgojvBx/g+vJQ6WGvpAPMXkK9cQs8JDzsf3kGBrUQNALRfmzHr/i0TKg1yC3AR/a/ HkagdokU1y5biRKKWpYU0fFLWWw6vS2qaqbszY0ZXHHFkNvCRnmvpv2Acz8SO9W7Ys y2/xSDR2Iggw9VU1k4R081Ewj9iRZrwHwdJd6QuDdw1E3jTEqmU6jFVNt3YviV3gD6 jzCB8KNGfP2GfmOGx/qD2PgQv9KKzeqFSg8CCw88TQuN3CemmyUal9fAVz7AqF8eqZ IjdD6VwH4BdsVvfEumWnlJjoTTDs8UVzjLN8xz3mWKzOIfJyksQwnROVio/uEeK1Rf Zz01e/el1R1VGRWopuYfWInI= Received: from [127.0.0.1] (257400053.box.freepro.com [95.178.90.96]) by mailfr00.databene.net (Postfix) with ESMTPSA id DC6525F2A1; Tue, 8 Jul 2025 04:14:15 +0200 (CEST) Message-ID: Date: Tue, 8 Jul 2025 02:14:00 +0000 MIME-Version: 1.0 Subject: Re: Adding basic NUMA awareness - Preliminary feedback and outline for an extensible approach From: =?UTF-8?Q?C=C3=A9dric_Villemain?= To: Tomas Vondra , PostgreSQL Hackers References: <099b9433-2855-4f1b-b421-d078a5d82017@vondra.me> <1caea3b1-3e0b-4bdb-a630-75671f1f837a@data-bene.io> <8b3341ee-1f8e-4dbb-8046-410f71d4a0cb@vondra.me> <2616b89d-3cd0-4a38-915d-2741da81e0a1@vondra.me> <1cd9d7e0-d1ae-4c74-91b5-fbbf8046ee56@data-b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0UNgOMgmBsT5+rgFm+xqY6TOrvnDVGUbAGkJIdzgTjzeu96BcBEuF 59r+grsmff8PUGtertKeXBr8NlliYZEFCilqus3PheOetWewysHROQJrqnSkpRP7zJWyFYY5 W6PWKQlUgcItrWsgPlHl5gmoH68zesTlW1rX1Z56V8vLPF7RTAPG6g1J7l29wLxUYTwF5Y64 gy+jXAEUJHKZABEBAAHCwF8EGAECAAkFAkvW1WwCGwwACgkQ2yAfTLNUF5ubKAgAtZdh0QJU Wc7WfZhoGOcAEADZJ9n6GSuhL+oxuhPfym1zsU70241rKYZH1m53CWWo+aNyThCXJx+HSSRV /hLNVW34DErJeNJIYwdxPo5/AjOhIUr4e8gMYuviFESBaMpgl8mSM1B1cHVBMZcsQb43Rc3V VfIMNRc4NB16uc7Sm++fbraQq13rB8HC6uYu7PbEAdX3C0IokR3JGb1NghQKga/OoU22KPEx Y+bFk4h3vq9MjlKLir0UJZHKSQ5xec6RcehoMBy0FHBEuK/72xN36dR/3bVwyeR76S7xf9UQ gXdpciBG95/tLRcpelwx8GaRcivTGc0FCBUzqG/YcCqvcA== In-Reply-To: <1cd9d7e0-d1ae-4c74-91b5-fbbf8046ee56@data-bene.io> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk >> On 7/7/25 16:51, Cédric Villemain wrote: >>>>> * Others might use it to integrate PostgreSQL's own resources (e.g., >>>>> "areas" of shared buffers) into policies. >>>>> >>>>> Hope this perspective is helpful. >>>> >>>> Can you explain how you want to manage this by an extension defined at >>>> the SQL level, when most of this stuff has to be done when setting up >>>> shared memory, which is waaaay before we have any access to catalogs? >>> >>> I should have said module instead, I didn't follow carefully but at some >>> point there were discussion about shared buffers resized "on-line". >>> Anyway, it was just to give some few examples, maybe this one is to be >>> considered later (I'm focused on cgroup/psi, and precisely reassigning >>> PIDs as needed). >>> >> >> I don't know. I have a hard time imagining what exactly would the >> policies / profiles do exactly to respond to changes in the system >> utilization. And why should that interfere with this patch ... >> >> The main thing patch series aims to implement is partitioning different >> pieces of shared memory (buffers, freelists, ...) to better work for >> NUMA. I don't think there's that many ways to do this, and I doubt it >> makes sense to make this easily customizable from external modules of >> any kind. I can imagine providing some API allowing to isolate the >> instance on selected NUMA nodes, but that's about it. >> >> Yes, there's some relation to the online resizing of shared buffers, in >> which case we need to "refresh" some of the information. But AFAICS it's >> not very extensive (on top of what already needs to happen after the >> resize), and it'd happen within the boundaries of the partitioning >> scheme. There's not that much flexibility. >> >> The last bit (pinning backends to a NUMA node) is experimental, and >> mostly intended for easier evaluation of the earlier parts (e.g. to >> limit the noise when processes get moved to a CPU from a different NUMA >> node, and so on). > > The backend pinning can be done by replacing your patch on proc.c to > call an external profile manager doing exactly the same thing maybe ? > > Similar to: > pmroutine = GetPmRoutineForInitProcess(); > if (pmroutine != NULL && >     pmroutine->init_process != NULL) >     pmroutine->init_process(MyProc); > > ... > > pmroutine = GetPmRoutineForInitAuxilliary(); > if (pmroutine != NULL && >     pmroutine->init_auxilliary != NULL) >     pmroutine->init_auxilliary(MyProc); > > Added on some rare places should cover most if not all the requirement > around process placement (process_shared_preload_libraries() is called > earlier in the process creation I believe). > After a first read I think this works for patches 002 and 005. For this last one, InitProcGlobal() may setup things as you do but then expose the choice a bit later, basically in places where you added the if condition on the GUC: numa_procs_interleave). -- Cédric Villemain +33 6 20 30 22 52 https://www.Data-Bene.io PostgreSQL Support, Expertise, Training, R&D