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 1urnds-00Ce7H-J9 for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Aug 2025 01:11:02 +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 1urndl-005geD-VO for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Aug 2025 01:10:54 +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 1urndk-005ge3-VS for pgsql-hackers@lists.postgresql.org; Fri, 29 Aug 2025 01:10:54 +0000 Received: from fhigh-b1-smtp.messagingengine.com ([202.12.124.152]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1urndj-002HMV-0A for pgsql-hackers@lists.postgresql.org; Fri, 29 Aug 2025 01:10:52 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 46E987A017E; Thu, 28 Aug 2025 21:10:50 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Thu, 28 Aug 2025 21:10:50 -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=fm1; t=1756429850; x=1756516250; bh=LQs5jQ4deuvTmN4ucL5AhAgAhIJ2rfM2l+5tp3QAkVM=; b= HjKTwYWInbpWfyzmluaWrpqfCqUZ6gktzerjz8NuK47KJKprp4EZurz5LAXUQP4l jLmlSotJc92P4jrXk7j8XAa+s/CWe0hkOXB4obGYJyZRtx84/+H4Jz8HSs/NR8Uo lPRnDEQbGKNNKGHt5XpTOvo7KmSdx4Z+ijFCerRYSxz7iTWB9tkJqF9klX/TE8AS xn4nb1J7Q4O97aHXA1zOVA8Py9lOPi5htpPxHKtw5zcqVHTrAv4EeD4LEC8F7StP 9dC+lWZqen+U0WYSMJqeFsik90u0b0Tq3ORnYF5EO6J6jB/4KKV8Q/1Lh42J7AYZ qnH4Yw4zWr2VKDN3N5eScg== 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=fm1; t=1756429850; x= 1756516250; bh=LQs5jQ4deuvTmN4ucL5AhAgAhIJ2rfM2l+5tp3QAkVM=; b=l zdG17jd6XQXG0op27Qff11hdeq/Pdd6mMju/YvtB5e/66HiPCvsKL06QqnlLyUKz +Hci3WCSXonWe61Fbquvj2RtWe6N32O9tPjnr+DdR7aGPTRoYvucu57MUxdhlj08 gu1gI5ZqRc1DEca6x24Nje9r0MMokAqdAE5arr0rT8n1Yheq6pgOpZNuoA67L8FQ +Ipw/rjOXf9lERTfOxmTHjz3kaAPGjSgi+x07KiM+t4mmR3IaKH7Z/g3a49IKbQV wCDD6XLHqnXdB+3n7ypecov03nYRLtz2gkOg+OmE4bgwYMH64seq40fMlGwsmWkt 5zQpiq5mi8zFrkQYMf3Ow== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddukedvheefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggugfgjsehtkefstddttdejnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpeelgeeufeduveeguedujeetueettdelgedvheekffehheffudeugeehvedu hfekjeenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhpohhsthhgrhgvshhqlhdroh hrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegr nhgurhgvshesrghnrghrrgiivghlrdguvgdpnhgspghrtghpthhtohepuddtpdhmohguvg epshhmthhpohhuthdprhgtphhtthhopehpghessghofihtrdhivgdprhgtphhtthhopehk nhhiiihhnhhikhesghgrrhhrvghtrdhruhdprhgtphhtthhopegshigrvhhuiiekudesgh hmrghilhdrtghomhdprhgtphhtthhopeguihhlihhpsggrlhgruhhtsehgmhgrihhlrdgt ohhmpdhrtghpthhtohepmhgvlhgrnhhivghplhgrghgvmhgrnhesghhmrghilhdrtghomh dprhgtphhtthhopehrohgsvghrthhmhhgrrghssehgmhgrihhlrdgtohhmpdhrtghpthht ohepthhhohhmrghsrdhmuhhnrhhosehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgsh hqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghp thhtohepghhkohhkohhlrghtohhssehprhhothhonhhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 28 Aug 2025 21:10:49 -0400 (EDT) Date: Thu, 28 Aug 2025 21:10:48 -0400 From: Andres Freund To: Peter Geoghegan Cc: Tomas Vondra , Thomas Munro , Nazir Bilal Yavuz , Robert Haas , Melanie Plageman , PostgreSQL Hackers , Georgios , Konstantin Knizhnik , Dilip Kumar Subject: Re: index prefetching Message-ID: References: <0dd33755-cab8-49c8-b1ed-698732577fbb@vondra.me> <1c9302da-c834-4773-a527-1c1a7029c5a3@vondra.me> <6d59c277-c440-4d1f-a46e-157958c06a5f@vondra.me> <5pltwb73d7cynsxo2yb54ygjk7haviatkrx43mnzihc6kkield@ahnstpgof46i> <931afce3-8c86-4c96-9861-0ffa17c6560f@vondra.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2025-08-28 19:57:17 -0400, Peter Geoghegan wrote: > On Thu, Aug 28, 2025 at 7:52 PM Tomas Vondra wrote: > > Use this branch: > > > > https://github.com/tvondra/postgres/commits/index-prefetch-master/ > > > > and then Thomas' patch that increases the prefetch distance: > > > > > > https://www.postgresql.org/message-id/CA%2BhUKGL2PhFyDoqrHefqasOnaXhSg48t1phs3VM8BAdrZqKZkw%40mail.gmail.com > > > > (IIRC there's a trivial conflict in read_stream_reset.). > > I found it quite hard to apply Thomas' patch. There's actually 3 > patches, with 2 earlier patches needed for earlier in the thread. And, > there were significant merge conflicts to work around. Same. Tomas, could you share what you applied? > I'm not sure that Thomas'/your patch to ameliorate the problem on the > read stream side is essential here. Perhaps Andres can just take a > look at the test case + feature branch, without the extra patches. > That way he'll be able to see whatever the immediate problem is, which > might be all we need. It seems caused to a significant degree by waiting at low queue depths. If I comment out the stream->distance-- in read_stream_start_pending_read() the regression is reduced greatly. As far as I can tell, after that the process is CPU bound, i.e. IO waits don't play a role. I see a variety for increased CPU usage: 1) The private ref count infrastructure in bufmgr.c gets a bit slower once more buffers are pinned 2) signalling overhead to the worker - I think we are resetting the latch too eagerly, leading to unnecessarily many signals being sent to the IO worker. 3) same issue with the resowner tracking But there's some additional difference in performance I don't yet understand... Greetings, Andres Freund