bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25706: 26.0.50; Slow C file fontification


From: Alan Mackenzie
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@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).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]