Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :cc:content-transfer-encoding;
        bh=zFqSxO/cLkJ5ohFusUONSgmUZwnlspZuK+UQEmCpabs=;
        b=amXV0Xbk1EgxY0E/ugA90/KrTfq+gpo49sVixg+D4dsI/wxjkIR6htd+uRywVv2NoR
         XWMVPdN4TAHdTLZj1dYjs72PfFsKzrBTeIqZCiCLKx3Xs1mLHDxKrmNFVSxQ+V74BmwI
         qUMaWvbI8RfCp5g0mdIez0/yUb/A9T64pp0ilaRpR8BpMCm9Vkjt3hf6XXHXMs1Qq7rL
         vo6O11svgAlYyNHq3PbzfXWoFj9jBLSrZlYlP3A53nzTRcxXIYPnxsdWWUEHPOnWEjOB
         88xQLT76iyfpz4VCtHONtkkUI60FTIdHcVpX5o0z8FwQ828YFuI8HYdyzJeGZHzvAics
         ugVg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:cc:content-transfer-encoding;
        bh=zFqSxO/cLkJ5ohFusUONSgmUZwnlspZuK+UQEmCpabs=;
        b=FLLMG1Y+8/I5GtlMnM34PygeKCzPy0syHfigo/7ad+xeEuOJ+isK5GntwROsh46dOL
         XT6jmDPLKQDBPueYjRfpmmJS+BmSv2L6rjdL61EestMlW8g6UXk6CqsAyDYpnN+AZgFz
         KxGSm8VQI1yLpWUhj00giPf4SMUVj3pqSJR+UVZyM9qJxQoz/jDSQqbPYW0OtIn0hyO/
         Wd+n5w6sdOM+2sdJ9QjACkNmbGRs/QPWdbwK3bWWjMwCVf0FKYYX4awSbkZ1sl6oh9W0
         4ESwAtiuyCTXqXl90KZAoEu1WaDZfZtpty25MCCxTgQLjhzUM/VFO68pRVbdRWyL1A7E
         4AOg==
X-Gm-Message-State: ALyK8tKfqYaSzlcN3Jlqdl1WQoGqo7acPa3w8BaMF7/Khk5zcUXVvFWM3H7SkIuOLK6GCyjrpM6t1fnobkXZUA==
X-Received: by 10.55.99.216 with SMTP id x207mr12578607qkb.163.1465156062923;
 Sun, 05 Jun 2016 12:47:42 -0700 (PDT)
MIME-Version: 1.0
In-Reply-To: <160605121020.ZM7727@torch.brasslantern.com>
References: <CAKc7PVC=AES1LhY7tYTXrPsefX3CXgtUsxiVbDaxmc5o2iHnVw@mail.gmail.com>
 <160605121020.ZM7727@torch.brasslantern.com>
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Sun, 5 Jun 2016 21:47:23 +0200
Message-ID: <CAKc7PVC+v4i0z1Q8DLw2MvQhx6a2BJ8A4QyDVJ+6m2YWN5h9fw@mail.gmail.com>
Subject: Re: [BUG] Long line makes pattern matching (by //) hog Zsh
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Seq: zsh-workers 38618

On 5 June 2016 at 21:10, Bart Schaefer <schaefer@brasslantern.com> wrote:
> It's in the block in pattern.c:patchmatch() that begins with the
> comment:
>
>                 /*
>                  * Lookahead to avoid useless matches. This is not possib=
le
>                  * with approximation.
>                  */
>
> Specifically, in the "if (no >=3D min) for (;;) ..." loop, at each charat=
er
> in the input string patmatch() is called recursively to look at the rest
> of the string, which again enters this same loop because the next thing
> is also a one-or-more expression, which calls recursively and again
> enters the loop because the thing after that is a zero-or-more.
>
> It consumes a LOT of memory while doing this, even if I add a hack to
> prevent it from recursively re-entering lookahead (or to skip the
> lookahead entirely).

Too bad the input isn't even that large, ~2850 characters. And that
the pattern even with first segment removed =E2=80=93 ([^0-9/\\\\
]##[^/\\\\]#(#e)) =E2=80=93 i.e. two 0/1-or-more segments, is also slow,
although doesn't hog Zsh. Maybe your changes would make a difference
for that input size, and for first segment removed, i.e. two # or ##
blocks? I had simplified highlighting in my tool and should be fine
now, but maybe in future I could restore the more sophisticated
pattern.

Best regards,
Sebastian Gniazdowski

