systemd (Was Re: tmpfs for strategic directories)

Kevin Kofler kevin.kofler at chello.at
Wed May 26 20:56:18 UTC 2010


James Findley wrote:
> You're comparing the wrong thing here - I was demonstrating that it
> doesn't take noticeably longer to spawn awk than a small C app on modern
> systems.
> thus using:
> for i in {1..1000}; do awk 'BEGIN{print "Hello World"}' > /dev/null; done
> for i in {1..1000}; do ./helloworld > /dev/null; done
> we compare how long it takes to start a trivial C program 1000 times to
> a trivial awk program 1000 times.
> The bash for loop overhead is present in both cases, and since we are
> only interested in the difference in speed, we can ignore it.  (I
> actually ran this comparison a number of times, and used the mean value)
> 
> You're comparing how long it takes to launch an awk program 1000 times
> to how long it takes to run 1000 iterations of a loop in C.  This is not
> an especially useful thing to do.

Your comparison is the flawed one. The point of porting the shell code to C 
is to invoke ONE C program instead of many awk, grep etc. subprocesses. All 
the operations done by awk etc. would be done by native C code. So doing the 
loop in C is very much consistent with what we want to accomplish.

IMHO replacing slow interpreted code by fast compiled code is always a good 
idea, especially so if the interpreted code is shell code with its massive 
abuse of process spawning.

        Kevin Kofler



More information about the devel mailing list