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 1rdYFS-006BAC-3N for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Feb 2024 16:18:06 +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 1rdYFQ-002BHs-CS for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Feb 2024 16:18: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 1rdYFQ-002BHk-3D for pgsql-hackers@lists.postgresql.org; Fri, 23 Feb 2024 16:18:04 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rdYFN-000Xtq-0w for pgsql-hackers@postgresql.org; Fri, 23 Feb 2024 16:18:03 +0000 Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-36576cf5fe0so2625825ab.0 for ; Fri, 23 Feb 2024 08:18:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708705079; x=1709309879; 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=PqrIgL+dh04iwajkV7JRHODCKwjLaCONfA97DcaNGXs=; b=I48MnEtI25DwNmoTj/ZCWOMprq7eO4y4obKxBIzJTcCTsgPKEF+PLJtL4KLCNhDHVn WSoIkysuKC8LtsGFwGKBPWMktA4iLRGolAwp+PO9VRs5cxFpnn5Vy00HE37M2zKLTmq/ GalXq0XBtItdAW3NBsVVbpaOPC8hP9mrFhudaLBLu93LhsPz+9MZ60ZcYfXnnUvzrWel k0zjKTXiQNu8Iv0EZTnlXQhn0QwQW0dTaLc3o7xbaiDm5jL9qAIPNQvKRrrhzcKrA8mw 9iVh9IDm6tofshjm8iqQU8sOnVDO2FKHJ4JbbbaFFyC4+PzmkrIOHURksSFNDmAQyrlJ AG8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708705079; x=1709309879; 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=PqrIgL+dh04iwajkV7JRHODCKwjLaCONfA97DcaNGXs=; b=n09PH1RkJjnT7ONaQZRUdxWBI3eluoOV4OKn1hLbekVU8JVvy6488tcIr+EbYT+1J7 ILj5kJj+CjnwILqIy1YcMKsJ5w/8K0iZPcR/ul/HJJOAx7zmrAy6XTjMFEvNGQRQ0Igk fWc4ls8Gx8sK731pM0rM1KJdkiekkU9DwYqlSLIMPgR+LFeSm3bvQB1VqfsXQJwXI+Am K9gfDNrse/14z8Zb7XyRSp4rTUAEUUScm5ZqvzsrJfA3EJNlf1hoqh+s2rqTksaFPJLE 1oJei2ftsPvow0nfk3Dy4HqVODpg5vo/HQmxQO2XpWb2AdB4OlFpfnXzcr26Uj4tHtky /2DA== X-Forwarded-Encrypted: i=1; AJvYcCVLtzcFbDB6Vcehp79+A6rVBysXd+7XkakzTd9smvgg5x3YkKfiEwWZMuhsoC8s0TB101YA5rMfJ3Gn+84DbN5ywoNjeDKrB96dAak0 X-Gm-Message-State: AOJu0YwbfVO9DcNZchdWglnBBE/zHQjxD+IRpk9ZqZYzSUQX4k8icvFP N7DYEQD4MGwATz7oPXfjRUpmgqB5EN2V2/0FpgbDLUL1nN6I3fyY X-Google-Smtp-Source: AGHT+IHp9KqbI/GyLFagu6I+PTvQGM9jhNSAVbqFde62KXyp2bD4aC8ElbG6q2njir4brMMpptEfEA== X-Received: by 2002:a92:c092:0:b0:363:e573:da77 with SMTP id h18-20020a92c092000000b00363e573da77mr383671ile.18.1708705079563; Fri, 23 Feb 2024 08:17:59 -0800 (PST) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id c9-20020a92c8c9000000b003606b6d1070sm4590713ilq.22.2024.02.23.08.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 08:17:59 -0800 (PST) Date: Fri, 23 Feb 2024 10:17:58 -0600 From: Nathan Bossart To: Jeff Davis Cc: Bharath Rupireddy , Andres Freund , pgsql-hackers@postgresql.org Subject: Re: locked reads for atomics Message-ID: <20240223161758.GA1697194@nathanxps13> References: <20231110205128.GB1315705@nathanxps13> <20231110231150.fjm77gup2i7xu6hc@alap3.anarazel.de> <20231111023813.GB1408159@nathanxps13> <20231111024839.op2d2id33x777mll@alap3.anarazel.de> <20231111025529.GA1409540@nathanxps13> <20231127210030.GA140335@nathanxps13> 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 On Thu, Feb 22, 2024 at 11:53:50AM -0800, Jeff Davis wrote: > On Thu, 2024-02-22 at 12:58 +0530, Bharath Rupireddy wrote: >> There's some immediate use for reads/writes with barrier semantics - > > Is this mainly a convenience for safety/readability? Or is it faster in > some cases than doing an atomic access with separate memory barriers? The former. Besides the 0002 patch tracked here, there's at least one other patch [0] that could probably use these new functions. The idea is to provide an easy way to remove spinlocks, etc. and use atomics for less performance-sensitive stuff. The implementations are intended to be relatively inexpensive and might continue to improve in the future, but the functions are primarily meant to help reason about correctness. I don't mind prioritizing these patches, especially since there now seems to be multiple patches waiting on it. IIRC I was worried about not having enough support for this change, but I might now have it. [0] https://commitfest.postgresql.org/47/4330/ -- Nathan Bossart Amazon Web Services: https://aws.amazon.com