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 1w8jny-000pUP-2x for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Apr 2026 19:03:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w8jnx-00DJKY-2N for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Apr 2026 19:03:42 +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.96) (envelope-from ) id 1w8jle-00DFL3-32 for pgsql-hackers@lists.postgresql.org; Fri, 03 Apr 2026 19:01:20 +0000 Received: from fhigh-b5-smtp.messagingengine.com ([202.12.124.156]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w8jlc-00000000Oyl-2XVP for pgsql-hackers@postgresql.org; Fri, 03 Apr 2026 19:01:18 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 1CA8F7A012B; Fri, 3 Apr 2026 15:01:15 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Fri, 03 Apr 2026 15:01:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding: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=fm2; t=1775242874; x=1775329274; bh=tpw/ACDYsZuFur2ChE4EZFGmf8CrCWCUy2uYHIzLQgo=; b= J82r995FxVClm/dKxxSzlt33ceaa1VGnTrp/h9HpQw/gXx4l/ztDM8GBkQooLINe P+x920oWVxpwo0NKDGUpFMGpREUc7UE8QdLpyE4BJoF51h3QjzYaEskbYxB0MB8i Qu2VggAN9L2LxtyXpi7AIt+On539/xEEy5QOxgp8la72HuVEKwk/xHBEoq5fIQtw 1T86UEbP39tD8XvpfTc1ka7Xe0Fd2J/MADTmrnbyxKnTTeB8g2igRHTIc7c+laXa NwRobkAEmXQe9szHh/VpQMOWScsqiYi7SwUTClMUQek35/y1tIjfUntl2xBjmJ5v h3dW2ZrISZ4fVfslp6Am8A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm2; t=1775242874; x= 1775329274; bh=tpw/ACDYsZuFur2ChE4EZFGmf8CrCWCUy2uYHIzLQgo=; b=T ngU148RTiDl53kiWCekdicWFOca5/wiigR8m469IK8htm6Uw/DnHiwVFf+ozKT7I TB4/B87xybswoB8QLu0Iak5ksRaqNdwnIrw570LrCCkvjytMPt70O2NnQLS5r219 QPrasdCPDMWkEM1aphruqzm3ncbC/SVsrS8bFraFPDApPENM66JY4woAsO24P5nH yER3uvJscUbVO2YnJ/yn93soQW/9th9RaViLkdtUu2Rm3EmgiN94lQF2Xus00ZA1 c7CBQ97jDEpuQVHw2V8sMbVjtom/9hTCkeNGHL9ORqBVeZMzCHPSgGt9rP9SBOft BJGKBBFBDUZFKDCWSki+A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeljeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epfffvvefukfhfgggtugfgjgfhsehtkefstddttdejnecuhfhrohhmpeetnhgurhgvshcu hfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrghtth gvrhhnpefgteeijeetieffhfevvdfgheejleejffdutddtgedvhffhtefhgeduvdffvddv tdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnh gurhgvshesrghnrghrrgiivghlrdguvgdpnhgspghrtghpthhtohepiedpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtohepphhgsegsohifthdrihgvpdhrtghpthhtohepthhvse hfuhiiiiihrdgtiidprhgtphhtthhopegshigrvhhuiiekudesghhmrghilhdrtghomhdp rhgtphhtthhopehmvghlrghnihgvphhlrghgvghmrghnsehgmhgrihhlrdgtohhmpdhrtg hpthhtohepthhhohhmrghsrdhmuhhnrhhosehgmhgrihhlrdgtohhmpdhrtghpthhtohep phhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 3 Apr 2026 15:01:13 -0400 (EDT) Date: Fri, 3 Apr 2026 15:01:13 -0400 To: Melanie Plageman Cc: Nazir Bilal Yavuz , pgsql-hackers@postgresql.org, Thomas Munro , Peter Geoghegan , Tomas Vondra Subject: Re: AIO / read stream heuristics adjustments for index prefetching Message-ID: yyFrom: Andres Freund References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: From: Andres Freund List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-04-03 12:45:50 -0400, Melanie Plageman wrote: > On Thu, Apr 2, 2026 at 9:33 AM Andres Freund wrote: > > > > > + /* > > > + * XXX: Should we actually reduce this at any time other than > > > + * a reset? For now we have to, as this is also a condition > > > + * for re-enabling fast_path. > > > + */ > > > + if (stream->combine_distance > 1) > > > + stream->combine_distance--; > > > > > > I don't think we need to reduce this other than reset. > > > > Hm. I go back and forth on that one :) > > Separate from the fast-path enablement, we also probably want to > decrease combine distance when we decrease readahead_distance because > there is a point where we still want to parallelize the IOs even when > the distance is lower and to do that, we need to make smaller IOs. I'm not sure that's something we really need to worry about at this point. If readahead_distance is so small that it does not allow enough IO concurrency, we will have to wait for IO completion, which in turn will lead to the readahead distance being increased again. I can see some corner cases where this would not suffice, e.g. if you have a rather low pin limit, but I doubt those are relevant in practice? > I'm not sure where this point is, but I wonder if a few 256kB IOs is faster > than 1 1MB IO (could test that with fio actually). Yes, that point definitely exists. But I think the mechanism for that is to configure io_combine_limit at or below the threshold at which even bigger IOs hurt. > I imagine that there is some size where that is true because of > peculiarities in how drives (and cloud storage) issue/break up IOs after > they are a certain size, etc. It's even true for synchronous copies from the kernel page cache, due to some hardware issue I have yet to fully understand. On both Intel and AMD CPUs, unless SMAP is disabled, larger copies from kernel to userspace start to to be substantially slower, somewhere around 1-4MBs per IO. Greetings, Andres Freund