GNU bug report logs - #25706
26.0.50; Slow C file fontification

Previous Next

Packages: cc-mode, emacs;

Reported by: Sujith <m.sujith <at> gmail.com>

Date: Mon, 13 Feb 2017 18:41:01 UTC

Severity: normal

Tags: moreinfo

Found in version 26.0.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Alan Mackenzie <acm <at> muc.de>
To: Mattias EngdegÄrd <mattiase <at> acm.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 25706 <at> debbugs.gnu.org
Subject: bug#25706: 26.0.50; Slow C file fontification
Date: Tue, 1 Dec 2020 12:57:34 +0000
Hello, Mattias.

On Tue, Dec 01, 2020 at 13:03:21 +0100, Mattias EngdegÄrd wrote:
> 1 dec. 2020 kl. 10.21 skrev Alan Mackenzie <acm <at> muc.de>:

> > (i) Take the first 10% of the original 4MB file, and save it in a
> >  different file.
> > (ii) Fontify that file from top to bottom: according to EPL, 292s
> > (iii) Insert 9 new lines "{}" every 10% of that new file.
> > (iv) Fontify the amended file top to bottom: new time 98s.

> > That's a factor of 3 different.

> Thank you, quite remarkable and a very useful piece of information!
> Please let me curb some unwarranted optimism that I'm guilty of
> engendering:

> We have been measuring slightly different things. Being lazy, I timed
> the fontification in one go:

>  (font-lock-ensure (point-min) (point-max))

> which took about 65 s originally and went down to about 24 s by fixing
> the regexps as previously mentioned. Much better but still not
> wonderful.

> You have measured interactive scrolling which is more realistic, but
> fontifying the buffer piecemeal it exercises slightly different code
> paths. Fixing those regexps helps but not as much, and clearly more
> work is needed.

> (By the way, could you direct me to your benchmark code? I don't think
> I have it.)

Just something I threw together a few years ago, and use regularly on
xdisp.c to check nothing's gone seriously slow/see how well my latest
optimisation has worked.

(defmacro time-it (&rest forms)
  "Time the running of a sequence of forms using `float-time'.
Call like this: \"M-: (time-it (foo ...) (bar ...) ...)\"."
  `(let ((start (float-time)))
    ,@forms
    (- (float-time) start)))

(defun time-scroll (&optional arg)
  (interactive "P")
  (message "%s"
           (time-it
            (condition-case nil
                (while t
                  (if arg (scroll-down) (scroll-up))
                  (sit-for 0))
              (error nil)))))

Put point at the start or end of a buffer and do M-: (time-scroll) or M-:
(time-scroll t) as appropriate.

> Still, improving regexps is clearly beneficial. Reducing allocation can
> be effective as well; a fair bit of the profile is in the GC.

How much time does this regexp change save on a "normal" file, such as
src/xdisp.c?

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 4 years and 214 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.