Hacker News new | ask | show | jobs
by aniou 20 days ago
Heh, I’m so old that I remember when systemd promised that the new init system would be easier to understand than those "vague startup scripts."

Meanwhile, on systems where I don’t use systemd, the entire initialization process can be displayed in about 30 lines on the screen - and I don’t have to wade through a chaotic web of dependencies, some of which are even auto-generated. As far as I can tell, I currently have about 350 of them active.

Boot times were supposed to be fast, too - yet, curiously enough, systemd often ends up saying, "waiting 1m30s for..."

7 comments

> Boot times were supposed to be fast, too - yet, curiously enough, systemd often ends up saying, "waiting 1m30s for..."

wouldn't that be the fault of the service it's waiting for and not systemd itself?

If it’s only happening under systemd, then I’d argue it’s systemd’s fault.

On one side, you have shell scripts that are generally pretty simple (FreeBSD’s init is something like 1000-2000 LOC for the implementation, and a simple service script is tens of lines).

On the other side, you have a monolith that hit 1.3 million lines of code a few years ago, and has gotten more and more complicated since then.

Assuming the waits are not a bug, then they are a misconfiguration. When I gave up on using it, the manual was long, incomprehensible, and the small documented fraction of systemd’s behavior didn’t match the manual.

> On the other side, you have a monolith that hit 1.3 million lines of code a few years ago, and has gotten more and more complicated since then.

Just a nit, that 1.3 million lines was reported incorrectly. You can see some talk at https://news.ycombinator.com/item?id=21935186 and I remember a Poettering tweet saying that was including things like documentation. At the time systemd was under 500k lines; still big but not quite so huge.

I'm also not sure if that count was for the full repository (which contains multiple modular projects like systemd-resolved that are not required for systemd) or just the actual systemd bin.

By not using systemd, you just shift the complexity around. Now suddenly every program needs to be able to do the double-forking song-and-dance, track PID files, etc.

systemd suffers from the lack of systemic design, but it's still way better than the pile of scripts that it replaced.

This is the whole service management for OpenBSD

https://github.com/openbsd/src/blob/master/usr.sbin/rcctl/rc...

Then you got the initialization script

https://github.com/openbsd/src/blob/master/etc/rc

Service file can be very small

https://github.com/openbsd/src/blob/master/etc/rc.d/httpd

Powered by

https://github.com/openbsd/src/blob/master/etc/rc.d/rc.subr

Also daemon(3) for running as a system service

https://man.openbsd.org/daemon.3

And no need to track pid. It uses pgrep with the flags and the program name by default. I believe OpenRC does the same.

https://github.com/openbsd/src/blob/f5d74fd467fccdfc60b450a7...

Yep, that's exactly the mess I'm talking about. Scripts that are ALWAYS incorrect, incomplete, and unreliable.

For example, can it kill a runaway Apache process tree? Or safely confine the CGI scripts so that they don't cause the OOM killer to terminate the sshd?

And what happens if the "stop" command hangs indefinitely?

> And no need to track pid. It uses pgrep with the flags and the program name by default. I believe OpenRC does the same.

Facepalm.

> Scripts that are ALWAYS incorrect, incomplete, and unreliable.

The BSDs have used it for years now and it works well enough

> Or safely confine the CGI scripts so that they don't cause the OOM killer to terminate the sshd?

That’s a different thing than service management. It’s handled by the login class of the program’s user which specify such things.

> And what happens if the "stop" command hangs indefinitely?

The logic for stop is in the rc.subr file. There’s a timeout for trying to send TERM, then it’s KILL.

> Facepalm.

How many services do you intend to run on a single machine/vm? rc is simple, use existing tooling, and it’s more of convenience than a new things you have to take care of. I run debian and while systemd works, I’m not sure I need all of those stuff.

> Now suddenly every program needs to be able to...

If by "every program" you mean "your init system", then sure. For example, OpenRC predates systemd by several years, can manage both forking and non-forking services, [0] and supervise non-forking programs with no PID files required.

[0] It even handles both s6 and systemd-style socket-based readiness notification.

Process supervision was not invented by systemd; worse still, it appears that systemd completely ignored earlier solutions in this field.

I was strongly disappointed and shocked when I realize that Lennart was not able to write something like "my solution is better or comparable to daemontools, because".

> Process supervision was not invented by systemd; worse still, it appears that systemd completely ignored earlier solutions in this field.

Facepalm^2. Do you remember the origin story of upstart and systemd?

Daemontools attempted to do similar things, but the only available tool for it was process groups versus cgroups. It also missed the service activation support.

Ekhem. "Service activation" thing was older than coal and rarely used, because of little usability at the time. It was called "inetd".

And to be precise - I'm not wrote, that daemontools and others already has support for cgroups (that was a moderate young concept, comparing to daemontools age). I'm pointing, that systemd author never admit that he draw a conclusions from prior work. I cannot talk about NIH syndrome even, because it was "I don’t even know that someone did this already".

> I was strongly disappointed and shocked when I realize that Lennart was not able to write something like "my solution is better or comparable to daemontools, because".

