From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 cLTEFsAnRGKKIwAAgWs5BA (envelope-from ) for ; Wed, 30 Mar 2022 11:49:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id wKZnE8AnRGKBDAEAauVa8A (envelope-from ) for ; Wed, 30 Mar 2022 11:49:52 +0200 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 0E65EC631 for ; Wed, 30 Mar 2022 11:49:52 +0200 (CEST) Received: from localhost ([::1]:49630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZUxa-00062t-U8 for larch@yhetil.org; Wed, 30 Mar 2022 05:49:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZUx3-00060u-KB for guix-devel@gnu.org; Wed, 30 Mar 2022 05:49:19 -0400 Received: from [2001:470:142:3::e] (port=58402 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZUx2-0003ej-1n; Wed, 30 Mar 2022 05:49:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=t9560tZS3dEP4ScIQqiRXMpWafpV2Ph8YLXo/LArw5g=; b=lskhPvv5AmCUD3jMYJ4t 2jYOULVcSRjkGjwCEjrAFBTwaibI4ho6q29U3dOmkUONTfMLh/YsrkiYO/C0amZDnNjxp68YQjmOz kp//FNGQSzNq9oFQRGBff2vZpyHF+mqetD+G4nNFJs1DdSMgYzKRIGlPaAGKVh43dnO27TRRcRqdH UAChp1zdWa0N3sNXK/1Du9fhbd5WTDtH4UYMpZ45r1zTTfdecrGOnyzdDYS9DOD9IViVkmT4tu7oj 6U3s45DRqddJeQTElhxHUDoqOicNUHeW6EwFV42RulM/ApnGTkdHHpBPOWm4KgfTcHXYrmxFFGblJ mevJShl4BzkLpg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:53565 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZUx0-000273-Cf; Wed, 30 Mar 2022 05:49:15 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Philip McGrath Subject: Re: The Shepherd on Fibers References: <87ee2sfg9d.fsf@inria.fr> <4f889372-3464-92df-b350-b7c61e081f31@philipmcgrath.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 10 Germinal an 230 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 30 Mar 2022 11:49:10 +0200 In-Reply-To: <4f889372-3464-92df-b350-b7c61e081f31@philipmcgrath.com> (Philip McGrath's message of "Mon, 28 Mar 2022 20:14:46 -0400") Message-ID: <877d8bwz1l.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: , Cc: guix-devel@gnu.org 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=1648633792; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=t9560tZS3dEP4ScIQqiRXMpWafpV2Ph8YLXo/LArw5g=; b=WebY95kA3FKld8HExWPoDHMjzhGh1XeGsAhW7vsZetVyU3V9vLA6PG1+VS6pyQe1iSdayp 4ASgnwsP6qqdJKNBUOWN9fTKN740NP8N337FN0QlioaITJ71pPRKgiJdYroFnfREjlYvFx jgtA/+tpZXrfqDNJaLg4tFPTVzfAn648+P9GakPDIsi1t8ndQOSWcS1GPBzToILSTSSvAM BanzG3NZmpCbRebo97B/S5RxJL/Le+fdjsKrXa7kjAo4teQwZDBSdymFi7/dAgCf42MI3N LO3VVFIxE4pVipw4n9HXckvsVWT/ZLgQGHOFg/q4sb8Ar/FXauBOCAy+JttVWQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1648633792; a=rsa-sha256; cv=none; b=csjr85USJfQxO3/xkxO7CfOAskS4P91v86HOEzLCZEfjAFtu0GUckPXemHvl0sGnYRfTor n1FAaVaDvgA3yXOO+S9AMzKFN0yMrA6S+HqdpjrnIB8J3bRXtOCsagOyDkmw1R4qS07O6Y hWQi+5dNr9Z/PJJwZjhxcpdggrTOhA4AjHxNGTZwou+Aor5KiBkwN5h3WlGj3ywInZhELQ a2cmmqe3yBN66uTuq99RR/NjCSj4BmoC4pG2/RRonmWshaaKgXaKJ8z0Thh84A3bukJ4Z2 4RrQSWJ3cbt+ajNlWpEGkCGmXiSG6BhB7YLjqa5MP8oVK+1oU8609xPIrlUmoA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=lskhPvv5; dmarc=pass (policy=none) header.from=gnu.org; 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: -5.27 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=lskhPvv5; dmarc=pass (policy=none) header.from=gnu.org; 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: 0E65EC631 X-Spam-Score: -5.27 X-Migadu-Scanner: scn1.migadu.com X-TUID: CgVsxP+5z2MK Hi! Philip McGrath skribis: >> Fibers is used in a single-threaded fashion, which is the main >> constraint for shepherd since it forks. That also means that fibers >> cannot be preempted, so it=E2=80=99s fully cooperative scheduling. >>=20 > > Would it be feasible for shepherd *not* to fork? Sure, but that would make it a daemon supervisor that doesn=E2=80=99t launc= h any daemon, which would make it less useful. :-) > Or only to fork in a way that cooperates with fibers? A process that has multiple POSIX threads cannot fork reliably; that=E2=80= =99s the core of the problem (it=E2=80=99s a problem of POSIX and =E2=80=98fork= =E2=80=99, not specific to Guile and Fibers). > Obviously forking is pretty ubiquitous, but I the 2019 paper "A fork() > in the road"[1] fairly convincing in its argument that Yes, I read it before. We could have bindings for =E2=80=98posix_spawn=E2= =80=99 but it=E2=80=99s kind of ugly and limited. > More concretely, preemption is a big benefit of fibers. I=E2=80=99m not arguing against preemption, I like it. :-) However, as currently implemented in Fibers, we cannot rely on it, though Maxime mentioned that it could use signals instead of a separate thread, which would work. We can always revisit that later. I making a first step here, and being cautious, but we can and should unleash our creativity once we have the basics in place. > Racket has a cross-platform C library, "rktio"[3], for accessing > os-specific functionality. It was refactored into its current form in=20 > 2017 as an early step toward Racket-on-Chez: while it happens to > provide exactly the functionality Racket needs, it no longer is > specific to Racket or any particular implementation thereof. That > includes everything needed to implement the Concurrent ML system and > nonblocking IO on a variety of OSes and kernels. > > In particular, it implements=E2=80=94IIUC primarily in > "rktio_process.c"=E2=80=94abstractions (over `fork` or alternatives) to s= tart > a new process running something, with environment, stdin, stdout, and=20 > stderror wired up ports in the sense of > `current-{input,output,error}-port`, and use the Concurrent ML system > to monitor its exit status, send it signals, etc. The Racket-level API > is documented at [4]. Interesting. I=E2=80=99m not sure this is directly translatable to Guile. However, libevent support for Fibers should address this specific point, so I=E2=80=99m not really concerned. > Second, I'm a little uneasy about `unwind-protect`: Your criticism is valid, though here it has a single user and it=E2=80=99s = =E2=80=9Cgood enough=E2=80=9D for that case I think. Thanks for your feedback! Ludo=E2=80=99.