From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Philip McGrath" Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Add atomic-box-update! function to (ice-9 atomic) Date: Thu, 22 Jun 2023 17:42:47 -0400 Message-ID: <7289b28b-d9d5-450e-baea-a51ef9ce61c2@app.fastmail.com> References: <874jn0pxtz.fsf@trop.in> <47D08644-D34F-43C2-9B0C-24A790F3CEA7@abou-samra.fr> <87ttv01711.fsf@trop.in> <4c24e86e-2dcb-4d41-89c4-67814b6ef4f1@app.fastmail.com> <871qi3q37k.fsf@trop.in> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3577"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.9.0-alpha0-499-gf27bbf33e2-fm-20230619.001-gf27bbf33 Cc: guile-devel@gnu.org, "Andy Wingo" To: "Andrew Tropin" , "Jean Abou Samra" Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Jun 22 23:43:54 2023 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qCS5o-0000dP-Qm for guile-devel@m.gmane-mx.org; Thu, 22 Jun 2023 23:43:54 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qCS5Y-0002Ht-VZ; Thu, 22 Jun 2023 17:43:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCS5X-0002Hi-Ca for guile-devel@gnu.org; Thu, 22 Jun 2023 17:43:35 -0400 Original-Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCS5V-00069b-EW for guile-devel@gnu.org; Thu, 22 Jun 2023 17:43:35 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 3A633320077A; Thu, 22 Jun 2023 17:43:31 -0400 (EDT) Original-Received: from imap52 ([10.202.2.102]) by compute1.internal (MEProxy); Thu, 22 Jun 2023 17:43:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= philipmcgrath.com; 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= 1687470210; x=1687556610; bh=hR9VuDIwXbFpm0NozgrG5N65+gNRoHMZk8z N9JmBMbc=; b=EQEIJq4gCpqVnjTrcj0W30Idk/qNjO5ng1E6uqsKQ24vw0eoAhw gvgmddtbY5SAUt8Ey5MGTzSVEB9yKi0uaWskUqAB+Oc3dLFFBOgR+CieBEDw+swU FWhgAT6RabHORlS1fRO/l1gf8ldBt8SJxS8XjUWPOFWJlS5OgBCW1Je70dpiGteq YLh2m96KxBDwmHfmdlDGaqmpGF+dKKgZvnpZJddYDaW29An2j4dl81qYDpWt3jGd co/tzPlakNUvogueMvXriAY7p7Xfan7W2w5LfYItVUqnWkipa1IFM4GN191dTSY5 smaPi9oXVgmTDv17eDi6eb9p2+SahwtHpew== 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=1687470210; x=1687556610; bh=hR9VuDIwXbFpm 0NozgrG5N65+gNRoHMZk8zN9JmBMbc=; b=fweGQdhKJpmVcAFAnE2c7OGOZexaJ o2VgOLop8gkIfIfHxDvQzDhELdjmATbQ34GzSM6OLpMxfXwkGgfpr4FiR6i3oqiE z8c7ZUPB0SfVrFZkxqHdpzKD7qkqTRDJu/joq1HysOnyO6QqVB96PYHAv+ApDI01 LlKmJR/MpYTVqsf7lheI2bM+tiL38e41Rcdib3A2XnTk8L3ebb5n9V32bWJXpLrL svHiT2skk1MPPuqhK+ngaGIiOr+1lDAarswRmQXOyEAM7JeE2xn9TlFUHF3R6NBA P/h3yhP07Gu4O/cSNBFp9JT5RJVhWH8UvHvqzwhLg3OFC46kH+D/vnxPw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeeguddgudeigecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdfr hhhilhhiphcuofgtifhrrghthhdfuceophhhihhlihhpsehphhhilhhiphhmtghgrhgrth hhrdgtohhmqeenucggtffrrghtthgvrhhnpedvjedvteefgefhjeeludeiveelkeefhfet heejveekteffvddtvdeivdeggefhfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehphhhilhhiphesphhhihhlihhpmhgtghhrrghthhdrtgho mh X-ME-Proxy: Feedback-ID: i2b1146f3:Fastmail Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 3D598C60093; Thu, 22 Jun 2023 17:43:30 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <871qi3q37k.fsf@trop.in> Received-SPF: pass client-ip=64.147.123.19; envelope-from=philip@philipmcgrath.com; helo=wout3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:21876 Archived-At: On Thu, Jun 22, 2023, at 5:02 AM, Andrew Tropin wrote: > On 2023-06-22 01:21, Philip McGrath wrote: >> >> In any case, the current documentation for >> atomic-box-compare-and-swap! is clear that the comparison is eq?: it >> just means that, when the behavior of eq? is unreliable, so is the >> behavior of atomic-box-compare-and-swap!. > > Good. Than implementation of atomic-box-update! looks correct to me. > Any thoughts on including it in (ice-9 atomic)? > >> >> Tangentially, does atomic-box-compare-and-swap! handle spurious >> failures on architectures like ARM, or does it expose machine >> semantics to the programmer? Maybe that's covered by details of the >> C11 memory model, but I don't think "sequential consistency" alone is >> enough to answer the question. >> I think your implementation is correct. If atomic-box-compare-and-swap! does not handle spurious failures, I think your implementation is still correct, but a more efficient implementation could retry without an extra call to the update procedure. Someone with a better sense of Guile performance might have a view about whether `apply` is likely to be expensive: alternatively, the update procedure could be restricted to a single argument, or `case-lambda` could provide a specialized entry-point. -Philip