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 1urlcI-00C6vC-UO for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Aug 2025 23:01: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 1urlcI-005BL5-18 for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Aug 2025 23:01: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 1urlcH-005BKK-Hr for pgsql-hackers@lists.postgresql.org; Thu, 28 Aug 2025 23:01:14 +0000 Received: from relay16.mail.gandi.net ([2001:4b98:dc4:8::236]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1urlcD-002OXm-2C for pgsql-hackers@lists.postgresql.org; Thu, 28 Aug 2025 23:01:13 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id D20E043FF3; Thu, 28 Aug 2025 23:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vondra.me; s=gm1; t=1756422064; 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=8UlRBB7R2cDkGFWP8x+rD8c7Tn6fQtV1+wP+hMx2Tpg=; b=QJ2ErynZQgv3AnHGMvehIE97NIM2q2cqGSSIbWlPjhXX6rbVZY+8YrS8AgRX0z5F4Bx3P/ yBCn/wRTWU7Gn+Tkq5dwgsC7/d/mK5uVHe5ldlwf7L2Mz5Odz/+6N2tq5ixmyyTXeYemGU yqV9bJXJILOGs01Q78kPvTPTbbE9hvDr16ZZG8YahO0ybympdM++V0kCP29TLHcbpzHdI0 DkoLjnlepUCnX9sKn2VpaTmnR8Z6FsHZTpI6zlaDQaSPhX59Yjngu8zbbiMe/psMxTH9A+ b/keakS5Ns0zxskz/50I6H4p3r84cJdsRvnrlJHUWBzCsVQZvjTApEvPDhDFmQ== Message-ID: Date: Fri, 29 Aug 2025 01:00:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: index prefetching To: Thomas Munro , Andres Freund Cc: Peter Geoghegan , Nazir Bilal Yavuz , Robert Haas , Melanie Plageman , PostgreSQL Hackers , Georgios , Konstantin Knizhnik , Dilip Kumar References: <5v2wuxg65l5e3s6uf373zskcqqoukmraxiucnvgn4t7b5cmeqx@5mhqsurdj6xn> <6butbqln6ewi5kuxz3kfv2mwomnlgtate4mb4lpa7gb2l63j4t@stlwbi2dvvev> <0dd33755-cab8-49c8-b1ed-698732577fbb@vondra.me> <1c9302da-c834-4773-a527-1c1a7029c5a3@vondra.me> <6d59c277-c440-4d1f-a46e-157958c06a5f@vondra.me> <5pltwb73d7cynsxo2yb54ygjk7haviatkrx43mnzihc6kkield@ahnstpgof46i> 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: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddukedvvdeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeenucfhrhhomhepvfhomhgrshcugghonhgurhgruceothhomhgrshesvhhonhgurhgrrdhmvgeqnecuggftrfgrthhtvghrnheptedvfefgveffgfeuhfeuueeuteegffetleevueeivdevhfefhfehteejgedutedtnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenucfkphepkeeirdegledrvdeftddrvddtieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeekiedrgeelrddvfedtrddvtdeipdhhvghloheplgdutddrudefjedrtddrvdgnpdhmrghilhhfrhhomhepthhomhgrshesvhhonhgurhgrrdhmvgdpnhgspghrtghpthhtohepuddtpdhrtghpthhtohepthhhohhmrghsrdhmuhhnrhhosehgmhgrihhlrdgtohhmpdhrtghpthhtoheprghnughrvghssegrnhgrrhgriigvlhdruggvpdhrtghpthhtohepphhgsegsohifthdrihgvpdhrtghpthhtohepsgihrghvuhiikedusehgmhgrihhlrdgtohhmpdhrtghpthhtoheprhhosggvrhhtmhhhrggrshesghhmrghilhdrtghomhdprhgtphhtthhopehmvghlrghnihgvp hhlrghgvghmrghnsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepghhkohhkohhlrghtohhssehprhhothhonhhmrghilhdrtghomh List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/28/25 23:50, Thomas Munro wrote: > On Fri, Aug 29, 2025 at 7:52 AM Andres Freund wrote: >> On 2025-08-28 19:08:40 +0200, Tomas Vondra wrote: >>> From the 2x regression (compared to master) it might seem like that, but >>> even with the increased distance it's still slower than master (by 25%). So >>> maybe the "error" is to use AIO in these cases, instead of just switching to >>> I/O done by the backend. >> >> If it's slower at a higher distance, we're missing something. > > Enough io_workers? What kind of I/O concurrency does it want? Does > wait_event show any backends doing synchronous IO? How many does [1] > want to run for that test workload and does it help? > I'm not sure how to determine what concurrency it "wants". All I know is that for "warm" runs [1], the basic index prefetch patch uses distance ~2.0 on average, and is ~2x slower than master. And with the patches the distance is ~270, and it's 30% slower than master. (IIRC there's about 30% misses, so 270 is fairly high. Can't check now, the machine is running other tests.) Not sure about wait events, but I don't think any backends are doing sychnronous I/O. There's only that one query running, and it's using AIO (except for the index, which is still read synchronously). Likewise, I don't think there's insufficient number of workers. I've tried with 3 and 12 workers, and there's virtually no difference between those. IIRC when watching "top", I've never seen more than 1 or maybe 2 workers active (using CPU). [1] https://www.postgresql.org/message-id/attachment/180630/ryzen-warm.pdf [2] https://www.postgresql.org/message-id/293a4735-79a4-499c-9a36-870ee9286281%40vondra.me > FWIW there's a very simple canned latency test in a SQL function in > the first message in that thread (0005-XXX-read_buffer_loop.patch), > just on the off-chance that it's useful as a starting point for other > ideas. There I was interested in IPC overheads, latch collapsing and > other effects, so I was deliberately stalling on/evicting a single > block repeatedly without any readahead distance, so I wasn't letting > the stream "hide" IPC overheads. > > [1] https://www.postgresql.org/message-id/flat/CA%2BhUKG%2Bm4xV0LMoH2c%3DoRAdEXuCnh%2BtGBTWa7uFeFMGgTLAw%2BQ%40mail.gmail.com Interesting, I'll give it a try tomorrow. Do you recall if the results were roughly in line with results of my signal IPC test? regards -- Tomas Vondra