[Top][All Lists]

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

Re: repeated extended pattern substitution incredibly slow w/large varia

From: Chet Ramey
Subject: Re: repeated extended pattern substitution incredibly slow w/large variables
Date: Mon, 19 Sep 2016 14:43:20 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 9/18/16 5:32 AM, address@hidden wrote:

> Bash Version: 4.4
> Patch Level: 0
> Release Status: rc2 / release
> Description:
>       The tests below were performed with 4.4.0-rc2. However, the problem is
>       still present in 4.4.0-release, only execution times are even higher
>       for about 20%.
>       Repeated pattern substitution (here: removal) using an extended pattern
>       and variables of considerable size is incredibly time and cpu consuming.
>       The command that revealed the problem was:
>                D=${C//\[+([0-9])\]=}

This is absolutely true.  The extended pattern matching code is very slow
and does far more work, in the sense that the matcher traverses the string
to be matched, than it needs to.  It's never been optimized, and the
primitives are not quite suited for this kind of scenario: multiple
short matches in a long string.

This is one of the things on my list to look at for bash-5.0.


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

reply via email to

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