From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrew Tropin Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Add atomic-box-update! function to (ice-9 atomic) Date: Thu, 13 Jul 2023 07:30:47 +0400 Message-ID: <878rbktrmg.fsf@trop.in> 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> <7289b28b-d9d5-450e-baea-a51ef9ce61c2@app.fastmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13768"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-devel@gnu.org, Andy Wingo To: Philip McGrath , Jean Abou Samra Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Jul 13 05:31:29 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 1qJn3B-0003Ob-Hp for guile-devel@m.gmane-mx.org; Thu, 13 Jul 2023 05:31:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJn2k-0000JT-FO; Wed, 12 Jul 2023 23:31:02 -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 1qJn2i-0000H0-PQ for guile-devel@gnu.org; Wed, 12 Jul 2023 23:31:00 -0400 Original-Received: from relay7-d.mail.gandi.net ([2001:4b98:dc4:8::227]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJn2g-0004a0-Qw for guile-devel@gnu.org; Wed, 12 Jul 2023 23:31:00 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 75B2820002; Thu, 13 Jul 2023 03:30:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1689219053; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gN3l3z2+jbhGdsSgqZFhY17Rwo4qhIPfAqzinlbnjOg=; b=lZuwOU9ffPr4jSsAnv0ecm59I4Y3xh3iaXz10GzNr0Q50EFGkDatcVpmsBfgE+5R6cN8eH mlu2MOPZ8AtGTAQd+xU/dwj6jJGMbaDeK1hy78M1swGTx/mnnHVsjLN+lV5AjdZxC2Y6og qikletVR/g0tOK5/YC+EoZgv8c2N17f8IOy74zQ4ufo1B1tS+ENkc4BMbIRn8gzzqsKAKN iku7SAxRvbCY5X7xknCDOHJSaSTCkxVUAxReFeUJQwFNkIVoP46ZkAUjNUi5IvpM2RBezz pXnSP/6bShdV0YU6mmQtWzrCnZCLhEo6HGTHPvMRyHJEDqQ6+aVVT4zKkSPk/Q== In-Reply-To: <7289b28b-d9d5-450e-baea-a51ef9ce61c2@app.fastmail.com> X-GND-Sasl: andrew@trop.in Received-SPF: pass client-ip=2001:4b98:dc4:8::227; envelope-from=andrew@trop.in; helo=relay7-d.mail.gandi.net 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, 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:21897 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On 2023-06-22 17:42, Philip McGrath wrote: > 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. How? If value was updated you need to recalculate new value. > > 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. Original implementation was a single argument, but I thought that variable number of arguments will be more convinient. =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmSvb+cACgkQIgjSCVjB 3rAMug/+ODjLQrKUlNuVt1iGJpCKgni1G9ecmKsWk5jAgWeANOOR/L4fLA7Eylzl VAoAy7o7w+IisjCpHbAOOmIU8jdqSoekeovdhSmmwFeGH75IDptziEw/4K1vMeI0 P97Z5DFSiQL0f012S/ua6iba9lzIbCAE/JCBI2Db701Jvd+Fhi02meIF1x4jFoGg pc7ZK+41KJecxqKiwgXo+xzNocDKkU2oRVzE9Xgra+2KoW2yyDvl5t9qAgOdJiwd zLy1WE9qfs40DA4QNbMmA+UAh7A3+fgI7neuMarrjZ49DfOFR4nk/FNwLVq0kvDD HmDfF3/u3p7MLSIGDYGalnsreVaswz3A7p+As0HBWFxX3h24DZnnhF+KLrgzgc4h ODNgIFC5DWq9TNZXJo8DJXkdU8gbKD6AKcgZ2cfuBfwrq6HL5UChuehRZIceuX+J HY5JeYKMFm1lRGSbdfYvKVu9XQIvqiAlOFX/DBkUH0WTouBgIn7DLxAJQ4a0SOyM x0EeEZqnvb9QfU5xYCB8tpXkWk/wxHJy+MepJKByJjXxeqYVp9n0GwTszEWuDPzr N67rLnNA7xsET3EMpi/Ox3ACa4ef2PmbbmSK6POk1kf1ew7Y+mKDUiuefFIiAs/f 6AZmepWNgpsv5NNdU5M91g/Jaof0L/wIO3yvy13a2vEYLJCnSOs= =aTS0 -----END PGP SIGNATURE----- --=-=-=--