Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16379

Re: 'while read' loop performance (redirection vs pipeline)

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: 'while read' loop performance (redirection vs pipeline)
Date 2020-06-10 09:49 -0400
Organization ITS, Case Western Reserve University
Message-ID <mailman.1589.1591797005.2541.bug-bash@gnu.org> (permalink)
References <1591789732.21528.14.camel@aliquot.org> <75f7cd6a-4442-9659-deed-78812de1d2b9@case.edu>

Show all headers | View raw


On 6/10/20 7:48 AM, Terence O'Gorman wrote:

> Bash Version: 5.0
> Patch Level: 11
> Release Status: release
> 
> 
> Description:
> 
> The 'while read' loop exhibits very different performance depending on
> whether input is via redirection or pipeline (and increasingly diverging
> performance with any increased data).  Here are some results from my
> machine (also observed in versions 3.0 and 4.0):

Two forks and one exec are expensive, as are the single-byte reads through
the pipe. The single-byte reads are required because the shell is not
allowed to read ahead in this case, since the remaining input may be
intended for another process.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: 'while read' loop performance (redirection vs pipeline) Chet Ramey <chet.ramey@case.edu> - 2020-06-10 09:49 -0400

csiph-web