bug-bash
[Top][All Lists]
Advanced

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

Re: bug: bash 4.2.20 impossibly slow


From: Chet Ramey
Subject: Re: bug: bash 4.2.20 impossibly slow
Date: Wed, 14 Mar 2012 15:59:18 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

On 3/14/12 2:14 PM, Somchai Smythe wrote:
> Hello,
> 
> I am reporting a problem with performance, not correctness.
> 
> While preparing some examples for a course lecture where I code the
> same algorithm in many languages to compare languages, I ran some code
> and while it was  reasonably quick with ksh, it would just apparently
> hang at 100% cpu in bash.  I finally let it run overnight and it does
> complete correctly in bash, but what takes ksh less than a minute
> takes bash 6 1/2 hours to complete (and keeping one core at 100% the
> entire 6.5 hours) on the same hardware.  I suspect there may be some
> special way to compile bash that I don't know about that maybe works
> with arrays differently, so I reporting this.  

I'd have to look at a profiling version of bash to confirm this, but my
initial impression is that this is due to how arrays are implemented
internally: ksh uses c-style arrays (which is why older versions limited
sizes to 4096 elements), while bash uses sparse doubly-linked lists.
The access time difference in big-O notation is obvious.

Chet

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



reply via email to

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