diff mbox

package/systemd: Optionally disable hwdb

Message ID 1460717190-29291-1-git-send-email-m.niestroj@grinn-global.com
State Accepted
Headers show

Commit Message

Marcin Niestroj April 15, 2016, 10:46 a.m. UTC
By default hwdb files are installed in /usr/lib/udev/hwdb.d
Currently they take about ~5MB. After first boot, systemd-hwdb tool
parses them and creates a binary in /etc/udev/hwdb.bin, which takes
another ~6.5MB.

In case of initramfs images, hwdb parsing is done every boot. This adds
about 2-3 seconds to boot time in case of rootfs on SDHC class 10
card (benchmarked with am335x board). NAND boot takes even longer.

Add config option to disable hwdb in systemd, for smaller images and
better boot performance.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
---
 package/systemd/Config.in  | 11 +++++++++++
 package/systemd/systemd.mk |  6 ++++++
 2 files changed, 17 insertions(+)

Comments

Peter Seiderer April 15, 2016, 8:53 p.m. UTC | #1
Hello Marcin Niestroj,

On Fri, 15 Apr 2016 12:46:30 +0200, Marcin Niestroj <m.niestroj@grinn-global.com> wrote:

> By default hwdb files are installed in /usr/lib/udev/hwdb.d
> Currently they take about ~5MB. After first boot, systemd-hwdb tool
> parses them and creates a binary in /etc/udev/hwdb.bin, which takes
> another ~6.5MB.
> 
> In case of initramfs images, hwdb parsing is done every boot. This adds
> about 2-3 seconds to boot time in case of rootfs on SDHC class 10
> card (benchmarked with am335x board). NAND boot takes even longer.
> 

Perfect for this case would be 'systemd-hwdb update' run at built time to
create the hwdb files once, but maybe stuff for a follow up patch...

Regards,
Peter


> Add config option to disable hwdb in systemd, for smaller images and
> better boot performance.
> 
> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
> ---
>  package/systemd/Config.in  | 11 +++++++++++
>  package/systemd/systemd.mk |  6 ++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> index 97d48c4..324e884 100644
> --- a/package/systemd/Config.in
> +++ b/package/systemd/Config.in
> @@ -84,6 +84,17 @@ config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
>  
>  	  http://www.freedesktop.org/software/systemd/man/systemd-journal-gatewayd.service.html
>  
> +config BR2_PACKAGE_SYSTEMD_HWDB
> +	bool "enable hwdb installation"
> +	default y
> +	help
> +	  Enables hardware database installation to /usr/lib/udev/hwdb.d
> +
> +	  Disabling this option improves first boot time (or every boot
> +	  time in case of initramfs images) and saves several MB space.
> +
> +	  https://www.freedesktop.org/software/systemd/man/hwdb.html
> +
>  config BR2_PACKAGE_SYSTEMD_BINFMT
>  	bool "enable binfmt tool"
>  	help
> diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
> index 79e657e..29b62c0 100644
> --- a/package/systemd/systemd.mk
> +++ b/package/systemd/systemd.mk
> @@ -127,6 +127,12 @@ else
>  SYSTEMD_CONF_OPTS += --disable-microhttpd
>  endif
>  
> +ifeq ($(BR2_PACKAGE_SYSTEMD_HWDB),y)
> +SYSTEMD_CONF_OPTS += --enable-hwdb
> +else
> +SYSTEMD_CONF_OPTS += --disable-hwdb
> +endif
> +
>  ifeq ($(BR2_PACKAGE_SYSTEMD_BINFMT),y)
>  SYSTEMD_CONF_OPTS += --enable-binfmt
>  else
Marcin Niestroj April 18, 2016, 8:25 a.m. UTC | #2
Hi,

On 15.04.2016 22:53, Peter Seiderer wrote:
> Hello Marcin Niestroj,
>
> On Fri, 15 Apr 2016 12:46:30 +0200, Marcin Niestroj <m.niestroj@grinn-global.com> wrote:
>
>> By default hwdb files are installed in /usr/lib/udev/hwdb.d
>> Currently they take about ~5MB. After first boot, systemd-hwdb tool
>> parses them and creates a binary in /etc/udev/hwdb.bin, which takes
>> another ~6.5MB.
>>
>> In case of initramfs images, hwdb parsing is done every boot. This adds
>> about 2-3 seconds to boot time in case of rootfs on SDHC class 10
>> card (benchmarked with am335x board). NAND boot takes even longer.
>>
>
> Perfect for this case would be 'systemd-hwdb update' run at built time to
> create the hwdb files once, but maybe stuff for a follow up patch...

