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 1uZApj-00H4yd-Pk for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jul 2025 16:06:16 +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 1uZAph-009mHH-Iq for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jul 2025 16:06:14 +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 1uZApg-009mCj-R5 for pgsql-hackers@lists.postgresql.org; Tue, 08 Jul 2025 16:06:13 +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 1uZApe-006ToC-33 for pgsql-hackers@lists.postgresql.org; Tue, 08 Jul 2025 16:06:13 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mailfr00.databene.net (Postfix) with ESMTP id 2F9AB5F2D2; Tue, 8 Jul 2025 18:06: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 HpuU96FOhI_n; Tue, 8 Jul 2025 18:06:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=data-bene.io; s=2024; t=1751990767; bh=m+R49NbWQNBHHtSTOKdH23G1nNP7MoBFy/6MvugCSws=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NmafzVh9CmNjqecPmiIWjvXezjQh9RDpPXUJHwdWO4nOInSZYbvCrbWSHZUw/w9ay IBuB+hUzS08Ox8h79qWh2SfIOirr5x7zQdQBTfM/ybAPUdO/kJSECxqogB6hvutYg3 a6gYPOPfhCdYoVxazRg+P6D1BOBA9rWgR4fSaquB9kAyFcdDeWlR4iS4gRtpL7VOHa uUkDxCw68YWP42SCZUJHXoxYzfByQ1GaB38ElgzfJpnQMcj2J69B2YglkSfCJ0UPpC d7o5Wef0vCyp3F5+7kJTAt2moifrCACw6DcuGqM+HS/5ujC3X1vh9Fuew0onMmPllz pWWuvRegZsohkb8GG4F0Qh0i7wFxzpiXmIhSKmGDuOubKeUltqj/dcd8PkeAYvzj25 f9ZivO8aQpMuYcYMvbaDxfoS54x4trmSYnwazwVGM3xwaXCdfx0PYSDoLBapAwLjlk uLR1nqLKSLYXvYDHaegv7UhgbKyefELHfE00of1V1K19cT8byEqZpXbFAO917e1LPZ XG9JMrpMA1xXs/AcQ6qQfUONBKbjg5RRaZSolAvZp7zWmgM+8DObKXnsA8UXQQhFWK AWHbLUyuAp5KLpLN86IkDOts6NkpVg8/lYU59oq4ERyHEgbC1mMaZLW468rZ1I0BHN 4IcARDSg+OBpmYlSX+2ClXqE= Received: from [127.0.0.1] (257400053.box.freepro.com [95.178.90.96]) by mailfr00.databene.net (Postfix) with ESMTPSA id D983B5F2D0; Tue, 8 Jul 2025 18:06:06 +0200 (CEST) Message-ID: Date: Tue, 8 Jul 2025 16:06:00 +0000 MIME-Version: 1.0 Subject: Re: Adding basic NUMA awareness - Preliminary feedback and outline for an extensible approach To: Tomas Vondra , Andres Freund Cc: PostgreSQL Hackers References: <099b9433-2855-4f1b-b421-d078a5d82017@vondra.me> <1caea3b1-3e0b-4bdb-a630-75671f1f837a@data-bene.io> <949e555b-84ed-4f8f-863e-f88a15781142@vondra.me> From: =?UTF-8?Q?C=C3=A9dric_Villemain?= Autocrypt: addr=cedric.villemain@data-bene.io; keydata= xsBNBEvW1WwBCAC6CG3zZnRpQwmSiFoTjaHlgt7RQ2RmYDqSB7DNt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etWewysHROQJrqnSkpRP7zJWyFYY5 W6PWKQlUgcItrWsgPlHl5gmoH68zesTlW1rX1Z56V8vLPF7RTAPG6g1J7l29wLxUYTwF5Y64 gy+jXAEUJHKZABEBAAHCwF8EGAECAAkFAkvW1WwCGwwACgkQ2yAfTLNUF5ubKAgAtZdh0QJU Wc7WfZhoGOcAEADZJ9n6GSuhL+oxuhPfym1zsU70241rKYZH1m53CWWo+aNyThCXJx+HSSRV /hLNVW34DErJeNJIYwdxPo5/AjOhIUr4e8gMYuviFESBaMpgl8mSM1B1cHVBMZcsQb43Rc3V VfIMNRc4NB16uc7Sm++fbraQq13rB8HC6uYu7PbEAdX3C0IokR3JGb1NghQKga/OoU22KPEx Y+bFk4h3vq9MjlKLir0UJZHKSQ5xec6RcehoMBy0FHBEuK/72xN36dR/3bVwyeR76S7xf9UQ gXdpciBG95/tLRcpelwx8GaRcivTGc0FCBUzqG/YcCqvcA== In-Reply-To: <949e555b-84ed-4f8f-863e-f88a15781142@vondra.me> 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/8/25 03:55, Cédric Villemain wrote: >> Hi Andres, >> >>> Hi, >>> >>> On 2025-07-05 07:09:00 +0000, Cédric Villemain wrote: >>>> In my work on more careful PostgreSQL resource management, I've come >>>> to the >>>> conclusion that we should avoid pushing policy too deeply into the >>>> PostgreSQL core itself. Therefore, I'm quite skeptical about integrating >>>> NUMA-specific management directly into core PostgreSQL in such a way. >>> >>> I think it's actually the opposite - whenever we pushed stuff like this >>> outside of core it has hurt postgres substantially. Not having >>> replication in >>> core was a huge mistake. Not having HA management in core is probably the >>> biggest current adoption hurdle for postgres. >>> >>> To deal better with NUMA we need to improve memory placement and various >>> algorithms, in an interrelated way - that's pretty much impossible to do >>> outside of core. >> >> Except the backend pinning which is easy to achieve, thus my comment on >> the related patch. >> I'm not claiming NUMA memory and all should be managed outside of core >> (though I didn't read other patches yet). >> > > But an "optimal backend placement" seems to very much depend on where we > placed the various pieces of shared memory. Which the external module > will have trouble following, I suspect. > > I still don't have any idea what exactly would the external module do, > how would it decide where to place the backend. Can you describe some > use case with an example? > > Assuming we want to actually pin tasks from within Postgres, what I > think might work is allowing modules to "advise" on where to place the > task. But the decision would still be done by core. Possibly exactly what you're doing in proc.c when managing allocation of process, but not hardcoded in postgresql (patches 02, 05 and 06 are good candidates), I didn't get that they require information not available to any process executing code from a module. Parts of your code where you assign/define policy could be in one or more relevant routines of a "numa profile manager", like in an initProcessRoutine(), and registered in pmroutine struct: pmroutine = GetPmRoutineForInitProcess(); if (pmroutine != NULL && pmroutine->init_process != NULL) pmroutine->init_process(MyProc); This way it's easier to manage alternative policies, and also to be able to adjust when hardware and linux kernel changes. -- Cédric Villemain +33 6 20 30 22 52 https://www.Data-Bene.io PostgreSQL Support, Expertise, Training, R&D