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 1uXx1R-00GZbL-8f for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Jul 2025 07:09:17 +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 1uXx1O-003cV8-HV for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Jul 2025 07:09:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uXx1O-003cUr-7S for pgsql-hackers@lists.postgresql.org; Sat, 05 Jul 2025 07:09:14 +0000 Received: from mailfr00.databene.net ([31.170.12.19]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uXx1L-005fw7-21 for pgsql-hackers@lists.postgresql.org; Sat, 05 Jul 2025 07:09:13 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mailfr00.databene.net (Postfix) with ESMTP id 681635F2D4; Sat, 5 Jul 2025 09:09:09 +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 3bmuVCWe0kyT; Sat, 5 Jul 2025 09:09:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=data-bene.io; s=2024; t=1751699347; bh=nV4W8GYJaMdss8SJJ2TLRexaznRSBAoa0JGxtEPlVmo=; h=Date:Subject:To:References:From:In-Reply-To:From; b=OpgHAgwbGo6TsEAemBNcjoSniZLaL/3pw1Kz7eKo5Jwc8JTZxRnbtbxnQQCeQtwId UVaTpPm1LGx8mtrCodNMhy+YvCy1puXrwVPubwZt4fYQwQD57YV2tbLp0uRukIfERy iBQfJRhf8thEA0iiV6ep/icx+ItzqySVDaOaCHsS/+AbYrXf9BmhfT2A+iNWT4dNNd JENN3mehuKSucRamkV/YA5NGvDo6JcCSkR4UPfyhTicIOozd3TAEtyRldO/xhgkB4k w5LXYgwI7460nGdveU6mPFmsMf8PQYHrU2slEVc+jxHDjoB0r+BWcIj0lat+9cZyUx NQqrOsL0+TVOKaBOw4bTXYzvo6GWSjg6w6RYvhb/5vY4B5AyuelHt5YHuEZFmLbVhH F5kBS1/ADUFbeb45mWNIsONvhuN8CfvcY9avaodr57qJ7Qmity+Tw1L98aEQQtyBXL fGnJ+D/fGHPq0J9D3bzOJD4m+ge1ib1LdFgEJfwIXG5PhIYDfWN6PExOWFw/sMakiV 7/qmLMNnjAOzw8vCJY5lrBKcDUewNwsHWCRAkXy4nmbeAy2QHayWJpK05jcXtxxnrE sq9Z0tbrR+HUDEIpROXTy/GCc2kYlctzGszqJZkTF8JbaLJ9FFqFIB6wnkZ3Se3ZYY FNUHqOwr0eQjvAHqPDpiGYF4= Received: from [127.0.0.1] (257400053.box.freepro.com [95.178.90.96]) by mailfr00.databene.net (Postfix) with ESMTPSA id F413B5F2D0; Sat, 5 Jul 2025 09:09:06 +0200 (CEST) Message-ID: <1caea3b1-3e0b-4bdb-a630-75671f1f837a@data-bene.io> Date: Sat, 5 Jul 2025 07:09:00 +0000 MIME-Version: 1.0 Subject: Re: Adding basic NUMA awareness - Preliminary feedback and outline for an extensible approach To: Tomas Vondra , PostgreSQL Hackers References: <099b9433-2855-4f1b-b421-d078a5d82017@vondra.me> From: =?UTF-8?Q?C=C3=A9dric_Villemain?= Autocrypt: addr=cedric.villemain@data-bene.io; keydata= xsBNBEvW1WwBCAC6CG3zZnRpQwmSiFoTjaHlgt7RQ2RmYDqSB7DNtOItV9bBDUe4DKxV9iNF SoD2yV2LrzsYghWXwI0snHGVGCLkJFYBkqyMnJeli5PoHcn9jI12mOz0hdpsTmTJbH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l29wLxUYTwF5Y64 gy+jXAEUJHKZABEBAAHCwF8EGAECAAkFAkvW1WwCGwwACgkQ2yAfTLNUF5ubKAgAtZdh0QJU Wc7WfZhoGOcAEADZJ9n6GSuhL+oxuhPfym1zsU70241rKYZH1m53CWWo+aNyThCXJx+HSSRV /hLNVW34DErJeNJIYwdxPo5/AjOhIUr4e8gMYuviFESBaMpgl8mSM1B1cHVBMZcsQb43Rc3V VfIMNRc4NB16uc7Sm++fbraQq13rB8HC6uYu7PbEAdX3C0IokR3JGb1NghQKga/OoU22KPEx Y+bFk4h3vq9MjlKLir0UJZHKSQ5xec6RcehoMBy0FHBEuK/72xN36dR/3bVwyeR76S7xf9UQ gXdpciBG95/tLRcpelwx8GaRcivTGc0FCBUzqG/YcCqvcA== In-Reply-To: <099b9433-2855-4f1b-b421-d078a5d82017@vondra.me> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Tomas, I haven't yet had time to fully read all the work and proposals around=20 NUMA and related features, but I hope to catch up over the summer. However, I think it's important to share some thoughts before it's too=20 late, as you might find them relevant to the NUMA management code. > 6) v1-0006-NUMA-pin-backends-to-NUMA-nodes.patch >=20 > This is an experimental patch, that simply pins the new process to the > NUMA node obtained from the freelist. >=20 > Driven by GUC "numa_procs_pin" (default: off). In my work on more careful PostgreSQL resource management, I've come to=20 the conclusion that we should avoid pushing policy too deeply into the=20 PostgreSQL core itself. Therefore, I'm quite skeptical about integrating=20 NUMA-specific management directly into core PostgreSQL in such a way. We are working on a PROFILE and PROFILE MANAGER specification to provide=20 PostgreSQL with only the APIs and hooks needed so that extensions can=20 manage whatever they want externally. The basic syntax (not meant to be discussed here, and even the names=20 might change) is roughly as follows, just to illustrate the intent: CREATE PROFILE MANAGER manager_name [IF NOT EXISTS] [ HANDLER handler_function | NO HANDLER ] [ VALIDATOR validator_function | NO VALIDATOR ] [ OPTIONS ( option 'value' [, ... ] ) ] CREATE PROFILE profile_name [IF NOT EXISTS] USING profile_manager SET key =3D value [, key =3D value]... [USING profile_manager SET key =3D value [, key =3D value]...] [...]; CREATE PROFILE MAPPING [IF NOT EXISTS] FOR PROFILE profile_name [MATCH [ ALL | ANY ] ( [ROLE role_name], [BACKEND TYPE backend_type], [DATABASE database_name], [APPLICATION appname] )]; ## PROFILE RESOLUTION ORDER 1. ALTER ROLE IN DATABASE 2. ALTER ROLE 3. ALTER DATABASE 4. First matching PROFILE MAPPING (global or specific) 5. No profile (fallback) As currently designed, this approach allows quite a lot of flexibility: * pg_psi is used to ensure the spec is suitable for a cgroup profile=20 manager (moving PIDs as needed; NUMA and cgroups could work well=20 together, see e.g. this Linux kernel summary:=20 https://blogs.oracle.com/linux/post/numa-balancing ) * Someone else could implement support for Windows or BSD specifics. * Others might use it to integrate PostgreSQL's own resources (e.g.,=20 "areas" of shared buffers) into policies. Hope this perspective is helpful. Best regards, --=20 C=C3=A9dric Villemain +33 6 20 30 22 52 https://www.Data-Bene.io PostgreSQL Support, Expertise, Training, R&D