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 1uZFpU-000si8-9g for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jul 2025 21:26:20 +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 1uZFpS-00C5Zc-5z for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jul 2025 21:26:18 +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 1uZFpR-00C5ZU-Ns for pgsql-hackers@lists.postgresql.org; Tue, 08 Jul 2025 21:26:18 +0000 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uZFpN-006He0-27 for pgsql-hackers@lists.postgresql.org; Tue, 08 Jul 2025 21:26:17 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 527FB443A2; Tue, 8 Jul 2025 21:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vondra.me; s=gm1; t=1752009970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YJwKH9t2WmnJCbzWu+mvAyAA6r8Sczakg30R9Ta+3a8=; b=L1spQCEqzyMB622X90Yno7dZuRis6vq21eVppvJy8eG9onUGPKW1B2YMI46mJLaDOozwjq p8tQkR2o8QIhzGlDqOR5d6kY2i5oU3orzwLZly5ZifH+Ug4I/P5I4+ee8oBOd4RBVmHFsD F6xVcQAihTI6X2o+RfsXPsBeGvSdJm53RFSHSswWFOM5YbdrTSsvd9/xWlIWMDgF3RBUla 9y6Q7CP1Ka+P/FCvlmmLIwxgJ+JkDy0LJ63Z7wVgtjyNulhoNZZVBKnueL88I8TZnVXcdI xMvK85IeFPjLbFwyPYoSCszLhf3/8rqquWQGmIOfUWV8O5Gx8dkOmb0ibNhrTw== Message-ID: <89c1f26c-977f-44e2-9d78-ddff7c8268b2@vondra.me> Date: Tue, 8 Jul 2025 23:26:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Adding basic NUMA awareness - Preliminary feedback and outline for an extensible approach To: =?UTF-8?Q?C=C3=A9dric_Villemain?= , 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> Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdefheejhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpefvohhmrghsucggohhnughrrgcuoehtohhmrghssehvohhnughrrgdrmhgvqeenucggtffrrghtthgvrhhnpeeuvddvieefffefkedugefgtdeigeelgfegudehffevieehgffghefgvdduteffveenucfkphepkeeirdegledrvdeftddrvddtieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeekiedrgeelrddvfedtrddvtdeipdhhvghloheplgdutddrudefjedrtddrvdgnpdhmrghilhhfrhhomhepthhomhgrshesvhhonhgurhgrrdhmvgdpnhgspghrtghpthhtohepfedprhgtphhtthhopegtvggurhhitgdrvhhilhhlvghmrghinhesuggrthgrqdgsvghnvgdrihhopdhrtghpthhtoheprghnughrvghssegrnhgrrhgriigvlhdruggvpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-GND-Sasl: tomas@vondra.me List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/8/25 18:06, Cédric Villemain wrote: > > > > > > >> 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. > Well, it needs to understand how some other stuff (especially PGPROC entries) is distributed between nodes. I'm not sure how much of this internal information we want to expose outside core ... > 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. > I'm not against making this extensible, in some way. But I still struggle to imagine a reasonable alternative policy, where the external module gets the same information and ends up with a different decision. So what would the alternate policy look like? What use case would the module be supporting? regards -- Tomas Vondra