GNU bug report logs - #59738
c-ts-mode is slow with large buffers.

Previous Next

Package: emacs;

Reported by: Alan Mackenzie <acm <at> muc.de>

Date: Thu, 1 Dec 2022 11:51:02 UTC

Severity: normal

Done: Yuan Fu <casouri <at> gmail.com>

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: Eli Zaretskii <eliz <at> gnu.org>
Cc: Yuan Fu <casouri <at> gmail.com>, 59738 <at> debbugs.gnu.org
Subject: bug#59738: c-ts-mode is slow with large buffers.
Date: Sat, 10 Dec 2022 21:34:20 +0000
Hello, Eli.

On Thu, Dec 08, 2022 at 22:37:05 +0200, Eli Zaretskii wrote:
> > From: Yuan Fu <casouri <at> gmail.com>
> > Date: Wed, 7 Dec 2022 16:40:15 -0800
> > Cc: Alan Mackenzie <acm <at> muc.de>,
> >  59738 <at> debbugs.gnu.org

> > > Right, but with a long series of #define lines there should be no
> > > parse tree at all…

> > Ok, I think I know why. At the beginning of the file there is this
> > line

> > #ifndef _dce_12_0_SH_MASK_HEADER

> > So it’s parsed into a preproc_ifdef node, which contains every
> > #define directive in the file as its immediate child. Now you have
> > this node with a tons of immediate children. And querying this node
> > in font-lock is very slow, even with a limited range. I think for the
> > query result to be accurate, tree-sitter has to query the whole node
> > without considering the range, then throw away matches that are not
> > in the range. 

> > Anyway, I activated my backup backup plan, which goes down the parse
> > tree to find a sufficiently small node to query. Now scrolling the
> > header file is fast as other files.

> Thanks, now c-ts-mode is twice as fast as c-mode with that file.

> Great job!

The bug which was causing it to be very slow is fixed, so I agree,
excellent job!

But I've measured it as being 62% faster (not twice as fast) as CC Mode.
A "normal" C file (xdisp.c) is around 160% faster, i.e. a little over 2½
times as fast.  These timings are indeed significantly faster.

But given how slow CC Mode was held to be, is a factor 2.6 speed-up
really all that we were expecting from c-ts-mode?  This is the sort of
speed-up one would get by replacing a 5 year old machine with a new one,
or using an optimised build in place of a debug build.

Was I perhaps a little unrealistic in expecting an order of magnitude
speed-up?  Is there still scope for optimisation in c-ts-mode?

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 2 years and 137 days ago.

Previous Next


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