Subject: bug#25706: 26.0.50; Slow C file fontification

From: Sujith <[email-masked]>
Date: Mon, 13 Feb 2017 23:50:20 +0530

On a machine that is not very high-powered, opening some C files
and trying to edit/view them is very slow.

For example:
https://raw.githubusercontent.com/qca/qcamain_open_hal_public/master/hal/ar9300/osprey_reg_map_macro.h

This is a large file and filled with macros.
Is there any way to view this without disabling font-lock entirely ?
I am using the master branch and I have these in my .emacs:

(global-font-lock-mode t)
(setq font-lock-maximum-decoration
      (quote ((c-mode . 2) (c++-mode . 2) (t . t))))
(setq c-font-lock-extra-types
      (quote
       ("\\sw+_t" "bool" "complex" "imaginary" "FILE" "lconv" "tm" "va_list" "jmp_buf" "Lisp_Object"
	"u8" "u16" "u32" "u64"
	"s8" "s16" "s32" "s64"
	"__le16" "__le32" "__le64"
	"__be16" "__be32" "__be64"
	"__s8" "__s16" "__s32" "__s64"
	"__u8" "__u16" "__u32" "__u64")))

The machine is a low-end 10-inch netbook. Some details:

$ uname -a
Linux the-damned 4.10.0-rc7-wt #16 SMP PREEMPT Tue Feb 7 10:47:38 IST 2017 x86_64 GNU/Linux

$ free -m -h
              total        used        free      shared  buff/cache   available
Mem:           1.8G        542M        560M         87M        766M        1.0G
Swap:          2.0G         24M        2.0G

$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 55
model name      : Intel(R) Celeron(R) CPU  N2807  @ 1.58GHz
stepping        : 8
microcode       : 0x811
cpu MHz         : 1828.644
cache size      : 1024 KB

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 55
model name      : Intel(R) Celeron(R) CPU  N2807  @ 1.58GHz
stepping        : 8
microcode       : 0x811
cpu MHz         : 1805.267
cache size      : 1024 KB

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc-multilib/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 6.3.1 20170109 (GCC)

In GNU Emacs 26.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.7)
 of 2017-02-13 built on the-damned
Repository revision: 271dcf8652ccf94d8582b2bcdb26f066d0b946a2
Windowing system distributor 'The X.Org Foundation', version 11.0.11901000
Recent messages:
Checking 57 files in /usr/share/emacs/26.0.50/lisp/eshell...
Checking 70 files in /usr/share/emacs/26.0.50/lisp/erc...
Checking 34 files in /usr/share/emacs/26.0.50/lisp/emulation...
Checking 172 files in /usr/share/emacs/26.0.50/lisp/emacs-lisp...
Checking 24 files in /usr/share/emacs/26.0.50/lisp/cedet...
Checking 57 files in /usr/share/emacs/26.0.50/lisp/calendar...
Checking 87 files in /usr/share/emacs/26.0.50/lisp/calc...
Checking 103 files in /usr/share/emacs/26.0.50/lisp/obsolete...
Checking for load-path shadows...done
Message modified; kill anyway? (y or n) y

Configured using:
 'configure --prefix=/usr --without-libsystemd --without-dbus
 --without-gconf --without-gsettings --without-selinux --without-threads
 --without-gpm --without-xaw3d --without-toolkit-scroll-bars
 --without-m17n-flt --without-libotf --without-imagemagick
 --without-rsvg --without-png --without-gif --without-tiff
 --without-jpeg --without-xpm --with-sound=no CFLAGS=-O3'

Configured features:
NOTIFY ACL GNUTLS LIBXML2 FREETYPE XFT ZLIB GTK3 X11

Important settings:
  value of $LANG: en_IN.UTF-8
  locale-coding-system: utf-8-unix

Major mode: C

Minor modes in effect:
  global-magit-file-mode: t
  magit-file-mode: t
  diff-auto-refine-mode: t
  magit-auto-revert-mode: t
  auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  shell-dirtrack-mode: t
  display-battery-mode: t
  display-time-mode: t
  iswitchb-mode: t
  savehist-mode: t
  save-place-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: 1
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Load-path shadows:
/home/sujith/.emacs.d/elpa/emms-20160304.920/tq hides /usr/share/emacs/26.0.50/lisp/emacs-lisp/tq

Features:
(cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs pp shadow flyspell ispell face-remap emacsbug ibuf-ext
ibuffer ibuffer-loaddefs w3m-form w3m-filter w3m-bookmark w3m-tabmenu
w3m-session ffap w3m timezone w3m-hist w3m-fb bookmark-w3m w3m-ems
wid-edit w3m-ccl ccl w3m-favicon w3m-image w3m-proc w3m-util dired-aux
magit-obsolete magit-blame magit-stash magit-bisect magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-branch
magit-files magit-refs magit-status magit magit-repos magit-apply
magit-wip magit-log magit-diff smerge-mode diff-mode magit-core
magit-autorevert autorevert filenotify magit-process magit-margin
magit-mode magit-git crm magit-section magit-popup git-commit
magit-utils log-edit easy-mmode pcvs-util add-log with-editor
async-bytecomp async tramp-sh tramp tramp-compat tramp-loaddefs trampver
ucs-normalize shell pcomplete parse-time dash advice mu4e-contrib mu4e
desktop frameset mu4e-speedbar speedbar sb-image ezimage dframe
mu4e-main mu4e-context mu4e-view cal-menu calendar cal-loaddefs
thingatpt browse-url comint ansi-color mu4e-headers mu4e-compose
mu4e-draft mu4e-actions ido rfc2368 smtpmail sendmail mu4e-mark
mu4e-message flow-fill html2text mu4e-proc mu4e-proc-mu mu4e-utils
doc-view jka-compr image-mode mu4e-lists mu4e-vars message puny
format-spec rfc822 mml mml-sec epa derived epg gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047
rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils
mailheader hl-line cl mu4e-meta battery time dired-x dired
dired-loaddefs edmacro kmacro xcscope ring server iswitchb savehist
saveplace finder-inf info package epg-config url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache url-vars seq byte-opt subr-x gv bytecomp byte-compile
cl-extra help-mode easymenu cconv cl-loaddefs pcase cl-lib time-date
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript case-table
epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote inotify dynamic-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 1112940 3463)
 (symbols 48 36857 5)
 (miscs 40 96 357)
 (strings 32 73343 16247)
 (string-bytes 1 2484237)
 (vectors 16 59639)
 (vector-slots 8 1342999 94842)
 (floats 8 475 158)
 (intervals 56 127752 56)
 (buffers 976 21))