PATCH: inotifyd.c: Implement a builtin 'echo' command

Denys Vlasenko vda.linux at googlemail.com
Mon Oct 10 18:27:38 UTC 2011


On Mon, Oct 10, 2011 at 9:24 AM, Flemming Madsen <busybox at themadsens.dk> wrote:
>
>
> On Mon, Oct 10, 2011 at 8:52 AM, Flemming Madsen <busybox at themadsens.dk>
> wrote:
>>
>>
>>>> Is it a *real* problem for you?
>>>>
>>>
>>> No, it is not a real problem to *me*. I run with my own patched busybox
>>> anyway ..
>>> Consider it a proposition.
>>> But of course, the more stuff I can get merged upstream, the less hassle
>>> the next time I want a new shiny busybox
>>> /Flemming
>>
>> And in replying to myself ..
>> Actually the the kernel is surprisingly effective (to me anyway) in doing
>> fork/exec. The penalty seems to be about 150% on the CPU load, where my gut
>> suspicion would have been around a factor 10 at least.
>> Anyway, I would still want this patch. If not for anything else then for
>> avoiding the PID for new processes to jump in sometimes tens or hundreds per
>> second.
>> /Flemming
>> 2004007309:/var/log# ps l | grep inot
>>  2555  2544 root  1220   292 S    06:27  0:00:25  pts5 inotifyd echo
>> /var/log c
>>  2557  2544 root  1232   292 S    06:27  0:00:10  pts5 inotifyd /bin/echo
>> /var/log c
>>  3242  2544 root  1224   264 S    06:50  0:00:00  pts5 grep inot
>>
>> PS: note how the ':' from the command line is garbled by the program logic
>> .. Though about fixing that, but that would have been a far larger patch
>
> And even further ..
> Of course one should consider the cumulative times, and that changes the
> picture. (The 150% above actually in the fork/exec favor)
> This shows a factor 15 in favor of the patch. More in line with my initial
> expectations.
> /Flemming
> From linux/Documentation/filesystems/proc.txt:
>   utime         user mode jiffies
>   stime         kernel mode jiffies
>   cutime        user mode jiffies with child's
>   cstime        kernel mode jiffies with child's
> 2004007309:/var/log# ps l | grep inot
>  2020  2544 root  1224   264 S    07:05  0:00:00  pts5 grep inot
>  2555  2544 root  1220   292 S    06:27  0:00:41  pts5 inotifyd echo
> /var/log c
>  2557  2544 root  1232   292 S    06:27  0:00:17  pts5 inotifyd /bin/echo
> /var/log c
> 2004007309:/var/log# cat /proc/2555/stat /proc/2557/stat | awk '{print  $1,
> $14, $15, $16, $1
> 7}'
> 2555 1785 2359 0 0
> 2557 214 1566 26052 36573
> 2004007309:/var/log# expr 1785 + 2359
> 4144
> 2004007309:/var/log# expr 214 + 1566 + 26052 + 36573
> 64405
> 2004007309:/var/log# expr 64405 / 4144
> 15

Applied to git:

http://git.busybox.net/busybox/commit/?id=ecccbac37b733a57099c73bc806ac5de64643a35

Instead of using "echo", I decided to use a string which is unlikely
to ever match an existing executable: "-"

Why: real "echo", among other things, does not emit tab-separated
arguments, it separates them with space.

-- 
vda


More information about the busybox mailing list