unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Nicolas Richard <theonewiththeevillook@yahoo.fr>
To: Andreas Schwab <schwab@suse.de>
Cc: Nicolas Richard <theonewiththeevillook@yahoo.fr>, 18013@debbugs.gnu.org
Subject: bug#18013: 24.3.92; looking-back "[^\n]" taking a lot of time in large buffers (was: Infloop in re_search_2)
Date: Mon, 14 Jul 2014 13:12:34 +0200	[thread overview]
Message-ID: <878unw9ot9.fsf_-_@geodiff-mac3.ulb.ac.be> (raw)
In-Reply-To: <mvm4mykp83k.fsf@hawking.suse.de> (Andreas Schwab's message of "Mon, 14 Jul 2014 12:06:55 +0200")

Andreas Schwab <schwab@suse.de> writes:

> Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:
>
>> I'll admit that (looking-back "[^\n]") is not exactly the canonical way
>> to test for (not (bolp)), but should it make an infloop ? I can't
>> reproduce though.
>
> I don't think it infloops, it just takes a very long time.  Since this
> is running in a process filter interrupts are disabled, so you have to
> be extra careful with what you do here.

It seems you were totally right, thanks ! Here's a repro test case :

# pick up a big file or make one :

$ yes | dd bs=1MB iflag=fullblock count=50 > foobartest 
50+0 enregistrements lus
50+0 enregistrements écrits
50000000 octets (50 MB) copiés, 0,853576 s, 58,6 MB/s

# open it in an emacs buffer and try looking-back :

$ time emacs --batch -Q --eval '(with-temp-buffer (insert-file-contents "foobartest") (goto-char (point-max)) (princ "Looking back...") (looking-back "[^\n]") (princ "done!") (terpri))'

"Looking back..."

"done!"


real	0m8.577s
user	0m8.541s
sys	0m0.047s

As you see it takes more than 8 seconds on my system, most of that time
is spent looking-back (inserting the file is quick).

(looking-back "[^\n]") is bad code, so I totally deserve this. Still, is
it possible to make the search smarter when the match is supposed to be
"anchored" at point ? Otherwise let's just close this bug.

-- 
Nico.





  parent reply	other threads:[~2014-07-14 11:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-14  9:48 bug#18013: 24.3.92; Infloop in re_search_2 Nicolas Richard
2014-07-14 10:06 ` Andreas Schwab
2014-07-14 10:15   ` Nicolas Richard
2014-07-14 11:12   ` Nicolas Richard [this message]
2014-07-15  6:08     ` bug#18013: 24.3.92; looking-back "[^\n]" taking a lot of time in large buffers Kevin Rodgers
2014-07-15  7:21       ` Andreas Schwab
2017-03-25 20:59     ` npostavs

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=878unw9ot9.fsf_-_@geodiff-mac3.ulb.ac.be \
    --to=theonewiththeevillook@yahoo.fr \
    --cc=18013@debbugs.gnu.org \
    --cc=schwab@suse.de \
    /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).