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 1rZgP7-005r8L-Va for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Feb 2024 00:12:07 +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 1rZgP6-00EPhK-1O for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Feb 2024 00:12:04 +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 1rZgP4-00EPhC-4H for pgsql-hackers@lists.postgresql.org; Tue, 13 Feb 2024 00:12:03 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rZgOz-006tQO-Sr for pgsql-hackers@lists.postgresql.org; Tue, 13 Feb 2024 00:12:01 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 039FF3200A40; Mon, 12 Feb 2024 19:11:52 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 12 Feb 2024 19:11:53 -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=1707783112; x=1707869512; bh=0EVaUur5SL GHOku1U9b0KasOLwJ8c8UnepPCypVmfqU=; b=Xf7sF3ICVoXmHQzG4lbregxc6s puhsKvOGb35mYXTHaWAc5nxKic/GQOM4C9hidw74oVU1ROrjPlNvk07pmvGAi7+l 2lteljErl0yHVa1ZQE3xCdep9VJIGa1fiSC0q7bzwbenvvE+IQ/FgJLQe+USzL1n /V0F6/ktwxQXFywyhu54MJNUHJe+cUjK3Spa9mJaSxQJ769qLnves9FkZ+GBmeFA 5kEylXjQ2rZGTTdT7T4IpptQxKTVW89cNBHB19F1pVDkuDprBwZdniK9Dk5Kg+ZA BkbUzRz8LXJyZ0+L63IsEe+CT1kNi8ieQ+84xgIgVGF3Yislx8fCBNxeQn7Q== 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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1707783112; x=1707869512; bh=0EVaUur5SLGHOku1U9b0KasOLwJ8 c8UnepPCypVmfqU=; b=vz29Y1cXUZBoD6qP5DQ2Ho6xS+H9iMGtBZqt+DQugU5P D1aqNSxU4E65txOj8zKTv7PeGyZaixp6fPhkWhaY5iWLQ1NhIw29urbiwUkrz7Dh LqATcMTojueSV0H3uhZ6SvN/2Bn7AGFqr0yPLvEUIJBpLGtyDKEIldY00KinY1gO UDlSFJybAQjyNZR6ypEDN5ZMCno9JwPPrsEFzptI+8U3nqJUNsBi+rw+D/6V0JsJ Wno1L1ZiLN0BLSxktfYOGxFqbWE5/Z7sGwkyjcOzO2CFKWMc+JBLOuW0P9F67Zqo YJEadqeedh1662nc2Uad2G5FsFRDRJsI9jpQPZuzcw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudeggddvtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedvffefvefhteevffegieetfefhtddvffejvefhueetgeeludehteevudei tedtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Feb 2024 19:11:51 -0500 (EST) Date: Mon, 12 Feb 2024 16:11:50 -0800 From: Andres Freund To: Jeff Davis Cc: Bharath Rupireddy , Alvaro Herrera , Dilip Kumar , Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org, Nathan Bossart , Masahiko Sawada Subject: Re: Improve WALRead() to suck data directly from WAL buffers when possible Message-ID: <20240213001150.4uqzh7tinuhvoopl@awork3.anarazel.de> References: <202401301731.o3cthlcry4ve@alvherre.pgsql> 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 2024-02-12 15:56:19 -0800, Jeff Davis wrote: > On Mon, 2024-02-12 at 11:33 -0800, Jeff Davis wrote: > > For 0002 & 0003, I'd like more clarity on how they will actually be > > used by an extension. > > In patch 0002, I'm concerned about calling > WaitXLogInsertionsToFinish(). It loops through all the locks, but > doesn't have any early return path or advance any state. I doubt it'd be too bad - we call that at much much higher frequency during write heavy OLTP workloads (c.f. XLogFlush()). It can be a performance issue there, but only after increasing NUM_XLOGINSERT_LOCKS - before that the limited number of writers is the limit. Compared to that walsender shouldn't be a significant factor. However, I think it's a very bad idea to call WALReadFromBuffers() from WALReadFromBuffers(). This needs to be at the caller, not down in WALReadFromBuffers(). I don't see why we would want to weaken the error condition in WaitXLogInsertionsToFinish() - I suspect it'd not work correctly to wait for insertions that aren't yet in progress and it just seems like an API misuse. > So if it's repeatedly called with the same or similar values it seems like > it would be doing a lot of extra work. > > I'm not sure of the best fix. We could add something to LogwrtResult to > track a new LSN that represents the highest known point where all > inserters are finished (in other words, the latest return value of > WaitXLogInsertionsToFinish()). That seems invasive, though. FWIW, I think LogwrtResult is an anti-pattern, perhaps introduced due to misunderstanding how cache coherency works. It's not fundamentally faster to access non-shared memory. It'd make far more sense to allow lock-free access to the shared LogwrtResult and Greetings, Andres Freund