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.96) (envelope-from ) id 1vqd3a-00Ek2v-2J for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Feb 2026 20:13:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vqd3Z-00Aygv-3B for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Feb 2026 20:12:58 +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.96) (envelope-from ) id 1vqd3Z-00Aygl-0q for pgsql-hackers@lists.postgresql.org; Thu, 12 Feb 2026 20:12:58 +0000 Received: from fhigh-b6-smtp.messagingengine.com ([202.12.124.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vqd3X-00000000NBj-2GMT for pgsql-hackers@postgresql.org; Thu, 12 Feb 2026 20:12:57 +0000 Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id AF0EF7A0171; Thu, 12 Feb 2026 15:12:52 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Thu, 12 Feb 2026 15:12:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1770927172; x=1771013572; bh=ntVyLkKxBq 8/WdPUF1HAPeWlvvpkkCW1qpZwudv4RpY=; b=INJ/pUYvbV3+xDiWIdggZB8mKg I1k/rLoxToa8M62AKNd7IHjpb0mFN0if1TP8/znyYGyDhVRb1V8xXEd+UvW60844 hl6N9Bej61J8MgeLXiaYuc7lkT7Z6DaONeRSNXZ0OpjAV2WgmcO+Rk4PBA2mmVgV c1d3XJXDi4AzoQ/M16lvafqhtWptaN79Fg2FdZNKBXkSsOBMgaSLD1a6YFdp4TYM RR0GxP4ibfwq3a65YBGijBV+AXOAGRt124QNwGpZHy/9UN6ho5rNuhJ+roYa2H80 aBE0+lUQCYOYOZXwX7973KVSNOzuFYThDA5/VwVo5AGzaQy25oJqPO5TOnjw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1770927172; x=1771013572; bh=ntVyLkKxBq8/WdPUF1HAPeWlvvpkkCW1qpZ wudv4RpY=; b=Xm/K/itJHdvDA3mcwbuiulq1fYP42uw5w9bhJJkrlaL+UcxP4cl DWlDqugFEbnmEzEmN22jP8aee8r3vBGzMI8w5LsFTwPqep9p5KieFoIbsEdNzkWT cSB9t6xPXC14l6OMF6uOuWvQpEDuqdQkewmfeBqd9Bh9aBDoJTQAhDHDyFjXykaS dyfdBowBZgzaA6pSKgotZ+chCKNtRcHVFTsUQYbiTv9oLNSdJuwRaKMm4zJ0vQhH g216RjP7Bx2SBkuE1uX4j4fWNL44gMMpQJ6im4rhSSYm4pEORKA7iDUjIZBqPknk BOmmBb3CSn72EcRJYQnXS8u2zchmxwiv+2w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvtdeifedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepvdfffeevhfetveffgeeiteefhfdtvdffjeevhfeuteegleduheetveduieet tddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopeelpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopehpvghtvghrsegvihhsvghnthhrrghuthdrohhrgh dprhgtphhtthhopeelvghrthhhrghlihhonheisehgmhgrihhlrdgtohhmpdhrtghpthht oheprghshhhuthhoshhhrdgsrghprghtrdhoshhssehgmhgrihhlrdgtohhmpdhrtghpth htoheptghhrghtuhhrvhgvughiphgrlhgrkhduleduudesghhmrghilhdrtghomhdprhgt phhtthhopehrohgsvghrthhmhhgrrghssehgmhgrihhlrdgtohhmpdhrtghpthhtohepth hhohhmrghsrdhmuhhnrhhosehgmhgrihhlrdgtohhmpdhrtghpthhtohephhhlihhnnhgr khgrsehikhhirdhfihdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsth hgrhgvshhqlhdrohhrghdprhgtphhtthhopehtohhmrghssehvohhnughrrgdrmhgv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Feb 2026 15:12:51 -0500 (EST) Date: Thu, 12 Feb 2026 15:12:50 -0500 From: Andres Freund To: Ashutosh Bapat Cc: Heikki Linnakangas , Tomas Vondra , Peter Eisentraut , Thomas Munro , Dmitry Dolgov <9erthalion6@gmail.com>, pgsql-hackers@postgresql.org, Robert Haas , chaturvedipalak1911@gmail.com Subject: Re: Changing shared_buffers without restart Message-ID: References: <9ac6082a-2e30-4462-a260-1507452aa962@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-02-10 11:02:13 +0530, Ashutosh Bapat wrote: > > I still don't see what the point of having multiple mappings and using memfd > > is. We need to reserve the address space for the maximum sized allocation in > > postmaster, otherwise there's absolutely no guarantee that it's available at > > those addresses in all the children - which you do as you explain > > here. Therefore, the maximum size of each "suballocation" needs to be reserved > > ahead of time. At which point I don't see the point of having multiple > > mmaps. It just makes things more complicated and expensive (each mmap makes > > fork & exit slower). > > > > Even if we decide to use memfd, because we consider MADV_DONTNEED to not be > > suitable for some reason, what's the point of having more than one mapping > > using memfd? (this should reference MADV_REMOVE, not MADV_DONTNEED) > There are just two mappings now compared to 6 earlier. If I am reading > Jakub's benchmarking correctly, even 6 segments didn't show much > regression in his benchmarks. Having just two should not see much > regression. If we use multiple mappings we could control the > properties of each segment separately - e.g. use huge pages for some > (buffer blocks) and not for others. In Windows it seems it is easy to > create multiple segments than punching holes in an existing segments. > When we port the feature to Windows or other platforms, being able to > treat all the segments in the same way would be an advantage. > Said that I am not discarding the idea of using a single fd and then > punching holes using fallocate() altogether; we will use it if > multiple mappings do not bring any advantages. Let's also see how the > on-demand shared memory segment feature being discussed in this thread > with Heikki gets shaped. I think the multiple memory mappings approach is just too restrictive. If we e.g. eventually want to make some of the other major allocations that depend on NBuffers react to resizing shared buffers, it's very easy to do if all it requires is calling madvise(TYPEALIGN(start, page_size), MADV_REMOVE, TYPEALIGN_DOWN(end, page_size)); There are several cases that are pretty easy to handle that way: - Buffer Blocks - Buffer Descriptors - Sync request queue (part of the "Checkpointer Data" allocation) - Checkpoint BufferIds (for sorting the to-be-checkpointed data) - Buffer IO Condition Variables But if you want to support making these resizable with the separate mappings approach, it gets considerably more complicated and the number of mappings increases more substantially. We also don't need a lot less infrastructure in shmem.c that way. We could e.g. make ShmemInitStruct() reservere the entire requested size (to avoid OOM killer issues) and have a ShmemInitStructExt() that allows the caller choose whether to reserve. No different segment IDs etc are needed. Greetings, Andres Freund