I thought about it. This would propably require compiling part of 
systemd for the host PC, so the build time would be significally 
increased. This can be implemented if someone finds use case for it. For 
now it is ok for me that we totally disable hwdb and save additional 
space of the binary hwdb file.

For OpenEmbedded I saw a patch that was running QEMU to just generate 
the binary hwdb file at build time. I don't think this is an option for us.
Marcin Niestroj June 7, 2016, 2:37 p.m. UTC | #3
ping

On 15.04.2016 12:46, Marcin Niestroj wrote:
> By default hwdb files are installed in /usr/lib/udev/hwdb.d
> Currently they take about ~5MB. After first boot, systemd-hwdb tool
> parses them and creates a binary in /etc/udev/hwdb.bin, which takes
> another ~6.5MB.
>
> In case of initramfs images, hwdb parsing is done every boot. This adds
> about 2-3 seconds to boot time in case of rootfs on SDHC class 10
> card (benchmarked with am335x board). NAND boot takes even longer.
>
> Add config option to disable hwdb in systemd, for smaller images and
> better boot performance.
>
> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
> ---
>  package/systemd/Config.in  | 11 +++++++++++
>  package/systemd/systemd.mk |  6 ++++++
>  2 files changed, 17 insertions(+)
>
> diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> index 97d48c4..324e884 100644
> --- a/package/systemd/Config.in
> +++ b/package/systemd/Config.in
> @@ -84,6 +84,17 @@ config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
>
>  	  http://www.freedesktop.org/software/systemd/man/systemd-journal-gatewayd.service.html
>
> +config BR2_PACKAGE_SYSTEMD_HWDB
> +	bool "enable hwdb installation"
> +	default y
> +	help
> +	  Enables hardware database installation to /usr/lib/udev/hwdb.d
> +
> +	  Disabling this option improves first boot time (or every boot
> +	  time in case of initramfs images) and saves several MB space.
> +
> +	  https://www.freedesktop.org/software/systemd/man/hwdb.html
> +
>  config BR2_PACKAGE_SYSTEMD_BINFMT
>  	bool "enable binfmt tool"
>  	help
> diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
> index 79e657e..29b62c0 100644
> --- a/package/systemd/systemd.mk
> +++ b/package/systemd/systemd.mk
> @@ -127,6 +127,12 @@ else
>  SYSTEMD_CONF_OPTS += --disable-microhttpd
>  endif
>
> +ifeq ($(BR2_PACKAGE_SYSTEMD_HWDB),y)
> +SYSTEMD_CONF_OPTS += --enable-hwdb
> +else
> +SYSTEMD_CONF_OPTS += --disable-hwdb
> +endif
> +
>  ifeq ($(BR2_PACKAGE_SYSTEMD_BINFMT),y)
>  SYSTEMD_CONF_OPTS += --enable-binfmt
>  else
>
Yann E. MORIN June 8, 2016, 8:19 p.m. UTC | #4
Marcin, All,

On 2016-04-15 12:46 +0200, Marcin Niestroj spake thusly:
> By default hwdb files are installed in /usr/lib/udev/hwdb.d
> Currently they take about ~5MB. After first boot, systemd-hwdb tool
> parses them and creates a binary in /etc/udev/hwdb.bin, which takes
> another ~6.5MB.
> 
> In case of initramfs images, hwdb parsing is done every boot. This adds
> about 2-3 seconds to boot time in case of rootfs on SDHC class 10
> card (benchmarked with am335x board). NAND boot takes even longer.

So that's where my boot time goes! ;-)

> Add config option to disable hwdb in systemd, for smaller images and
> better boot performance.
> 
> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>

I'm looking at all systemd-related pending patches, since I'm working on
cleaning up our systemd handling...

I have had a look at the systemd code to update the hwdb, and it is not
trivially replaced, so we would indeed need a host-systemd if we wanted
to generate the hwdb at build time.

I don't think this warrants the complexity of a host-systemd, however...

Yet, I'd like to know what would be the impact of not having hwdb
support at runtime. Care to shed some light, please?

Otherwise:

Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

Regards,
Yann E. MORIN.

