[BusyBox] builtin echo for ash

Shaun Jackman sjackman at gmail.com
Sat Aug 6 22:26:25 UTC 2005


On 8/5/05, Paul Fox <pgf at brightstareng.com> wrote:
> i've implemented a builtin echo command in ash.  i didn't have to
> do much -- i moved the guts of the echo applet into libbb, and
> now call bb_echo() from both echo.c and ash.c.  so the code size
> impact of having both the applet and the builtin is minimal.
> 
> it seems to work, and on our platform (400mhz MPC5200, with small
> caches) is at least 60x faster.  (running a script of 4000 echo
> statements takes under a second with the builtin, versus about
> one minute otherwise.)

I'd guess the primary reason for the performance difference here is
the fork(2) call.
The typical solution in *nix was to provide a shell built-in as Paul
has done. Busybox is in the unique position of being able to provide
another solution, namely
optionally providing a bb_fork() via longjmp implementation. echo
wouldn't need to be a special case; every applet would implicitly
receive the same performance benefit by avoiding the fork(2) call.

I'm still all for this patch though. The currently mythical bb_fork()
won't be for everyone, and providing the typical *nix solution is a
good idea.

Cheers,
Shaun



More information about the busybox mailing list