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: Mattias EngdegÄrd <mattiase <at> acm.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 25706 <at> debbugs.gnu.org
Subject: bug#25706: 26.0.50; Slow C file fontification
Date: Mon, 30 Nov 2020 17:53:04 +0100
30 nov. 2020 kl. 17.38 skrev Alan Mackenzie <acm <at> muc.de>:

> Yes.  I've had a look at the file, and it's large and lacking in braces.
> There are functions in CC Mode which search backwards for opening braces
> to establish context.  When there are none, the search goes back to BOB.
> Lots of these searches, not efficiently cached, take a long time.
> 
> It's a problem with CC Mode, not with the source file.  It's a known
> problem, and not easy to fix.

Actually, it's the underscores!
Demo: fill a file with the line pairs

#define abc_defg_hij_klm__nop_qrst_uvw_xyz_w__ooa_cin_e__aoi__uynv(s) \
 0

repeated 1000 times, thus making it 2000 lines. Save as something.h. Slow!
Now replace each underscore with a letter. Save. Fast!

Fontifying the 2000 line file (with underscores) takes longer than the original 80000 line file.

I started going through c-find-decl-spots and c-find-decl-prefix-search (together there are while statements nested 4 deep) but am not sure exactly where the trouble is. A regexp? Something syntax-char related (since '_' has symbol syntax, not word)?

CC-mode in general thrashes the regexp cache; the miss rate is at 27 % for the original file, which is way too high. Enlarging the cache enough to eliminate misses helps, but not nearly enough.





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

Previous Next


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