Bug#696465: /etc/bash_completion.d/grub wastes 35 ms running sed "s, x, x, " 12 times

Anders Kaseorg andersk at MIT.EDU
Fri Dec 21 07:29:53 UTC 2012


Package: grub-common
Version: 2.00-7

After fixing the worst offender (#695811), I found that about 15% of my 
bash’s startup time is spent in /etc/bash_completion.d/grub forking and 
execing sed "s,x,x," 12 times.  The patch below reduces the time it takes 
to source /etc/bash_completion.d/grub from 42 ms to 7 ms, saving 35 ms on 
startup of every interactive bash.  This stuff adds up!

This sed call comes from @program_transform_name@; for Debian we can 
safely assume that functionality is not used.  Perhaps upstream should 
consider refactoring to perform this transformation at build time.

Alternatively (or in addition), consider moving this script to the new 
/usr/share/bash-completion/completions directory with appropriate symlinks 
and Breaks: bash-completion (<< 1:1.90-1), so that it need not be loaded 
on bash startup at all.

Anders

--- /etc/bash_completion.d/grub
+++ /etc/bash_completion.d/grub
@@ -168 +168 @@
-__grub_set_default_program=$( echo grub-set-default | sed "s,x,x," )
+__grub_set_default_program=grub-set-default
@@ -173 +173 @@
-__grub_reboot_program=$( echo grub-reboot | sed "s,x,x," )
+__grub_reboot_program=grub-reboot
@@ -200 +200 @@
-__grub_editenv_program=$( echo grub-editenv | sed "s,x,x," )
+__grub_editenv_program=grub-editenv
@@ -221 +221 @@
-__grub_mkconfig_program=$( echo grub-mkconfig | sed "s,x,x," )
+__grub_mkconfig_program=grub-mkconfig
@@ -255 +255 @@
-__grub_setup_program=$( echo grub-setup | sed "s,x,x," )
+__grub_setup_program=grub-setup
@@ -301 +301 @@
-__grub_install_program=$( echo grub-install | sed "s,x,x," )
+__grub_install_program=grub-install
@@ -323 +323 @@
-__grub_mkfont_program=$( echo grub-mkfont | sed "s,x,x," )
+__grub_mkfont_program=grub-mkfont
@@ -354 +354 @@
-__grub_mkrescue_program=$( echo grub-mkrescue | sed "s,x,x," )
+__grub_mkrescue_program=grub-mkrescue
@@ -396 +396 @@
-__grub_mkimage_program=$( echo grub-mkimage | sed "s,x,x," )
+__grub_mkimage_program=grub-mkimage
@@ -418 +418 @@
-__grub_mkpasswd_pbkdf2_program=$( echo grub-mkpasswd-pbkdf2 | sed "s,x,x," )
+__grub_mkpasswd_pbkdf2_program=grub-mkpasswd-pbkdf2
@@ -456 +456 @@
-__grub_probe_program=$( echo grub-probe | sed "s,x,x," )
+__grub_probe_program=grub-probe
@@ -478 +478 @@
-__grub_script_check_program=$( echo grub-script-check | sed "s,x,x," )
+__grub_script_check_program=grub-script-check



More information about the Pkg-grub-devel mailing list