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 1qoTAv-001NYb-Kt for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Oct 2023 18:34:18 +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 1qoTAs-00GZfk-Np for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Oct 2023 18:34:15 +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 1qoTAr-00GZfb-0k for pgsql-hackers@lists.postgresql.org; Thu, 05 Oct 2023 18:34:15 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qoTAj-000DOB-Ve for pgsql-hackers@postgresql.org; Thu, 05 Oct 2023 18:34:13 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 172865C03A9; Thu, 5 Oct 2023 14:34:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 05 Oct 2023 14:34:04 -0400 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:sender :subject:subject:to:to; s=fm2; t=1696530844; x=1696617244; bh=IE ArQWbNFGuGfonlTR1HVR5J4EN0GRny59hOXmuLD+w=; b=Sp7fGnbtdopsgwvqT2 oK97OYRMoHo67Bsf1/7iK3hP1u3bwrcgpnjBnsBuB/ZTXyCjh1o/lY6XzYn+c6wP 7cdM3BFFuPl3nP9wh+jvf5BRkkLBbRW9faGFEtZmbSdR4e2XHa4chAbc10uwOx8n qpWb/wLuLpRgGU0NsezPS3zBmmMjDdP8Fgv3jE/MTv0MJY/RW/30XFILGfnwOqEW iPRzBdtVnyPxf+MjUIsRGhNORiFGn2NhVY+MXADy2vHnLok94V9K8Qn8RqqtM/jI cO5uFe+cS/lr0OKc+BVFZTKOcCWHrW/FfPhlQQsRDI+v9djeMmkqDgtlK54BMcfr mi0A== 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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1696530844; x=1696617244; bh=IEArQWbNFGuGf onlTR1HVR5J4EN0GRny59hOXmuLD+w=; b=BcOVT/JK3uY/2BQmztbb6xg3PGGt9 P4vxEdx/ZpgL3JVIeV9J90g3CNTp+vHzHlMSDPdUqER8zDMgSkYd1J0lG5FovreS je1P2uTxcEFG4xwpc75JENS5HRIZ2YKTBCU77U9A11qy7wqZ1Ts/pQ4YcG2NBi/E ts4ZZCG4igxFngbQw+BNwInt55MSb1nBhPNhqDmXLGYfy+hArubOZOvLXkcA8XKY 5Gj0votYAm9jRE47pWa/b/cJYc7dOEDpJBVBkgWOgR3b0rdfIERUDPrRnzDo0Dlw GY0ukeG2Jvpmh6rpyq9KtPs41dEglNv285fQ3Z7ngGNVLMlX/jeM4ourQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrgeeggdduvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepvdfffeevhfetveffgeeiteefhfdtvdffjeevhfeuteegleduheetvedu ieettddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Oct 2023 14:34:03 -0400 (EDT) Date: Thu, 5 Oct 2023 11:34:00 -0700 From: Andres Freund To: Robert Haas Cc: Dilip Kumar , Heikki Linnakangas , pgsql-hackers Subject: Re: New WAL record to detect the checkpoint redo location Message-ID: <20231005183400.n5myso7vu6crd656@alap3.anarazel.de> References: <20230714151626.rhgae7taigk2xrq7@awork3.anarazel.de> 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 2023-10-02 10:42:37 -0400, Robert Haas wrote: > I was trying to think of a test case where XLogInsertRecord would be > exercised as heavily as possible, so I really wanted to generate a lot > of WAL while doing as little real work as possible. The best idea that > I had was to run pg_create_restore_point() in a loop. What I use for that is pg_logical_emit_message(). Something like SELECT count(*) FROM ( SELECT pg_logical_emit_message(false, '1', 'short'), generate_series(1, 10000) ); run via pgbench does seem to exercise that path nicely. > One possible conclusion is that the differences here aren't actually > big enough to get stressed about, but I don't want to jump to that > conclusion without investigating the competing hypothesis that this > isn't the right way to test this, and that some better test would show > clearer results. Suggestions? I saw some small differences in runtime running pgbench with the above query, with a single client. Comparing profiles showed a surprising degree of difference. That turns out to mostly a consequence of the fact that ReserveXLogInsertLocation() isn't inlined anymore, because there now are two callers of the function in XLogInsertRecord(). Unfortunately, I still see a small performance difference after that. To get the most reproducible numbers, I disable turbo boost, bound postgres to one cpu core, bound pgbench to another core. Over a few runs I quite reproducibly get ~319.323 tps with your patches applied (+ always inline), and ~324.674 with master. If I add an unlikely around if (rechdr->xl_rmid == RM_XLOG_ID), the performance does improve. But that "only" brings it up to 322.406. Not sure what the rest is. One thing that's notable, but not related to the patch, is that we waste a fair bit of cpu time below XLogInsertRecord() with divisions. I think they're all due to the use of UsableBytesInSegment in XLogBytePosToRecPtr/XLogBytePosToEndRecPtr. The multiplication of XLogSegNoOffsetToRecPtr() also shows. Greetings, Andres Freund