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 1tAuxX-000r7b-VY for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Nov 2024 17:45:47 +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 1tAuxT-008Z9j-RC for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Nov 2024 17:45:44 +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 1tAuxS-008Z9L-Qc for pgsql-hackers@lists.postgresql.org; Tue, 12 Nov 2024 17:45:44 +0000 Received: from fout-b8-smtp.messagingengine.com ([202.12.124.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tAuxP-001Zoc-0K for pgsql-hackers@postgresql.org; Tue, 12 Nov 2024 17:45:42 +0000 Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfout.stl.internal (Postfix) with ESMTP id 5D74211401CF; Tue, 12 Nov 2024 12:45:37 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Tue, 12 Nov 2024 12:45:37 -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=1731433537; x=1731519937; bh=h5pAFxzr4M N2tSn0Guo1T0kT2KhfYwkg13xUmR78qtw=; b=cawpbu6B8LFZAae7x4ocKnUY9A acNyAhUDZLqOe8HF0DeUOkPGNvBT9smlFB22/TVwHfd+YE0QcB5D1Ra17y6yB5A0 1hPw0DbyuKfmGVoW34D4uNT6yQ03rtTrQDtAAa+HBjlB2cV0HWVCRIggSnV+FrVF 2CwQ6ZHrEkiKmuBcR47wGNJBrCFx9WDtV7fT5p+3qs7xsGYu8xlI8Q1H3o/bB8bf J3kd2MfzyKpzpu8iHXXM/psc7PQ2Z2LhMkR/hI/VYdENcrF286Cv6+QHoghpkJ7+ JSdvAdL6fDrwN2i8YebJG1TazyktUPPg/jO2wA3vq9LnDetwQmYm1SdHNGJQ== 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-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1731433537; x=1731519937; bh=h5pAFxzr4MN2tSn0Guo1T0kT2KhfYwkg13x UmR78qtw=; b=oZ3ysa+s4sbGtjgUUHZO8OTfC/IgSdFj9KuAFHirDhe4Gq5EU09 0vgUErQRT7t/m4SEtZclLe1SmI/Zc5GjVAYZK6b4JpteaDW3WVGoJpswqAhxTgGW 199CgLGPPnP3CfwKRqT0oxxnNGLaaYD6EwvLbC7R/0Bne0qGZO4o/lOrbcbDA9pN 6yWOdi3QjptsB+vxyxTsCfhtAlhvsIx0QzUfnv6qmzLJWqVjfE7cZ07IZ8q7Vm9V 4D3+pF2wyeCejXdNce3njlswrLN+ZhPfV0VwrRMEmWTAu1tytlHjeiWLXR71E2xv FVi/nb+6rzGP0ojwFwP1Oosv/5nbsZR9tZA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudeggddutddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepfffhvfevuffkfhggtggujgesthdtsfdttddtvden ucfhrhhomheptehnughrvghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivg hlrdguvgeqnecuggftrfgrthhtvghrnhepfeffgfelvdffgedtveelgfdtgefghfdvkefg geetieevjeekteduleevjefhueegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgt phhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehhohhuiihjrdhfnh hsthesfhhujhhithhsuhdrtghomhdprhgtphhtthhopegrmhhithdrkhgrphhilhgrudei sehgmhgrihhlrdgtohhmpdhrtghpthhtohepshhhvhgvthgrrdhmrghlihhksehgmhgrih hlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghs qhhlrdhorhhgpdhrtghpthhtoheprghlvghkshgrnhguvghrsehtihhmvghstggrlhgvrd gtohhmpdhrtghpthhtohepthhomhgrshesvhhonhgurhgrrdhmvgdprhgtphhtthhopehj rghnseifiheftghkrdhinhhfoh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 12 Nov 2024 12:45:36 -0500 (EST) Date: Tue, 12 Nov 2024 12:45:35 -0500 From: Andres Freund To: Jan Wieck Cc: Amit Kapila , Tomas Vondra , "Zhijie Hou (Fujitsu)" , Aleksander Alekseev , pgsql-hackers , shveta malik Subject: Re: Commit Timestamp and LSN Inversion issue Message-ID: References: <11ee3489-40ba-45d6-ba6a-7c3def725e84@vondra.me> <00f7cfb2-e3a6-4bd7-b19c-fd75d3838049@wi3ck.info> <296b2c56-c688-41a0-a752-b242268691fd@wi3ck.info> <94fc0a8b-5d18-4a82-8082-b76a0e725788@wi3ck.info> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <94fc0a8b-5d18-4a82-8082-b76a0e725788@wi3ck.info> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2024-11-12 11:40:39 -0500, Jan Wieck wrote: > On 11/12/24 10:34, Andres Freund wrote: > > I have working code - pretty ugly at this state, but mostly needs a fair bit > > of elbow grease not divine inspiration... It's not a trivial change, but > > entirely doable. > > > > The short summary of how it works is that it uses a single 64bit atomic that > > is internally subdivided into a ringbuffer position in N high bits and an > > offset from a base LSN in the remaining bits. The insertion sequence is > > > > ... > > > > This leaves you with a single xadd to contended cacheline as the contention > > point (scales far better than cmpxchg and far far better than > > cmpxchg16b). There's a bit of contention for the ringbuffer[].oldpos being set > > and read, but it's only by two backends, not all of them. > > That sounds rather promising. > > Would it be reasonable to have both implementations available at least at > compile time, if not at runtime? No, not reasonably. > Is it possible that we need to do that anyway for some time or are those > atomic operations available on all supported CPU architectures? We have a fallback atomics implementation for the uncommon architectures without 64bit atomics. > In any case, thanks for the input. Looks like in the long run we need to > come up with a different way to solve the inversion problem. IMO there's absolutely no way the changes proposed in this thread so far should get merged. Greetings, Andres Freund