Bug#1051514: grub-common: Please remove grub-common.service from boot hot path
On Sun, Sep 10, 2023 at 03:45:52PM +0200, Paul Menzel wrote: > Dear Andres, > > > Thank you for your reply. > > Am 10.09.23 um 13:54 schrieb Julian Andres Klode: > > On Sat, Sep 09, 2023 at 12:21:29AM +0200, Paul Menzel wrote: > > > Package: grub-common > > > Version: 2.12~rc1-9 > > > Severity: normal > > > > The unit `grub-common.service` is installed to the multi-user.target and > > > therefore run during boot-up, slowing down the boot, especially as shell > > > commands are used. > > > > > > ``` > > > $ systemctl cat grub-common.service > > > # /lib/systemd/system/grub-common.service > > > [Unit] > > > Description=Record successful boot for GRUB > > > After=suspend.target hibernate.target hybrid-sleep.target > > > suspend-then-hibernate.target > > > ConditionPathExists=/boot/grub/grub.cfg > > > > > > [Service] > > > Type=oneshot > > > Restart=no > > > ExecStartPre=/bin/sh -c '[ -s /boot/grub/grubenv ] || rm -f > > > /boot/grub/grubenv; mkdir -p /boot/grub' > > > ExecStart=grub-editenv /boot/grub/grubenv unset recordfail > > > ExecStartPost=/bin/sh -c 'if grub-editenv /boot/grub/grubenv list | grep > > > -q > > > initrdless_boot_fallback_triggered=1; then echo "grub: GRUB_FORCE_PARTUUID > > > set, initrdless boot paniced, fallback triggered."; fi' > > > StandardOutput=kmsg > > > > > > [Install] > > > WantedBy=multi-user.target suspend.target hibernate.target > > > hybrid-sleep.target suspend-then-hibernate.target > > > ``` > > > > As you can see, there are no Before relations in the service, > > so grub-common is not in the hot path, nothing depends on it > > having finished startup. > > > > I'm sure this was well intended and not a troll attempt, but > > systemd doesn't start services in a sequence, so services can > > run in parallel and there is in general very little ordering > > requirements. > > That is exactly, what I was saying. Due to the missing ordering, systemd > starts this service as early as possible causing pressure on the possibly > scarce system resources at the beginning. So care has to be taken > introducing these things. Looking into decreasing the start time of an > Ubuntu system once, grub-common showed up there, so it will make the startup > time of quite a lot of Debian systems longer now too. Please keep in mind, > that Debian is also run on older systems. I think bug reports like this are ill-advised, it is not our decision to make how to start services and abusing timers for this is wrong. If you want units that do not contribute to the target to run only when idle, then my suggestion would be to add such a feature to systemd itself rather than go around trying to hack each such instance with timers. That said, I strongly disagree with the assessment. Boot is not interactive so it is less of a priority to have it fast vs having a performant interactive session. On the extreme, if you boot into your desktop and then it eats up all your cores and locks up the UI on your resource constrained device that's a worse experience than waiting longer at boot and then having things work correctly. -- debian developer - deb.li/jak | jak-linux.org - free software dev ubuntu core developer i speak de, en
Bug#1051514: grub-common: Please remove grub-common.service from boot hot path
Dear Andres, Thank you for your reply. Am 10.09.23 um 13:54 schrieb Julian Andres Klode: On Sat, Sep 09, 2023 at 12:21:29AM +0200, Paul Menzel wrote: Package: grub-common Version: 2.12~rc1-9 Severity: normal The unit `grub-common.service` is installed to the multi-user.target and therefore run during boot-up, slowing down the boot, especially as shell commands are used. ``` $ systemctl cat grub-common.service # /lib/systemd/system/grub-common.service [Unit] Description=Record successful boot for GRUB After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target ConditionPathExists=/boot/grub/grub.cfg [Service] Type=oneshot Restart=no ExecStartPre=/bin/sh -c '[ -s /boot/grub/grubenv ] || rm -f /boot/grub/grubenv; mkdir -p /boot/grub' ExecStart=grub-editenv /boot/grub/grubenv unset recordfail ExecStartPost=/bin/sh -c 'if grub-editenv /boot/grub/grubenv list | grep -q initrdless_boot_fallback_triggered=1; then echo "grub: GRUB_FORCE_PARTUUID set, initrdless boot paniced, fallback triggered."; fi' StandardOutput=kmsg [Install] WantedBy=multi-user.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target ``` As you can see, there are no Before relations in the service, so grub-common is not in the hot path, nothing depends on it having finished startup. I'm sure this was well intended and not a troll attempt, but systemd doesn't start services in a sequence, so services can run in parallel and there is in general very little ordering requirements. That is exactly, what I was saying. Due to the missing ordering, systemd starts this service as early as possible causing pressure on the possibly scarce system resources at the beginning. So care has to be taken introducing these things. Looking into decreasing the start time of an Ubuntu system once, grub-common showed up there, so it will make the startup time of quite a lot of Debian systems longer now too. Please keep in mind, that Debian is also run on older systems. I suggest you have a look at your `systemd-analyze critical-chain` to see your actual critical chain. Thank you. I am well aware of these tools – including systemd-bootchart. Kind regards, Paul
Bug#1051514: grub-common: Please remove grub-common.service from boot hot path
Package: grub-common Version: 2.12~rc1-9 Severity: normal Dear Debian folks, The unit `grub-common.service` is installed to the multi-user.target and therefore run during boot-up, slowing down the boot, especially as shell commands are used. ``` $ systemctl cat grub-common.service # /lib/systemd/system/grub-common.service [Unit] Description=Record successful boot for GRUB After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target ConditionPathExists=/boot/grub/grub.cfg [Service] Type=oneshot Restart=no ExecStartPre=/bin/sh -c '[ -s /boot/grub/grubenv ] || rm -f /boot/grub/grubenv; mkdir -p /boot/grub' ExecStart=grub-editenv /boot/grub/grubenv unset recordfail ExecStartPost=/bin/sh -c 'if grub-editenv /boot/grub/grubenv list | grep -q initrdless_boot_fallback_triggered=1; then echo "grub: GRUB_FORCE_PARTUUID set, initrdless boot paniced, fallback triggered."; fi' StandardOutput=kmsg [Install] WantedBy=multi-user.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target ``` It’d be great, if you removed it from the hot path and it would be run by some kind of timer. Kind regards, Paul