Here are the code and the measurements.

partman/lib/base.sh currently uses statements such as:
    template=$(cat $dir/question)
As reported before, with the long default
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
then current busybox sh using both fork() and execve() runs
    cat /dev/null
for 1000 iterations in 22.2 seconds on unmodified armel-eabi NSLU2
(133MHz armv5te.)

Changing to the the modified short PATH=/bin , then 1000 iterations
take 21.5 seconds.

Changing tryexec()/shell/ash.c to use only fork() and no execve()
[verified using strace]:
-----
        struct BB_applet const *app = (struct BB_applet const 
*)find_applet_by_name(cmd);
        int argc = 0;
        {
                char **p;
                for (p = argv; *p; ++p)
                        ++argc;
        }
        if (app) {
                __environ = envp;
                exit(app->main(argc, argv));
        }
-----
runs 1000 iterations of the builtin applet
    cat /dev/null
in 12.7 seconds.

The syntax for busybox sh to replace
    template=$(cat $dir/question)
is
    read template  < $dir/question
Then 1000 iterations of
    read line  < /dev/null
takes 0.66 seconds.  [Thus fork() is almost as slow as execve()
when measured in the busybox sh environment.]

So, avoiding both fork+execve is faster by an order of magnitude
than using fork and avoiding only execve.  Avoiding both fork+exec
also bounds the required testing, because only partman is affected,
and not everything else that uses busybox sh.

Some d-i developer probably could edit partman/lib/base.sh to use 'read'
instead of 'cat', test it, and report the results in less than a day.
I got lost in debian-installer-20080522/build/README.

-- 



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to