From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id eHTLCyMLP2Kq+QAAgWs5BA (envelope-from ) for ; Sat, 26 Mar 2022 13:46:27 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id MCoVCSMLP2IHTgAA9RJhRA (envelope-from ) for ; Sat, 26 Mar 2022 13:46:27 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B498316EAB for ; Sat, 26 Mar 2022 13:46:26 +0100 (CET) Received: from localhost ([::1]:38252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY5oH-0004ec-To for larch@yhetil.org; Sat, 26 Mar 2022 08:46:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY5ml-0004bT-C5 for guix-devel@gnu.org; Sat, 26 Mar 2022 08:44:51 -0400 Received: from [2a02:1800:120:4::f00:15] (port=38536 helo=andre.telenet-ops.be) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY5mj-0006S0-9E for guix-devel@gnu.org; Sat, 26 Mar 2022 08:44:50 -0400 Received: from [172.20.10.9] ([213.119.160.242]) by andre.telenet-ops.be with bizsmtp id B0kl2700H5E5NyV010kmVZ; Sat, 26 Mar 2022 13:44:46 +0100 Message-ID: <0678da36c885da1619164663b4ccf2eaa8226944.camel@telenet.be> Subject: Re: The Shepherd on Fibers From: Maxime Devos To: Ludovic =?ISO-8859-1?Q?Court=E8s?= , guix-devel@gnu.org Date: Sat, 26 Mar 2022 13:44:40 +0100 In-Reply-To: <87ee2sfg9d.fsf@inria.fr> References: <87ee2sfg9d.fsf@inria.fr> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-SIVXGWG03fTx70yR0Ae6" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1648298686; bh=/Z4j6QOlwqoOmwJj49925x4hdCsFNsAL9gwUlWBsz8o=; h=Subject:From:To:Date:In-Reply-To:References; b=L5k2/edkWTZe3GVOgx55qt2ZxE7eivpCbso4VNk3xx4erjAdNH/fT7ZjosHEc+A1k oje4nzg9WttA/f/QlB4ocCPqVQ09rhFKdU270Ee5mDbq/ysRfyBr9IuGZ9v91VH4FZ xolqjCU/UcDlw3KxXg3qpiBKzHOFoaAb9oMDstOigEh87fk0bbXaUhByrXCGgoTKPF p6Am8EnOrDBJTPFJElZLD0Opby2O2WUPXZc7JY1fJa2zeBdROsQvYUY2YOqEZmHPOV DvqqQJyaClyGXpHf8mfkJh4QoJ9UrLm6JZpD5Ty8Hs+yySymKMudXs8B5s6F2e6+pV 222lWaUmB9sTg== X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a02:1800:120:4::f00:15 (failed) Received-SPF: pass client-ip=2a02:1800:120:4::f00:15; envelope-from=maximedevos@telenet.be; helo=andre.telenet-ops.be X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1648298786; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=/Z4j6QOlwqoOmwJj49925x4hdCsFNsAL9gwUlWBsz8o=; b=LDazzS5dhTBfpB+Rb9s95Q8QnIosnxJiv124EZuMpq0YZ9asQgVR0fb6tviicVXUXNSSpy 08oGT6ov3FOZ7Z0E5TYH1x6dmbXQd8M+8CznNk4csGizI7WWzUmSQVRKXC8p78ga/VqdA3 EtdCdI3OO50v82pOiHsf5XmEmRMOlu4pFzzm+ViKhM/9gr7p7/DrFNQPB7uQi7XHbO2CMN p+AcVklu/AICNwCvzDsTc/Hjl6ti3UMqBU6jyElanY3uY4+fecadL4A1amfXosUYMV9gR5 KBFM6TU8ANh0BVZ8fq87YTD5mK10IDzNM84Y3jwb9Cd8wk5X9YfGNTewxO3M9A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1648298786; a=rsa-sha256; cv=none; b=C8yNMc3X05ZNkhiL5xV5jhdCZVIDTrs0KtCyQpNQqxl/zLAAQkxcRR4pWhxju96F5U2JJ1 TT6Z8uRjhoz7Rv08xjdZjqtgKJl5+vhnTr/Zr1tCuycz+JLihzwHi2pTU4EsphZ4KshpcJ cRE4tuu59JPA4DZigStAn6gTxMoILtpJ7oqBOv/n+fmknfU5kU9KxZ5LK4YRirTUz6+Yin 7oRP0ycrf9u9EQws6HxjiueEGMe5K5l3Oju/u7eFTwbiM1TWHUMtkZCRxKdrtlQleA78YQ yXjKO2pwwzT09JyetzLPfuO8Fmo5mfq2xvRfEp1o8jD/r21OSyEop8XykT1uGQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=telenet.be header.s=r22 header.b="L5k2/edk"; dmarc=pass (policy=none) header.from=telenet.be; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -6.28 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=telenet.be header.s=r22 header.b="L5k2/edk"; dmarc=pass (policy=none) header.from=telenet.be; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: B498316EAB X-Spam-Score: -6.28 X-Migadu-Scanner: scn1.migadu.com X-TUID: R1LzFC9rfstq --=-SIVXGWG03fTx70yR0Ae6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s schreef op wo 23-03-2022 om 23:36 [+0100]: Thoughts? =46rom service.scm: > + (define (sleep* n) > + ;; In general we want to use (@ (fibers) sleep) to yield to the sche= duler. > + ;; However, this code might be non-suspendable--e.g., if the user ca= lls > + ;; the 'start' method right from their config file, which is loaded = with > + ;; 'primitive-load', which is a continuation barrier. Thus, this va= riant > + ;; checks whether it can suspend and picks the right 'sleep'. > + (if (yield-current-task) > + (begin > + (set! sleep* (@ (fibers) sleep)) > + (sleep n)) > + (begin > + (set! sleep* (@ (guile) sleep)) > + ((@ (guile) sleep) n)))) Instead of working around this limitation of Fiber's 'sleep', why not modify Fiber's sleep to detect if it is from a suspendable context or not, and depending on that, use Guile's sleep/usleep or the perform-operation+sleep-operation? Additionally, the set! can be avoided here in favour of a loop variable: (define start ...) (define (sleep n) ;; In general [...] (if (yield-current-task) (begin ((@ (fibers) sleep) n) ((@ (fibers) sleep) n)) (begin ((@ (guile) sleep) n) ((@ (guile) sleep) n)))) (let loop ((sleep sleep)) (define (try-again) ... =20 (loop (sleep 1))) (catch ...)) FWIW, the delay can be decreased here, if Guile's sleep is replaced by an appropriate use of 'usleep'. Greetings, Maxime. --=-SIVXGWG03fTx70yR0Ae6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYj8KuBccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7pR5AP9P9NWVrhvBp8ShfQuqzC3HY6Lk RkTBA5p6fehe7tsY1gEA4VPjSJaBo6nPcMVT2ARgvQIgq5U6oQYeGDKnz9o1Fws= =qa0u -----END PGP SIGNATURE----- --=-SIVXGWG03fTx70yR0Ae6--