[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU Emacs 24 Performance Issues in 'add-text-properties
From: |
Stefan Monnier |
Subject: |
Re: GNU Emacs 24 Performance Issues in 'add-text-properties |
Date: |
Thu, 04 Sep 2014 16:04:38 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) |
> Actually, I wrote the commenting because font-lock-mode is too slow on large
> C/C++ files.
Performance of c-mode's highlighting on large files can indeed be
problematic. This said, Emacs's own src/xdisp.c (1MB, 30K lines) is
a test case which Emacs maintainers use on a regular basis
(intentionally or not), so we try to fix those problems, and we
generally consider them as bugs.
If you have a file where Emacs's major mode suffers from performance
problems, please M-x report-emacs-bug. It's not always easy to fix, but
we do try to find some solution.
> Thanks for your response. This does work well with no interference from
> font-lock-mode because I turn and keep font-lock-mode off when I edit C/C++.
When I try your code on my machine (on Emacs's src/xdisp.c, with
font-lock disabled), it indeed takes a few seconds to run in c-mode, but
is "instantaneous" in fundamental-mode. Running it twice in succession in
c-mode, only the first run is slow.
Running it through M-x profiler-start, I get the following profile:
- command-execute 5900 98%
- call-interactively 5900 98%
- execute-extended-command 5773 96%
- command-execute 5760 96%
- call-interactively 5760 96%
- mark-comments 5744 95%
- while 5740 95%
- add-text-properties 5704 95%
- c-after-change 5012 83%
- let* 4996 83%
- unwind-protect 4996 83%
- progn 4996 83%
- save-restriction 4996 83%
- let 4996 83%
- unwind-protect 4992 83%
- progn 4984 83%
- save-excursion 4808 80%
- mapc 4808 80%
- #<lambda 0xe067877> 4808 80%
- funcall 4808 80%
- c-neutralize-syntax-in-and-mark-CPP 4800 80%
...
so as you can see, even though I did disable font-lock-mode, c-mode
still has an after-change-function installed (probably used because
syntactic info is also needed for indentation and is cached to avoid
terrible slowdowns in large files) and it takes the lion's share of
the time.
Stefan