tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: performance of shell read loops



    Date:        Mon, 7 Mar 2016 05:21:35 +0000
    From:        David Holland <dholland-tech%netbsd.org@localhost>
    Message-ID:  <20160307052135.GA7645%netbsd.org@localhost>

  | pretty bad!

I thought I'd verify my assumption about echo, so modified (my already
modified) script by simply removing the "echo".   Not the same test
at all, so the numbers aren't really comparable, but ...

andromeda$ time ./sh /tmp/script-nofork-sh

real    2m8.881s
user    0m49.017s
sys     1m18.704s

Then I ktrace'd it, and of course, the "read" builtin command is reading
one character at a time.   If you think about it just a litte, you will
see that it must work that way (it is only permitted to take one line of
data from stdin, whatever follows the \n must be still available there for
the next command, whatever it is.)

That will account for essentially all that remaining system time.

Whether the user time can be improved at all will depend upon what
profiling eventually tells me (or someone else.)

kre



Home | Main Index | Thread Index | Old Index