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 1r8u2p-00CSHn-22 for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Dec 2023 03:18:23 +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 1r8u2n-004o09-Kh for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Dec 2023 03:18:21 +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 1r8u2n-004nzG-B9 for pgsql-hackers@lists.postgresql.org; Fri, 01 Dec 2023 03:18:21 +0000 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r8u2k-008Ctz-Kn for pgsql-hackers@postgresql.org; Fri, 01 Dec 2023 03:18:20 +0000 Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-7b3870ee4easo50261939f.3 for ; Thu, 30 Nov 2023 19:18:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701400698; x=1702005498; 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=PQYPkIA3O0Nrut2q+LQ2MWZWB4SCwgVeBPtuUlt0XxU=; b=R9SS4fusGNaWl2tBu2jzl7/ArFYuV4/4+uMdUS7jvqV3fcfRTQttK+1loTy6lMKH7Z H7qrxcg2QthuZTqYndZyTkHwtsg2YC5AxeU9uiX8gT0NgwHAr2Pq9C62lWj07UQ7dOra pgnZduDdGjZCZqaf4RumAO0yp8pW7bFIqKWvxV4Azb+HkWIbMpKGLcmiBwyp0QzxuF+V fIvH5zN7HkARK4C4pqkaDk3wEwfNOeZ3YX4uESQ0QLfEYAOqcBNhpdMXOI0XqAOp7TfC 1qB/eXGPzBJPMKaf92JD7FDDrl7U3qLnyA6OyrpXqyOcTF8zv0+qqyRVsXxhCmnacnuk 82Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701400698; x=1702005498; 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=PQYPkIA3O0Nrut2q+LQ2MWZWB4SCwgVeBPtuUlt0XxU=; b=brSVpxH7kdeTfc4tZozn68PMfMnyPBBKnIVSBFB4ctSM/VZJ/0YRjswv7vAAws8SaB aZjoakHEMbSor3QGSbd44wdQ1vvnk6m+peyzCYU1azgrYi01u5RMogzwd7A9q1d/BSII q+EWJ3ykXO6DOWnyOFOi9IQvoOUgEfrr4hjOpkUo4XROdF0NoBw3oWMxAOtXO4WCJBo7 HsBFE4RoWyS2xT/3i7LPbKlRp9K25lg2uenfsU38PaW0gGE1T3aTrjof/5xInUfKVP7A N5um6gKmPT1Tac0JJsCtSXSLh0fHZawgqDR9uE5SAmOGTd51In1SWH/4LwWfnffJj/CY J5KQ== X-Gm-Message-State: AOJu0YzNd+18EKPUaz41GxekifNbbY6G/0AA9ItUYH+kviNSNXttCv/y PPGd7OK2rz++YGC1S8vt91vJzIkwEs4= X-Google-Smtp-Source: AGHT+IEhF8quO96YXHjQBvy01sxaM68QJAvTzjBhJvumlI8zeYyZhyO4U9UcqvWfRTu/tkURh9hx8w== X-Received: by 2002:a92:cb91:0:b0:35d:1212:5c3 with SMTP id z17-20020a92cb91000000b0035d121205c3mr10485293ilo.3.1701400697767; Thu, 30 Nov 2023 19:18:17 -0800 (PST) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id b2-20020a02c982000000b00463ff175405sm646030jap.80.2023.11.30.19.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 19:18:17 -0800 (PST) Date: Thu, 30 Nov 2023 21:18:15 -0600 From: Nathan Bossart To: Andres Freund Cc: pgsql-hackers@postgresql.org Subject: Re: optimize atomic exchanges Message-ID: <20231201031815.GA1519459@nathanxps13> References: <20231129212905.GA1258737@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231129212905.GA1258737@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Nov 29, 2023 at 03:29:05PM -0600, Nathan Bossart wrote: > I haven't done any sort of performance testing on this yet. Some > preliminary web searches suggest that there is unlikely to be much > difference between cmpxchg and xchg, but presumably there's some difference > between xchg and doing cmpxchg in a while loop (as is done in > atomics/generic.h today). I'll report back once I've had a chance to do > some testing... Some rudimentary tests show a >40% speedup with this patch on x86_64. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com