[systemd-devel] Help needed for optimizing my boot time

Dan Williams dcbw at redhat.com
Thu Jun 11 09:23:54 PDT 2015


On Thu, 2015-06-11 at 15:15 +0200, Francis Moreau wrote:
> On 06/11/2015 02:22 PM, Andrei Borzenkov wrote:
> > On Thu, Jun 11, 2015 at 3:10 PM, Francis Moreau <francis.moro at gmail.com> wrote:
> >> On 06/11/2015 01:40 PM, Andrei Borzenkov wrote:
> >>> On Thu, Jun 11, 2015 at 2:26 PM, Francis Moreau <francis.moro at gmail.com> wrote:
> >>>>>>
> >>>>>>    $ systemd-analyze critical-chain
> >>>>>>
> >>>>>>    graphical.target @7.921s
> >>>>>>      multi-user.target @7.921s
> >>>>>>        autofs.service @7.787s +132ms
> >>>>>>          network-online.target @7.786s
> >>>>>>            network.target @7.786s
> >>>>>>              NetworkManager.service @675ms +184ms
> >>>>>>                basic.target @674ms
> >>>>>>                  ...
> >>>>>>
> >>> ...
> >>>>> Is NetworkManager-wait-online.service enabled and active?
> >>>>>
> >>>>
> >>>> It seems it's enabled but no more active:
> >>>>
> >>>> $ systemctl status NetworkManager-wait-online.service
> >>>> ● NetworkManager-wait-online.service - Network Manager Wait Online
> >>>>    Loaded: loaded
> >>>> (/usr/lib/systemd/system/NetworkManager-wait-online.service; disabled;
> >>>> vendor preset: disabled)
> >>>>    Active: inactive (dead) since Thu 2015-06-11 11:54:37 CEST; 1h 4min ago
> >>>>   Process: 583 ExecStart=/usr/bin/nm-online -s -q --timeout=30
> >>>> (code=exited, status=0/SUCCESS)
> >>>>  Main PID: 583 (code=exited, status=0/SUCCESS)
> >>>>
> >>>> Jun 11 11:54:30 cyclone systemd[1]: Starting Network Manager Wait Online...
> >>>> Jun 11 11:54:37 cyclone systemd[1]: Started Network Manager Wait Online.
> >>>>
> >>>> This seems correct to me, doesn't it ?
> >>>>
> >>>
> >>> Actually it says "disabled" which makes me wonder why it run. But this
> >>> is the service that is likely responsible for long time you observe.
> >>
> >> I think it runs because of this:
> >>
> >> $ ls /usr/lib/systemd/system/network-online.target.wants/
> >> NetworkManager-wait-online.service
> >>
> >> BTW, why isn't it showed by 'systemd-analyze critical-chain' ?
> >>
> > 
> > My best guess is that it has no direct dependency on NetworkManager so
> > it is not counted as part of "chain". You could try adding
> > 
> > After=NetworkManager.service
> > 
> > to see if it changes anything in systemd-analyze output.
> > 
> >>> If disabling it does ot help, you can try masking it (systemctl mask)
> >>> for a test.
> >>
> >> Actually, I'm still not sure why autofs.service is waiting for
> >> network-online.target to be activated, IOW why this service has
> >> 'After=network-online.target'.
> >>
> > 
> > You can discuss it on autofs list; systemd is just a messenger here :)
> > 
> 
> Well it's more a systemd configuration question. I think the
> 'After=network-online.target' in its service file is not really needed.
> 
> I tried to disable autofs service and got a similar issue with ntpd one
> (except network-online.target is not involved here):
> 
>   $ systemd-analyze critical-chain
>   graphical.target @7.921s
>     multi-user.target @7.921s
>       ntpd.service @7.790s +20ms
>         network.target @7.786s
>           NetworkManager.service @675ms +184ms
>             basic.target @674ms
> 
>   $ systemctl show ntpd -p After
>   After=network.target...
> 
> Does ntpd service really need 'After=network.target', not sure.

The 'network online' targets are really just there for ignorant services
that don't respond to network events themselves, that expect the network
to be up and running before they start.  Of course, those services don't
have any way to say *which* network interface they care about, so if you
have more than one interface in your system they still get it wrong.

But anyway, if ntpd or autofs can respond to network events using
netlink or listening on D-Bus to NetworkManager/connman/etc or getting
triggered by eg NetworkManager dispatcher scripts, then they probably
don't need to block on network-online.  But if they can't, and they
expect the network to be up and running before they start, then yes they
will block startup until some kind of networking is running.

Dan



More information about the systemd-devel mailing list