Oh, but he did! Didn't you see where he wrote over and over and over again «SystemD is better than everything else because it is the Modern Way to do Linux and everything else is Legacy Garbage.»? ;)

> If it’s only happening under systemd, then I’d argue it’s systemd’s fault.

Yep. For me, it's most often a 90 second delay that comes from the combination of the automagical conversion of fstab entries into services, an NFS mount in fstab, and an offline NFS server.

Sane init systems notice that this is a networked filesystem (I've even marked it with the _netdev option!) and don't hang the boot for a minute and a half screaming at a dead server. Systemd is anything but sane.

Imdeed. Ubuntu tried its own upstart for a while, and there were a few others too. Gentoo has (had?) some alternatives to sysV.. Devuan felt like boycotting systemd. Didn't seem to help stop the spread but at least you could use something else if you wanted. Systemd is indeed a bit of a mini OS under the OS. We came a long way but I also feel that the improvements didn't necessarily result in faster boots.
> Gentoo has (had?) some alternatives to sysV.

You're probably thinking of OpenRC. It's quite nice and remains the distro's default init system.

Yep. I remember upstart, as well as some really neat soft-lockups, when a system gone "bricked", even without console, in result of bad-written network address :)

To be honest, from very beginning I viewed both (upstart and systemd) as dead-ends. Dependencies? Meh, rcorder in NetBSD has local dependencies years ago and, for larger installations, local-only dependency system has no value - because my app needs mysql... on another server. And modern init and supervision suite (systemd) without concept of inter-network dependecy? Meh. Like... let me think... a project of modern desktop without concept of remote work in eve of remote work explosion and covid times too - or something like that.

Supervising? I already had daemontools, monit, runit and whatever else (not mentioning s6) - even nowadays I really don't see cases, when systemd is used to restart services automatically.

I wonder if its because systemd is more rigorous about prerequisites. With systemd its normal to wait until networking is up before starting, say, a webserver. But in the days before you just started it without checking.
Btw that's the default behavior. You can change that. Most common reason systemd is slow is waiting on disks. But you don't have to (I don't). IME the hard drives and network mounts are the usual suspects. If they're not your main drivers mount then non blocking and they'll usually be up by the time you actually need them. Though if you're a server then you probably don't want that
Yep, and that's why a lot of old code has things like retry loops when a server starts in case binding the socket fails, or if a configured network interface/directory doesn't exist (instead of failing fast), etc. So much cruft could be cleaned up if we embraced this new world where we finally have reliable dependencies.

Sure your web server "started" 5 seconds after boot, in that a PID now exists for it, but that doesn't mean it will serve a web request if dhcp hasn't finished yet. `/etc/init.d/nginx status` tells lies on those old systems.

Call me crazy but I think it's much better for software to recover from (some) asynchronous/transient conditions by itself (at least if it's not a trivially stateless service). I've had to go great lengths to implement transparent redundant networking for software which doesn't know how to reconnect a TCP socket and instead just hangs for 5 minutes.

  > retry loops when a server starts in case binding the socket fails, or if a configured network interface/directory doesn't exist
FYI, you can change all of that pretty easily.

I think the issue is systemd takes the stance of the "safe" route first, which is not really necessary for most personal machines and not the greatest when people are using mostly flash. But a 90s timeout makes sense if you are loading a 20TB hdd (I've even seen longer load times on much smaller drives)

I believe systemd is a matter of control, not tech advancement. From the fruit you tell the tree and one of the easiest to see fruit has been to change long standing ways to admin a linux box. Coincidentally, the entity who pushed for systemd in very unorthodox ways, the discussion archives are probably still online, is also the entity making money with linux certifications, which de facto expire when the long standing ways to admin a linux box get obsoleted. So I will skip systemd and criticize instead all the modesetting and plymouth and stuff that altered those 30 lines of the screen which tell me what's happening when booting, what's unusually slow, what's broken. They removed it because walls of text reeked of old difficult ways to deal with pcs, while graphics GUI were the future. But the future became LLMs and walls of texts are things to copy into a prompt if you have doubts about what they meant. I prefer letting the GUI operate on the things it does best and let the wall of text tell me how the machine is booting.

  > Boot times were supposed to be fast, too - yet, curiously enough, systemd often ends up saying, "waiting 1m30s for..."
I'd wager that that's your disk drive being slow to boot.

Either lazy load that drive or change to faster media like a ssd or nvme.

My guess is because that's the default timeout for disks

If you have too many services, just disable them. Most systemd entries on my machines are virtual things (mounts, cgroups, etc.) that have no impact on startup performance or complexity.

Stuff the same amount of functionality into whatever 2000s style boot mechanism you use, and you'll be waiting just as long (you'll just need to make your you add ample `sleep` calls to make sure the network is up before your web server can bind, or accept that your system boots up flaky perhaps).

The first thing I noticed after switching to Void Linux that uses Runit instead of systemd was that my PC would now boot faster than my TV takes to turn on. The second thing I noticed was that I had way less processes run that I had no idea what they are supposed to do.