Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > muc.lists.netbsd.tech.userlevel > #11842

Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result

From Greg Troxel <gdt@lexort.com>
Newsgroups muc.lists.netbsd.tech.userlevel
Subject Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result
Date 2026-08-19 07:07 -0400
Organization Newsgate at muc.de e.V.
Message-ID <rmiy0e2gyhw.fsf@s1.lexort.com> (permalink)
References <> <66B35ACB-AB63-4E0D-B66C-B479A6B6C1C4@me.com>

Show all headers | View raw


Jason Thorpe <thorpej@me.com> writes:

> There’s a comment in the code that describies it:
>
> +#	doeswork	Returns 0 if the script does work that's needed
> +#			for boot, non-zero otherwise.  Scripts are considered
> +#			to do work if either their rcvar is set to YES or
> +#			if they do not have a defined rcvar.
> +#
>
> So let me explain the reasoning.  If a script defines a controlling rcvar, then that script, by definition, has been requested to do nothing if the rcvar evaluates to NO.  Scripts that do not define an rcvar fall into three categories:
>
> - scripts that always do some sort of work (e.g. mountcritlocal)
> - scripts that make some other determination as to whether or not they should do work (e.g. ccd)
> - the barrier scripts (e.g. LOGIN)

> I guess I can really distill it down to: “A script is considered to do no useful work only if it definitively tells us so.”  And it does so by self-reporting that its rcvar is set to NO.

That seems sound.

> The basic rule for rc.d scripts that work in our system is “use
> rc.subr”.  Any script that does will get a safe default for “does
> useful work”.  Any script that doesn’t probably doesn’t actually work
> properly as it is today.  A main design feture of our rc.d system is
> that scripts that don’t provide an explcit action for one of the
> directives get a widely-cast net of reasonable default behavior (and
> yes, I went back and read Luke’s USENIX paper again to provide maximum
> insurance against violating any religious tenents while working on
> this problem).

That is a rule in NetBSD but I do not expect it is followed by all
scripts installed by pkgsrc.

A different view is that the basic rule is that an rc.d script must
implement start, stop, status, reload, and should check a variable.
rc.subr is certainly a good library to use, and a convention, but it
isn't strictly necessary.


> The one situation where it could fall over is “some random rc.d script
> doesn’t use rc.subr at all”, and this it will not respond to the
> “doeswork” directive.  But even if I invert the sense to a “canskip”
> directive, some random rc.d script that doesn’t use rc.subr at all
> could choose to play Towers of Hanoi rather than exit with an error
> status.

Sure, but we can say that "invoked with a command that isn't understood"
should lead to quick error exit as an implied specification, far more
strongly than we can say that using rc.subr is an implied specification.

There are a lot of packages with scripts and many of them are old.

> I guess my point is the only rule a script has to follow is “use
> rc.subr”, which seems to be an *incredibly* low bar (because if they
> don’t, there’s already a myriad of ways those scripts could fall
> over).  If it follows that one rule, then the only way it gets
> optimized out is if is uses a control variable and that control
> variable contains the value that explcitiy says “yo script, you are to
> do no work”.

I don't see any downside to inverting the test.

>> (Also, it seems obvious that if you commit this, it should default to
>> off at first, except perhaps for particularly slow arches.)
>
> Of course, this has the side-effect of reducing the amount of dog
> food-induced problem finding and is yet another step that people have
> to do in order to make their systems run fast, but ok, sure.

I said "at first".   While every change that's committed is believed to
not cause regressions, it seems best to let the first 20 people opt in
and after it's been a month or so and there are no bugs on the table, it
seems ok to make it default.

Basically I don't think it's ok to push testing onto current-users,
until there's been enough testing that finding a bug would be very
surprising.  In this case, testing is all about environments you haven't
contemplated.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de

