From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id UEehNRWhO2KCfwEAgWs5BA (envelope-from ) for ; Wed, 23 Mar 2022 23:37:09 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id yPgkMxWhO2LyIQAA9RJhRA (envelope-from ) for ; Wed, 23 Mar 2022 23:37:09 +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 36CD445BB1 for ; Wed, 23 Mar 2022 23:37:09 +0100 (CET) Received: from localhost ([::1]:36984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nX9bI-00040E-9U for larch@yhetil.org; Wed, 23 Mar 2022 18:37:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX9aj-0003zB-5I for guix-devel@gnu.org; Wed, 23 Mar 2022 18:36:33 -0400 Received: from [2001:470:142:3::e] (port=43726 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 1nX9ai-0007Re-Sn for guix-devel@gnu.org; Wed, 23 Mar 2022 18:36:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=6VCRVg2Aa2OWKsrJ0KFiJZeIizovvWcMO3wMUMBv/Ho=; b=EK2xYiQTuRoLAa /bThdhQSMSZ4cUVoql0kcNfDHZjiCZcaskTaAn4VdthHmsEm/lzOMgC0qFUKdDvcfNK2FVTLm5BXT ejhWUW0v0C8S5AzdchFTAQEVAAKq4nzrBp+t5GCtScsh0J2Xirb0edlyU5Hws9fYDWUANMfsItwKu F6N1f6dgplj6TZzlzUX2dH24hBqx4IbYa6dWKAlaXslo1538n2c3OD+KZgXHQVt3SdPDJmeKBG+f4 nu7IqA5XUAyATHTLIiiEtLKp9wtfnjeZseC1hQ5zehXHFGQ37ZDukspA/vnNeWMn7yr/uAxxtevZY arNi0JpIE7+SGn3G1YXQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:59323 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nX9ai-0007yN-GA for guix-devel@gnu.org; Wed, 23 Mar 2022 18:36:32 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: guix-devel@gnu.org Subject: The Shepherd on Fibers X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 3 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, 23 Mar 2022 23:36:30 +0100 Message-ID: <87ee2sfg9d.fsf@inria.fr> 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: , 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=1648075029; 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: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=6VCRVg2Aa2OWKsrJ0KFiJZeIizovvWcMO3wMUMBv/Ho=; b=RcIJxCzITPQr+JSOMoy0SShbzBWCme3aq7MswANp9HOYE322Pq+rzCkr9kgIzsD0wPlNem T9DmC2+tscPgfrSjror70zQx+7+lQtOV7bHgeloTD1WRhkgWArcON8ugGHvGhUNBoLZmRx dmQq+hhphcNNKVUCcA4qxDWJrlSz2DrtZaOqeHpSeV4ZloxY0EJlIcSUJV/43QP/Zlx014 aif8fozFee8wLt5YErTDEEy0Q9O36nytq62Zd9vxvi+XdXkZUsV69jkcIl7Dh+hB85w4OM nOwPY0yCdbD2BzFONTa50JCEmQQL0upyaVjxYRJ1EHtOloMUiCXExoBoI8Xaug== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1648075029; a=rsa-sha256; cv=none; b=jCve7BTnFSdF/vBZJOyPbrB2mUp6uwpK+jyzKpOp4yOqO587W5pOxqsXtc+XAS5g32vfmO pWc/F+3yGEyDhAP5dfeKvOxryCmT81MhyGBhj3dYJCngQvXirWcOM3eIAIDE6kAG6cAIv0 krEIWqSPRPbnVDjL70Od832DeddRXxHS12GEGxgcxITI6mABmJp0/p6l7qzeLiIKLUinlm Z+RmW++LnvOT09kkGagkAiY6hYhvTaboZLck7XiiYFiaLRKPCz5m061PGFHV/56c89fUo1 8bG4uCdoRU3bRURyf8Xp/S8sz400VKMCrFbjyZOVoHePzlFipGgS5RLlqVdtAw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=EK2xYiQT; 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.29 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=EK2xYiQT; 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: 36CD445BB1 X-Spam-Score: -5.29 X-Migadu-Scanner: scn1.migadu.com X-TUID: 8aA31m78QR4/ Hello Guix! I have pushed a =E2=80=98wip-fibers=E2=80=99 branch of the Shepherd: https://git.savannah.gnu.org/cgit/shepherd.git/log/?h=3Dwip-fibers The goal is to make shepherd (the daemon) use Fibers=C2=B9 for concurrency. Right now, actions in shepherd are all serialized: starting services, waiting for their PID files, accepting client connections and serving them (when running the =E2=80=98herd=E2=80=99 command), etc. This slows do= wn startup, prevents things like running two clients at the same time, or serving a client while waiting for a PID file. In other words, it sucks. Using Fibers, we can introduce concurrency with few changes to the code; we can even do new things writing code that looks sequential. This is what the branch does. To illustrate that, it introduces a new, incredible feature: logging! As you know, shepherd had (euphemism ahead) limited support for logging, essentially in the form of #:log-file, which would redirect a daemon=E2=80= =99s stdout/stderr to a file, and also in the form of =E2=80=9Clet=E2=80=99s hop= e the daemon talks to syslogd=E2=80=9D. Here I was able to trivially add logging, such = that anything spawned by =E2=80=98fork+exec-command=E2=80=99 is logged, with tim= estamps and all (the logger is a fiber that calls =E2=80=98read-line=E2=80=99 in a loop= , which is automagically non-blocking=E2=80=94delightful!). The next fun step (besides logging) will be adding inetd-style and/or systemd-style =E2=80=9Csocket activation=E2=80=9D. 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. There=E2=80=99s one catch: Fibers is currently Linux-only. The good news is that work has been done to port it to other kernels via libevent=C2=B2. Until it is merged, we could keep using the Shepherd 0.8 on GNU/Hurd. I=E2=80=99ve done some Guix System testing in VMs and didn=E2=80=99t notice= any major issues. I=E2=80=99d like to merge that branch in =E2=80=98master=E2=80=99 = and to eventually release it as 0.9.0 (with or without socket activation, we=E2=80=99ll see.) Hopefully, we could be running it within a couple of weeks. Thoughts? Ludo=E2=80=99. =C2=B9 https://github.com/wingo/fibers =C2=B2 https://github.com/wingo/fibers/pull/53