> ---
>  package/systemd/Config.in  | 11 +++++++++++
>  package/systemd/systemd.mk |  6 ++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> index 97d48c4..324e884 100644
> --- a/package/systemd/Config.in
> +++ b/package/systemd/Config.in
> @@ -84,6 +84,17 @@ config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
>  
>  	  http://www.freedesktop.org/software/systemd/man/systemd-journal-gatewayd.service.html
>  
> +config BR2_PACKAGE_SYSTEMD_HWDB
> +	bool "enable hwdb installation"
> +	default y
> +	help
> +	  Enables hardware database installation to /usr/lib/udev/hwdb.d
> +
> +	  Disabling this option improves first boot time (or every boot
> +	  time in case of initramfs images) and saves several MB space.
> +
> +	  https://www.freedesktop.org/software/systemd/man/hwdb.html
> +
>  config BR2_PACKAGE_SYSTEMD_BINFMT
>  	bool "enable binfmt tool"
>  	help
> diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
> index 79e657e..29b62c0 100644
> --- a/package/systemd/systemd.mk
> +++ b/package/systemd/systemd.mk
> @@ -127,6 +127,12 @@ else
>  SYSTEMD_CONF_OPTS += --disable-microhttpd
>  endif
>  
> +ifeq ($(BR2_PACKAGE_SYSTEMD_HWDB),y)
> +SYSTEMD_CONF_OPTS += --enable-hwdb
> +else
> +SYSTEMD_CONF_OPTS += --disable-hwdb
> +endif
> +
>  ifeq ($(BR2_PACKAGE_SYSTEMD_BINFMT),y)
>  SYSTEMD_CONF_OPTS += --enable-binfmt
>  else
> -- 
> 2.8.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Marcin Niestroj June 13, 2016, 9:20 a.m. UTC | #5
Hi,

On 08.06.2016 22:19, Yann E. MORIN wrote:
> Marcin, All,
>
> On 2016-04-15 12:46 +0200, Marcin Niestroj spake thusly:
>> By default hwdb files are installed in /usr/lib/udev/hwdb.d
>> Currently they take about ~5MB. After first boot, systemd-hwdb tool
>> parses them and creates a binary in /etc/udev/hwdb.bin, which takes
>> another ~6.5MB.
>>
>> In case of initramfs images, hwdb parsing is done every boot. This adds
>> about 2-3 seconds to boot time in case of rootfs on SDHC class 10
>> card (benchmarked with am335x board). NAND boot takes even longer.
>
> So that's where my boot time goes! ;-)
>
>> Add config option to disable hwdb in systemd, for smaller images and
>> better boot performance.
>>
>> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
>
> I'm looking at all systemd-related pending patches, since I'm working on
> cleaning up our systemd handling...
>
> I have had a look at the systemd code to update the hwdb, and it is not
> trivially replaced, so we would indeed need a host-systemd if we wanted
> to generate the hwdb at build time.
>
> I don't think this warrants the complexity of a host-systemd, however...
>
> Yet, I'd like to know what would be the impact of not having hwdb
> support at runtime. Care to shed some light, please?

HWDB is mainly a database of device classes and vendors (for PCI, SDIO,
USB). This is helpfull during development, because tools like lsusb are
able to show vendor and usb class for each device. However we don't
need this in production most of the time.
Additionally there are some files for input devices, like mouse,
keyboard and pointstick. In keyboard files for example there are
defined some special keys, like play/pause, volumeup etc.

Regards,
Marcin

>
> Otherwise:
>
> Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
>
> Regards,
> Yann E. MORIN.
>
>> ---
>>  package/systemd/Config.in  | 11 +++++++++++
>>  package/systemd/systemd.mk |  6 ++++++
>>  2 files changed, 17 insertions(+)
>>
>> diff --git a/package/systemd/Config.in b/package/systemd/Config.in
>> index 97d48c4..324e884 100644
>> --- a/package/systemd/Config.in
>> +++ b/package/systemd/Config.in
>> @@ -84,6 +84,17 @@ config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
>>
>>  	  http://www.freedesktop.org/software/systemd/man/systemd-journal-gatewayd.service.html
>>
>> +config BR2_PACKAGE_SYSTEMD_HWDB
>> +	bool "enable hwdb installation"
>> +	default y
>> +	help
>> +	  Enables hardware database installation to /usr/lib/udev/hwdb.d
>> +
>> +	  Disabling this option improves first boot time (or every boot
>> +	  time in case of initramfs images) and saves several MB space.
>> +
>> +	  https://www.freedesktop.org/software/systemd/man/hwdb.html
>> +
>>  config BR2_PACKAGE_SYSTEMD_BINFMT
>>  	bool "enable binfmt tool"
>>  	help
>> diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
>> index 79e657e..29b62c0 100644
>> --- a/package/systemd/systemd.mk
>> +++ b/package/systemd/systemd.mk
>> @@ -127,6 +127,12 @@ else
>>  SYSTEMD_CONF_OPTS += --disable-microhttpd
>>  endif
>>
>> +ifeq ($(BR2_PACKAGE_SYSTEMD_HWDB),y)
>> +SYSTEMD_CONF_OPTS += --enable-hwdb
>> +else
>> +SYSTEMD_CONF_OPTS += --disable-hwdb
>> +endif
>> +
>>  ifeq ($(BR2_PACKAGE_SYSTEMD_BINFMT),y)
>>  SYSTEMD_CONF_OPTS += --enable-binfmt
>>  else
>> --
>> 2.8.0
>>
>> _______________________________________________
>> buildroot mailing list
>> buildroot@busybox.net
>> http://lists.busybox.net/mailman/listinfo/buildroot
>
Yann E. MORIN June 13, 2016, 8 p.m. UTC | #6
Marcin, All,

