bug-bash
[Top][All Lists]
Advanced

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

Re: for; do; done regression ?


From: Eric Blake
Subject: Re: for; do; done regression ?
Date: Fri, 07 Jan 2011 08:43:22 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

On 01/07/2011 08:39 AM, Chet Ramey wrote:
> On 1/7/11 10:03 AM, Chet Ramey wrote:
>> On 1/6/11 8:17 PM, Alexander Tiurin wrote:
>>> Hi!
>>>
>>> I ran the command 
>>>
>>> ~$ time for i in `seq 0 10000`  ; do echo /o/23/4 | cut -d'/' -f2 ; done
>>>> /dev/null 
>>>
>>> 6 times in a row, and noticed to the increase in execution time:
>>>
>>      [...]
>>>
>>> how to interpret the results?
>>
>> It's hard to say without doing more investigation, but I suspect that the
>> fork time is increasing because the bash binary is growing in size.
>>
>> I'd have to build a version with profiling enabled to tell for sure.
> 
> I built a profiling version of bash-4.2 (without the bash malloc, since
> linux doesn't let you replace malloc when you're profiling), and the
> execution time was dominated by fork: around 55-60% of the time.  That's
> around 10-15 times more than any other function.

Is it time to use posix_spawn() instead of fork() in the cases where we
are spawning external processes?  It doesn't help the fact that we have
to still use fork() for subshells, but as the bash binary grows larger,
posix_spawn() becomes more of a win over fork() by reducing kernel
overhead spent in marking a larger memory footprint as copy-on-write,
when that work is later discarded by an exec().

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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