its a performance problem with the underlying regex
whenever (...) groups are involved it has to work harder
if you only care about *any* match vs the longest of the leftmost matches
then prefix the pattern with ~(-g)
which means "not greedy" or "minimal"
this loop shows the time deterioration
x=
for ((i = 1; i <= 20; i++))
do x=x$x
time -f %E $SHELL -c "[[ x__${x}__x == *@(__+(+(x)?(_))__)* ]];
printf '%d %2d ' $? $i"
done
On Tue, Oct 29, 2013 at 8:40 AM, Dan Rickhoff <[email protected]>wrote:
>
> If this is a ksh bug, what ksh version should I upgrade to?
>
> On:
> OS: Red Hat Enterprise Linux Server release 6.1 (Santiago)
> ksh: version sh (AT&T Research) 93t+ 2010-06-21
>
> Elapsed time less than 2 tenths of a second:
>
> $ time -f ‘%E\n' ksh -e '[[ A__BBBBBBBB_CCCCC_Z_EEEE__F ==
> *@(__+(+([A-Z0-9])?(_))__)* ]]'
> 0:00.14
>
> However, if that string is extended by adding, say, seven more "Z"s, then
> the elapsed mushrooms to almost 10 seconds.
>
> $ time -f '%E\n' ksh -e '[[ A__BBBBBBBB_CCCCC_ZZZZZZZZ_EEEE__F ==
> *@(__+(+([A-Z0-9])?(_))__)* ]]'
> 0:09.96
>
> This appears to be a ksh bug (a memory leak?), what ksh version must I
> upgrade to to get past it?
>
> Please let me know if I should provide further information.
>
> Thanks,
> Dan
>
> _______________________________________________
> ast-users mailing list
> [email protected]
> http://lists.research.att.com/mailman/listinfo/ast-users
>
>
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users