On 2016-06-13 11:20 +0200, Marcin Niestroj spake thusly:
> On 08.06.2016 22:19, Yann E. MORIN wrote:
> >On 2016-04-15 12:46 +0200, Marcin Niestroj spake thusly:
> >>By default hwdb files are installed in /usr/lib/udev/hwdb.d
> >>Currently they take about ~5MB. After first boot, systemd-hwdb tool
> >>parses them and creates a binary in /etc/udev/hwdb.bin, which takes
> >>another ~6.5MB.
> >>
> >>In case of initramfs images, hwdb parsing is done every boot. This adds
> >>about 2-3 seconds to boot time in case of rootfs on SDHC class 10
> >>card (benchmarked with am335x board). NAND boot takes even longer.
[--SNIP--]
> >Yet, I'd like to know what would be the impact of not having hwdb
> >support at runtime. Care to shed some light, please?
> 
> HWDB is mainly a database of device classes and vendors (for PCI, SDIO,
> USB). This is helpfull during development, because tools like lsusb are
> able to show vendor and usb class for each device. However we don't
> need this in production most of the time.
> Additionally there are some files for input devices, like mouse,
> keyboard and pointstick. In keyboard files for example there are
> defined some special keys, like play/pause, volumeup etc.

OK, thanks for the info, definitively usefull.

So, it seems this is not systematically needed on production systems,
but mostly a "debugging" aid in most cases. And for those that need it,
it's still an option.

However, people that do need it and that are working either on a
read-only filesystem or a transient one (initramfs) would need a mean
to avoid building this hwdb at every boot... That would be so cool...

Regards,
Yann E. MORIN.
Thomas Petazzoni June 15, 2016, 9:19 p.m. UTC | #7
Hello,

On Fri, 15 Apr 2016 12:46:30 +0200, Marcin Niestroj wrote:
> By default hwdb files are installed in /usr/lib/udev/hwdb.d
> Currently they take about ~5MB. After first boot, systemd-hwdb tool
> parses them and creates a binary in /etc/udev/hwdb.bin, which takes
> another ~6.5MB.
> 
> In case of initramfs images, hwdb parsing is done every boot. This adds
> about 2-3 seconds to boot time in case of rootfs on SDHC class 10
> card (benchmarked with am335x board). NAND boot takes even longer.
> 
> Add config option to disable hwdb in systemd, for smaller images and
> better boot performance.
> 
> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
> ---
>  package/systemd/Config.in  | 11 +++++++++++
>  package/systemd/systemd.mk |  6 ++++++
>  2 files changed, 17 insertions(+)

Applied to master, thanks.

Thomas
diff mbox

Patch

diff --git a/package/systemd/Config.in b/package/systemd/Config.in
index 97d48c4..324e884 100644
--- a/package/systemd/Config.in
+++ b/package/systemd/Config.in
@@ -84,6 +84,17 @@  config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
 
 	  http://www.freedesktop.org/software/systemd/man/systemd-journal-gatewayd.service.html
 
+config BR2_PACKAGE_SYSTEMD_HWDB
+	bool "enable hwdb installation"
+	default y
+	help
+	  Enables hardware database installation to /usr/lib/udev/hwdb.d
+
+	  Disabling this option improves first boot time (or every boot
+	  time in case of initramfs images) and saves several MB space.
+
+	  https://www.freedesktop.org/software/systemd/man/hwdb.html
+
 config BR2_PACKAGE_SYSTEMD_BINFMT
 	bool "enable binfmt tool"
 	help
diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
index 79e657e..29b62c0 100644
--- a/package/systemd/systemd.mk
+++ b/package/systemd/systemd.mk
@@ -127,6 +127,12 @@  else
 SYSTEMD_CONF_OPTS += --disable-microhttpd
 endif
 
+ifeq ($(BR2_PACKAGE_SYSTEMD_HWDB),y)
+SYSTEMD_CONF_OPTS += --enable-hwdb
+else
+SYSTEMD_CONF_OPTS += --disable-hwdb
+endif
+
 ifeq ($(BR2_PACKAGE_SYSTEMD_BINFMT),y)
 SYSTEMD_CONF_OPTS += --enable-binfmt
 else