From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18198 invoked by alias); 8 Sep 2014 13:28:01 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19058 Received: (qmail 12504 invoked from network); 8 Sep 2014 13:27:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=ijrEJLPRGw2toahLwqpsJHO5uelf5TSpDSZfts/kEF0=; b=aslDNqNskJTRKxIxHfetmzcUFiww/zpMY/OD1LUH9J1gdNeXFnwAUybhPC74+hUAOI 5Six7RG+IxMeTuT4Jd1vTY+HeHw5uuuPAehF/ggeC9jb6wyjesnlvpdvYIPqGq2lJG/5 8wn54xr+Xd8gHWErX87R0pMPWS20Z/x36RBT3j5aroTil/HObnfiJ9mhW9K+BsigZYb2 6Bk1R/8UNn84CWE7AyJ6O3ih2tUUn+GCPeQz/52lOwgQ0AfUkaGIexp0fj82vtgMr0FA jzoy4BoBmQwiDtO1+cqLQSXRAzEl0JHC3iWAu8YPR/ojyFm7UdpTTXOyTM/kJYHI3ioM affA== MIME-Version: 1.0 X-Received: by 10.70.37.33 with SMTP id v1mr5185518pdj.155.1410182868104; Mon, 08 Sep 2014 06:27:48 -0700 (PDT) Date: Mon, 8 Sep 2014 10:27:48 -0300 Message-ID: Subject: There is a serious inefficiency in the way zsh handles wildcards From: =?UTF-8?Q?Paulo_C=C3=A9sar_Pereira_de_Andrade?= To: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 Hello, I had a bug report described as @subject. The test case was described as: ---%<--- $ time zsh -c "ls /tmp/*****.*****" real 0m0.006s user 0m0.004s sys 0m0.002s $ time zsh -c "ls /tmp/******.******" real 0m0.032s user 0m0.031s sys 0m0.001s $ time zsh -c "ls /tmp/*******.*******" real 0m0.127s user 0m0.125s sys 0m0.003s $ time zsh -c "ls /tmp/********.********" real 0m0.485s user 0m0.484s sys 0m0.002s $ time zsh -c "ls /tmp/**********.**********" real 0m5.933s user 0m5.937s sys 0m0.002s ---%<--- I did look a bit in zsh sources, and wrote this patch, that should not interfere on the special handling of **/ and ***/, and just avoid the very deep recursions that consume a huge amount of cpu, and apparently yield nothing. ---%<--- diff -up zsh-5.0.2/Src/pattern.c.orig zsh-5.0.2/Src/pattern.c --- zsh-5.0.2/Src/pattern.c.orig 2014-09-03 12:21:44.673792750 -0300 +++ zsh-5.0.2/Src/pattern.c 2014-09-03 12:22:28.069303587 -0300 @@ -2911,6 +2911,10 @@ patmatch(Upat prog) break; case P_STAR: /* Handle specially for speed, although really P_ONEHASH+P_ANY */ + while (P_OP(next) == P_STAR) { + scan = next; + next = PATNEXT(scan); + } case P_ONEHASH: case P_TWOHASH: /* ---%<--- Do you believe this patch is OK? The user reports those patterns are generated by one of their scripts. Thanks, Paulo