Re: performance of shell read loops

2016-03-13 Thread Joerg Sonnenberger
On Sat, Mar 12, 2016 at 10:17:26PM +0700, Robert Elz wrote: > | Actually I was wondering if there aren't more use cases for a "read > | until you find the following sequence" system call or just something > | specifiying a (simple) regular expression. > > I was too - but I suspect that the o

Re: performance of shell read loops

2016-03-13 Thread David Laight
On Sat, Mar 12, 2016 at 10:17:26PM +0700, Robert Elz wrote: > > | Actually I was wondering if there aren't more use cases for a "read > | until you find the following sequence" system call or just something > | specifiying a (simple) regular expression. > > I was too - but I suspect that th

Re: performance of shell read loops

2016-03-12 Thread Robert Elz
Date:Sat, 12 Mar 2016 14:50:59 +0100 From:Joerg Sonnenberger Message-ID: <20160312135059.ga27...@britannica.bec.de> | I'm not sure. A lot of shell processing also happens on real files. There are three cases that could work to improve this - when input is seekable,

Re: performance of shell read loops

2016-03-12 Thread Joerg Sonnenberger
On Sat, Mar 12, 2016 at 12:08:10PM +, David Laight wrote: > On Mon, Mar 07, 2016 at 04:09:06PM +0700, Robert Elz wrote: > > > > 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 m

Re: performance of shell read loops

2016-03-12 Thread David Laight
On Mon, Mar 07, 2016 at 04:09:06PM +0700, Robert Elz wrote: > > 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

Re: performance of shell read loops

2016-03-07 Thread Robert Elz
Date:Mon, 7 Mar 2016 05:21:35 + From:David Holland Message-ID: <20160307052135.ga7...@netbsd.org> | 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

Re: performance of shell read loops

2016-03-07 Thread Robert Elz
Date:Mon, 7 Mar 2016 05:21:35 + From:David Holland Message-ID: <20160307052135.ga7...@netbsd.org> | Today it came up (in the context of something Christos did) that shell | read loops are horribly, horribly slow. I had been intending to look at shell performa

performance of shell read loops

2016-03-06 Thread David Holland
Today it came up (in the context of something Christos did) that shell read loops are horribly, horribly slow. I'd always assumed that this was because shell read loops tend to fork at least once for every iteration (so O(n) times) and a more pipeline-oriented approach tends to fork O(1) times. Whi