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 1r8vFW-00CbnK-Cn for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Dec 2023 04:35:34 +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 1r8vFU-005Cx3-46 for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Dec 2023 04:35:32 +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 1r8vFT-005CwV-QZ for pgsql-hackers@lists.postgresql.org; Fri, 01 Dec 2023 04:35:31 +0000 Received: from mail-il1-x134.google.com ([2607:f8b0:4864:20::134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r8vFM-008DMH-V4 for pgsql-hackers@postgresql.org; Fri, 01 Dec 2023 04:35:30 +0000 Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-35ca9a9719cso5321595ab.1 for ; Thu, 30 Nov 2023 20:35:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701405324; x=1702010124; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=smlsbxd1Ql/0Gu3Lr4rvVS+3xeC1QXVZuopy3KC3aR8=; b=IP7L7KhPTAfGRWcLbA0FkRba7OcVd1Es8etHUJUAugVC5BeWVS90tABzf3VG8/rzjp DDVAppR7VPgAzx3M7JV/j9JhuN7F6Z200gB9T6u0hNLhpqQk4RxhkPYtCFkEOb/psCN3 +im6StKeeDRySkuIqVR/KECAaEPwjMWISfOj5y+Gya/KNMCUvIp7hIhI8XjCvXD2h2HT 5Hzlq2bDv8ESzXIifInQzrDCHnmexrJsIhWbss8JKujfZ7ij08GoeskmktpI3RcR4xAM w0yFB3wqvNVgyAT0buDbjvjHax0S182ZDVHup4Txpeyi5Ux1gMHnQcHN9QDtb0YOVjnv ZEQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701405324; x=1702010124; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=smlsbxd1Ql/0Gu3Lr4rvVS+3xeC1QXVZuopy3KC3aR8=; b=Igc7wc5h2L5H48q5+pnnvYh0Nn7HxL5yeD/ZS9SAES0xEPQXwLgmnnOGzbQWsyCIPB sHB/F8mZpAdoywmKQbcdpN6D+XitatuOF7Sdr6/zOr5q4Q9Kut6gpgDVdBnmzdHN1cgr AjoxHs6PZv4phh5fpiVrgsy78c19QeoBaPevvp/pZ8Eq8VuTxaZkTvK/iAy7CcLOp0Cf CwQaD0ruUCgcEEvVJMvZf8JoROqMz/VxNUj2J1JDJkV8SVuYnG/O6l15eKgywxsZcs7J nf/JgEgoCUQPRT+4rJ7mrKqRESF4J/40xCQRMAqpyskdkjQmbd9Nk0bZdbLHLEGVck4J vwQQ== X-Gm-Message-State: AOJu0Ywyb4j4yyCBba0usuj4TWN/B5bb7BtYH+BS00naGkNhLJZN4sQX czPqqdKaybq3FOqm1poMspZA1JbsX18= X-Google-Smtp-Source: AGHT+IHXVrbnaQzuoREaSP+wBMLrsP2QydgzeBop+1/1e0nig0/zl/Bwq1pXS3zv2IV0wJzDDIQWFQ== X-Received: by 2002:a05:6e02:152b:b0:35a:d654:5158 with SMTP id i11-20020a056e02152b00b0035ad6545158mr28931127ilu.30.1701405324235; Thu, 30 Nov 2023 20:35:24 -0800 (PST) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id r10-20020a92cd8a000000b0035b0b05189bsm823523ilb.38.2023.11.30.20.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 20:35:23 -0800 (PST) Date: Thu, 30 Nov 2023 22:35:22 -0600 From: Nathan Bossart To: Andres Freund Cc: pgsql-hackers@postgresql.org Subject: Re: optimize atomic exchanges Message-ID: <20231201043522.GB1577008@nathanxps13> References: <20231129212905.GA1258737@nathanxps13> <20231201031815.GA1519459@nathanxps13> <20231201035627.7xke2qvec6p5lihy@awork3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231201035627.7xke2qvec6p5lihy@awork3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Nov 30, 2023 at 07:56:27PM -0800, Andres Freund wrote: > On 2023-11-30 21:18:15 -0600, Nathan Bossart wrote: >> Some rudimentary tests show a >40% speedup with this patch on x86_64. > > On bigger machines, with contention, the wins are likely much higher. I see > two orders of magnitude higher throughput in a test program that I had around, > on a two socket cascade lake machine. Of course it's also much less > powerfull... Nice. Thanks for trying it out. One thing on my mind is whether we should bother with the inline assembly versions. It looks like gcc has had __atomic since 4.7.0 (2012), so I'm not sure we gain much from them. OTOH they are pretty simple and seem unlikely to cause too much trouble. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com