bug-bash
[Top][All Lists]
Advanced

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

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


From: Chet Ramey
Subject: Re: 'while read' loop performance (redirection vs pipeline)
Date: Wed, 10 Jun 2020 09:49:52 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

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/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]