Back to muc.lists.netbsd.tech.userlevel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Improving the performance of system boot by eliding unused rc.d scripts and caching the result Jason Thorpe <thorpej@me.com> - 2026-08-17 21:46 -0700
  Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Edgar Fuß <ef@math.uni-bonn.de> - 2026-08-18 11:07 +0200
    Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Jason Thorpe <thorpej@me.com> - 2026-08-18 06:07 -0700
  Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Greg Troxel <gdt@lexort.com> - 2026-08-18 06:41 -0400
    Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Jason Thorpe <thorpej@me.com> - 2026-08-18 06:44 -0700
      Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Mouse <mouse@Rodents-Montreal.ORG> - 2026-08-18 09:51 -0400
        Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Jason Thorpe <thorpej@me.com> - 2026-08-18 06:58 -0700
        Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result David Holland <dholland-tech@netbsd.org> - 2026-08-19 04:33 +0000
          barrier scripts (was: Improving the performance of system boot by eliding unused rc.d scripts and caching the result) Edgar Fuß <ef@math.uni-bonn.de> - 2026-08-19 11:20 +0200
          Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Greg Troxel <gdt@lexort.com> - 2026-08-19 06:43 -0400
            Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Jason Thorpe <thorpej@me.com> - 2026-08-19 06:16 -0700
            Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result David Holland <dholland-tech@netbsd.org> - 2026-08-20 16:03 +0000
              Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Greg Troxel <gdt@lexort.com> - 2026-08-20 12:35 -0400
                Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Jason Thorpe <thorpej@me.com> - 2026-08-20 09:51 -0700
                Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result David Holland <dholland-tech@netbsd.org> - 2026-08-20 21:09 +0000
          Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result "Simon J. Gerraty" <sjg@crufty.net> - 2026-08-19 14:07 -0700
      Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Greg Troxel <gdt@lexort.com> - 2026-08-19 07:07 -0400
        Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Jason Thorpe <thorpej@me.com> - 2026-08-19 08:47 -0700
          Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Robert Elz <kre@munnari.OZ.AU> - 2026-08-20 10:43 +0700
            Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Jason Thorpe <thorpej@me.com> - 2026-08-19 23:27 -0700
              Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Robert Elz <kre@munnari.OZ.AU> - 2026-08-21 04:37 +0700
            Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Edgar Fuß <ef@math.uni-bonn.de> - 2026-08-20 10:12 +0200
              Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Jason Thorpe <thorpej@me.com> - 2026-08-20 06:40 -0700
            Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Valery Ushakov <uwe@stderr.spb.ru> - 2026-08-20 12:38 +0300
              Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Robert Elz <kre@munnari.OZ.AU> - 2026-08-21 02:17 +0700
    Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Martin Neitzel <neitzel@hackett.marshlabs.gaertner.de> - 2026-08-21 01:38 +0200
  Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Robert Elz <kre@munnari.OZ.AU> - 2026-08-19 02:07 +0700
    "good" editors [was Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result] Mouse <mouse@Rodents-Montreal.ORG> - 2026-08-18 15:19 -0400
    Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Jason Thorpe <thorpej@me.com> - 2026-08-18 14:24 -0700
      Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result Robert Elz <kre@munnari.OZ.AU> - 2026-08-19 08:08 +0700
        shell quoting (was: Improving the performance of system boot by eliding unused rc.d scripts and caching the result) Edgar Fuß <ef@math.uni-bonn.de> - 2026-08-19 11:17 +0200
          Re: shell quoting (was: Improving the performance of system boot by eliding unused rc.d scripts and caching the result) David Holland <dholland-tech@netbsd.org> - 2026-08-20 16:16 +0000
            Re: shell quoting (was: Improving the performance of system boot by eliding unused rc.d scripts and caching the result) Ken Hornstein <kenh@pobox.com> - 2026-08-20 12:36 -0400
          Re: shell quoting (was: Improving the performance of system boot by eliding unused rc.d scripts and caching the result) Robert Elz <kre@munnari.OZ.AU> - 2026-08-21 12:37 +0700
            Re: shell quoting Jarle Greipsland <jarle.greipsland@norid.no> - 2026-09-09 08:36 +0200
              Re: shell quoting Edgar Fuß <ef@math.uni-bonn.de> - 2026-09-09 10:28 +0200
                Re: shell quoting Robert Elz <kre@munnari.OZ.AU> - 2026-09-09 18:42 +0700
                Re: shell quoting Edgar Fuß <ef@math.uni-bonn.de> - 2026-09-09 14:42 +0200
                Re: shell quoting kre@munnari.OZ.AU - 2026-09-09 20:03 +0700
                Re: shell quoting Robert Elz <kre@munnari.OZ.AU> - 2026-09-09 20:21 +0700
              Re: shell quoting Robert Elz <kre@munnari.OZ.AU> - 2026-09-09 18:36 +0700
                Re: shell quoting Edgar Fuß <ef@math.uni-bonn.de> - 2026-09-09 17:28 +0200
                Re: shell quoting Edgar Fuß <ef@math.uni-bonn.de> - 2026-09-09 17:31 +0200
                Re: shell quoting Robert Elz <kre@munnari.OZ.AU> - 2026-09-10 08:12 +0700
                Re: shell quoting Mouse <mouse@Rodents-Montreal.ORG> - 2026-09-09 21:38 -0400
                Re: shell quoting Robert Elz <kre@munnari.OZ.AU> - 2026-09-10 10:10 +0700
                Re: shell quoting Jarle Greipsland <jarle.greipsland@norid.no> - 2026-09-09 18:56 +0200
                Re: shell quoting Robert Elz <kre@munnari.OZ.AU> - 2026-09-10 08:51 +0700

csiph-web