unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuri Khan <yuri.v.khan@gmail.com>
To: "Clément Pit--Claudel" <clement.pit@gmail.com>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Documentation on debugging regexp performance
Date: Thu, 21 Jan 2016 12:36:34 +0600	[thread overview]
Message-ID: <CAP_d_8XRPUYE1xcge8tVKVoFGRBsTw8_yabR-vzbYopvaU2iTw@mail.gmail.com> (raw)
In-Reply-To: <56A06CD6.2090707@gmail.com>

On Thu, Jan 21, 2016 at 11:29 AM, Clément Pit--Claudel
<clement.pit@gmail.com> wrote:
> Hi emacs-devel,
>
> I'm running into a surprising regular expressions issue. I have attached a file (~50k) in which (re-search-forward "   +[^:=]+ +:=?") seems to be extremely slow. (I killed it after 30 seconds). Truncating the file to its first 20 lines reduces the time for re-search-forward to about a second, which is still extremely slow.

I’m no expert on the Emacs regexp implementation, but this part is
ambiguous: "[^:=]+ +". The engine will have to backtrack at least once
because the first part will greedily slurp all spaces, then the second
part will not match. You might want to add the space to the exclusion
character class: "[^:= ]+ +".



  reply	other threads:[~2016-01-21  6:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21  5:29 Documentation on debugging regexp performance Clément Pit--Claudel
2016-01-21  6:36 ` Yuri Khan [this message]
2016-01-21  9:39   ` Alexis
2016-01-21 13:22     ` Clément Pit--Claudel
2016-01-21 22:10     ` Marcin Borkowski
2016-01-22  7:02       ` Alexis
2016-01-22 14:32       ` Clément Pit--Claudel
2016-01-21 11:42 ` Wolfgang Jenkner
2016-01-21 16:38   ` Clément Pit--Claudel
2016-01-21 15:27 ` Alan Mackenzie
2016-01-21 16:37   ` Clément Pit--Claudel
2016-01-21 17:16     ` Alan Mackenzie
2016-01-23  6:12       ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAP_d_8XRPUYE1xcge8tVKVoFGRBsTw8_yabR-vzbYopvaU2iTw@mail.gmail.com \
    --to=yuri.v.khan@gmail.com \
    --cc=clement.pit@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).