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 1uZ7Py-00GM5i-CU for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jul 2025 12:27:26 +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 1uZ7Pv-007iU8-TB for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jul 2025 12:27:24 +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 1uZ7Pv-007iS8-Dj for pgsql-hackers@lists.postgresql.org; Tue, 08 Jul 2025 12:27:24 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uZ7Pt-006Dey-2T for pgsql-hackers@lists.postgresql.org; Tue, 08 Jul 2025 12:27:23 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id AA06A44380; Tue, 8 Jul 2025 12:27:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vondra.me; s=gm1; t=1751977636; 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=m7TXii/+gkgoVYbeylPa2mFXkfZi8DZSYcbBnpAab2c=; b=jfiHPMN4CC243IhRGble86qU82H9Ucut9VMu6ValLCvHbZlG3wh8HyqnBqDVHMpEeiPr6I b3l09HCu5pwwBf+0pmbB9u8L2D9y1HHkSG3Tp3KjYt2iWA2mXnq78bfGDb918/H76P1V9a EisznHZR/nOjODGqCzqv7Xs920PVRFkje1GOG5PQJD0hCln9UWsfVLEuWIy1tmVJCpKN5w Z0jx3kAa2slLlydrOX1oqSpE1yFAmGgn3Tl0JB/o9wfvQmj2OnMpFgpd4j19XxI5gSMJ2U 8ftn/HJYdQK88VWcnsvWXk1ZupXwI8VRRjSXFuFDr/y8ipfWpU0aqDEWFJLx0Q== Message-ID: <44890599-03d0-43cd-9b7b-7b71ac351337@vondra.me> Date: Tue, 8 Jul 2025 14:27:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Adding basic NUMA awareness To: Andres Freund , Jakub Wartak Cc: PostgreSQL Hackers References: <099b9433-2855-4f1b-b421-d078a5d82017@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: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdefgeeikecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpefvohhmrghsucggohhnughrrgcuoehtohhmrghssehvohhnughrrgdrmhgvqeenucggtffrrghtthgvrhhnpeeuvddvieefffefkedugefgtdeigeelgfegudehffevieehgffghefgvdduteffveenucfkphepkeeirdegledrvdeftddrvddtieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeekiedrgeelrddvfedtrddvtdeipdhhvghloheplgdutddrudefjedrtddrvdgnpdhmrghilhhfrhhomhepthhomhgrshesvhhonhgurhgrrdhmvgdpnhgspghrtghpthhtohepfedprhgtphhtthhopegrnhgurhgvshesrghnrghrrgiivghlrdguvgdprhgtphhtthhopehjrghkuhgsrdifrghrthgrkhesvghnthgvrhhprhhishgvuggsrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg 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 05:04, Andres Freund wrote: > Hi, > > On 2025-07-04 13:05:05 +0200, Jakub Wartak wrote: >> On Tue, Jul 1, 2025 at 9:07 PM Tomas Vondra wrote: >>> I don't think the splitting would actually make some things simpler, or >>> maybe more flexible - in particular, it'd allow us to enable huge pages >>> only for some regions (like shared buffers), and keep the small pages >>> e.g. for PGPROC. So that'd be good. >> >> You have made assumption that this is good, but small pages (4KB) are >> not hugetlb, and are *swappable* (Transparent HP are swappable too, >> manually allocated ones as with mmap(MMAP_HUGETLB) are not)[1]. The >> most frequent problem I see these days are OOMs, and it makes me >> believe that making certain critical parts of shared memory being >> swappable just to make pagesize granular is possibly throwing the baby >> out with the bathwater. I'm thinking about bad situations like: some >> wrong settings of vm.swapiness that people keep (or distros keep?) and >> general inability of PG to restrain from allocating more memory in >> some cases. > > The reason it would be advantageous to put something like the procarray onto > smaller pages is that otherwise the entire procarray (unless particularly > large) ends up on a single NUMA node, increasing the latency for backends on > every other numa node and increasing memory traffic on that node. > That's why the patch series splits the procarray into multiple pieces, so that it can be properly distributed on multiple NUMA nodes even with huge pages. It requires adjusting a couple places accessing the entries, but it surprised me how limited the impact was. If we could selectively use 4KB pages for parts of the shared memory, maybe this wouldn't be necessary. But it's not too annoying. The thing I'm not sure about is how much this actually helps with the traffic between node. Sure, if we pick a PGPROC from the same node, and the task does not get moved, it'll be local traffic. But if the task moves, there'll be traffic. I don't have any estimates how often this happens, e.g. for older tasks. regards -- Tomas Vondra