unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* The Shepherd on Fibers
@ 2022-03-23 22:36 Ludovic Courtès
  2022-03-25 13:29 ` Maxim Cournoyer
                   ` (8 more replies)
  0 siblings, 9 replies; 42+ messages in thread
From: Ludovic Courtès @ 2022-03-23 22:36 UTC (permalink / raw)
  To: guix-devel

Hello Guix!

I have pushed a ‘wip-fibers’ branch of the Shepherd:

  https://git.savannah.gnu.org/cgit/shepherd.git/log/?h=wip-fibers

The goal is to make shepherd (the daemon) use Fibers¹ 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 ‘herd’ command), etc.  This slows down 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’s
stdout/stderr to a file, and also in the form of “let’s hope the daemon
talks to syslogd”.  Here I was able to trivially add logging, such that
anything spawned by ‘fork+exec-command’ is logged, with timestamps and
all (the logger is a fiber that calls ‘read-line’ in a loop, which is
automagically non-blocking—delightful!).  The next fun step (besides
logging) will be adding inetd-style and/or systemd-style “socket
activation”.

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’s fully cooperative scheduling.

There’s one catch: Fibers is currently Linux-only.  The good news is
that work has been done to port it to other kernels via libevent².
Until it is merged, we could keep using the Shepherd 0.8 on GNU/Hurd.

I’ve done some Guix System testing in VMs and didn’t notice any major
issues.  I’d like to merge that branch in ‘master’ and to eventually
release it as 0.9.0 (with or without socket activation, we’ll see.)
Hopefully, we could be running it within a couple of weeks.

Thoughts?

Ludo’.

¹ https://github.com/wingo/fibers
² https://github.com/wingo/fibers/pull/53


^ permalink raw reply	[flat|nested] 42+ messages in thread
* The Shepherd on Fibers
@ 2022-03-24  6:48 Brendan Tildesley
  0 siblings, 0 replies; 42+ messages in thread
From: Brendan Tildesley @ 2022-03-24  6:48 UTC (permalink / raw)
  To: ludo@gnu.org, guix-devel@gnu.org

I think you are doing amazing work! I hope socket activation can be added
because it may be helpful for launching the user services for pipewire, but I've
never really understood how it actually works.

I would like to replace pulseaudio with pipewire as the default in
%desktop-services, the only hurdle is how to launch the user daemons in all the
different desktop configurations one might use. Other distros use systemd's
socket activation to magically launch pipewire.

Otherwise XDG autostarts or some kind of guix home service could launch it?


^ permalink raw reply	[flat|nested] 42+ messages in thread
* The Shepherd on Fibers
@ 2022-03-24 16:57 Nathan Dehnel
  0 siblings, 0 replies; 42+ messages in thread
From: Nathan Dehnel @ 2022-03-24 16:57 UTC (permalink / raw)
  To: ludo, guix-devel

Hooray!


^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2022-03-31  7:57 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23 22:36 The Shepherd on Fibers Ludovic Courtès
2022-03-25 13:29 ` Maxim Cournoyer
2022-03-26 21:28   ` Ludovic Courtès
2022-03-26 11:06 ` pelzflorian (Florian Pelz)
2022-03-26 11:09   ` Zhu Zihao
2022-03-26 11:16     ` Zhu Zihao
2022-03-26 11:18     ` pelzflorian (Florian Pelz)
2022-03-26 11:27       ` Zhu Zihao
2022-03-26 16:56         ` pelzflorian (Florian Pelz)
2022-03-26 11:59   ` Maxime Devos
2022-03-26 16:52     ` pelzflorian (Florian Pelz)
2022-03-26 18:20       ` Maxime Devos
2022-03-29 11:44   ` Ludovic Courtès
2022-03-26 12:03 ` Maxime Devos
2022-03-29 12:47   ` Ludovic Courtès
2022-03-26 12:11 ` Maxime Devos
2022-03-29 12:48   ` Ludovic Courtès
2022-03-29 16:26     ` Maxime Devos
2022-03-30 15:14       ` Ludovic Courtès
2022-03-30 17:16         ` Maxime Devos
2022-03-26 12:16 ` Maxime Devos
2022-03-29 12:50   ` Ludovic Courtès
2022-03-29 12:52     ` Maxime Devos
2022-03-29 12:54     ` Maxime Devos
2022-03-29 15:29       ` Attila Lendvai
2022-03-30 10:05         ` Ludovic Courtès
2022-03-31  4:33         ` adriano
2022-03-31  7:56           ` Attila Lendvai
2022-03-26 12:44 ` Maxime Devos
2022-03-29 13:03   ` Ludovic Courtès
2022-03-26 19:24 ` Maxime Devos
2022-03-29  0:14 ` Philip McGrath
2022-03-29  0:22   ` Philip McGrath
2022-03-29  9:36   ` Maxime Devos
2022-03-29 11:11     ` Philip McGrath
2022-03-30 10:00       ` Ludovic Courtès
2022-03-29 10:13   ` Zhu Zihao
2022-03-29 10:40     ` Maxime Devos
2022-03-30  9:49   ` Ludovic Courtès
2022-03-29 13:16 ` Ludovic Courtès
  -- strict thread matches above, loose matches on Subject: below --
2022-03-24  6:48 Brendan Tildesley
2022-03-24 16:57 Nathan Dehnel

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).