:: Re: [DNG] make-rc: A parallel (as i…
Pàgina inicial
Delete this message
Reply to this message
Autor: Alejandro Colomar (man-pages)
Data:  
A: Adrian Zaugg, dng
CC: Alejandro Colomar
Assumpte: Re: [DNG] make-rc: A parallel (as in make(1)) alternative to sysv-rc
Hi Adrian,

On 1/5/22 14:42, Adrian Zaugg wrote:
> Hi Alejandro
>
> In der Nachricht vom Wednesday, 5 January 2022 03:03:53 CET schrieb Alejandro
> Colomar (man-pages) via Dng:
>> So, if the problem is that the rc scripts don't run parallel and don't
>> know about exact dependencies from each-other, let's rewrite that part
>
> rc.scripts do run in parallel and they know about dependencies, this is what
> the LSB tags in the beginning of the init scripts are for. See insserv (8).


Ahhh, that's where all of those numbers come from! That's good to know.
Now I can edit my scripts to get the info directly from the LSB tags
to get more precise makefiles. Thanks!

I know that currently rc already parallelizes (I learnt it a few days
ago while reading through its code). However, it's inefficient, given
that the real dependencies are known but not used. Let me show with an
example:

Let's imagine there are 5 scripts A, B, C, D, and E. Each of them has
the following dependencies:

A:
B:
C: A
D: A
E: C

And let's say that they take the following time (in units, let's say
seconds) to execute:

A 1
B 5
C 1
D 5
E 1

Now, I'll guess that the algorithm to chose the order in which to
execute them, since it knows nothing about the time each one takes to
execute, simply assigns levels according to dependencies:

lvl1: A, B
lvl2: C, D
lvl3: E

This will lead to the following run time:

A    Ddddd
BbbbbC    E



See those gaps? The CPU is sleeping there. Not good.
A total of 11 s. Better than the 13 s that it would take if serial, but
much worse than ideal. I admit this is a specially crafted example, but
wonder how far from ideal a real scenario is.

With make(1), this would be fully optimized, as I guess systemd(1) also
does. make(1) would run it like this:

ACDdddd
BbbbbE

A total of 7 s.


Of course, we need to take into account that we're loading make(1),
which is not exactly light, and that will add some time (hopefully
negligible), and then there's also the time of calculating the
dependency tree at run-time instead of compiling it in the form of
numerated symlinks, but I hope that the sum of the added times will be
less than the improvement in times due to full parallelization, and will
result in a net win. There will also be one less program to maintain:
startpar(1), which will be replaced by make(1), which many systems
already have.


$ ls -lh $(realpath $(which startpar make dash bash))
-rwxr-xr-x 1 root root 1.2M Dec 15 00:43 /bin/bash
-rwxr-xr-x 1 root root 123K Nov 3 11:51 /bin/dash
-rwxr-xr-x 1 root root 39K Sep 23 12:03 /bin/startpar
-rwxr-xr-x 1 root root 235K Apr 10 2021 /usr/bin/make

systemd(1) was about 1.8M.


I guess the scripts I wrote would be the replacement for insserv(1), to
compile from LSB-formatted dependencies to Makefile-formatted dependencies.

Any thoughts?


Thanks,

Alex

--
Alejandro Colomar
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/