[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU Emacs 24 Performance Issues in 'add-text-properties
From: |
joseph . koziatek |
Subject: |
Re: GNU Emacs 24 Performance Issues in 'add-text-properties |
Date: |
Thu, 4 Sep 2014 11:12:22 -0700 (PDT) |
User-agent: |
G2/1.0 |
On Wednesday, September 3, 2014 4:19:23 PM UTC-4, joseph....@dowjones.com wrote:
> Hello All,
>
>
>
> Recently I started using Gnu Emacs 24.3.1 on Redhat 5 which I built with X
> support. I've noticed that add-text-properties has a performance issue. Below
> is a simplified function I wrote many years ago to gray out C & C++ comments.
> I call it from find-file-hooks and other commands where I select a buffer to
> edit.
>
>
>
> In Gnu Emacs 21.4.1 this routine is blistering fast on a buffer of C++ code
> 11,000 lines long with lots of comments. Under Gnu Emacs 24.3.1 I experience
> a long delay..
>
>
>
> If I comment out the calls to 'add-text-properties under 24.3.1, it is super
> fast, so the 'search-forward commands are not the bottleneck.
>
>
>
> It is the calls to 'add-text-properties causing the long delay.
>
>
>
> The memory usage (virtual memory and physical memory) reported by ps aux
> --sort=-rss,-rss looks normal for both versions (VirtMemory=150Mb and
> Rss=30Mb)
>
>
>
> I'm running on a 16 Cpu box with 32 Gig ram, so I have plenty of horsepower.
>
>
>
> Any help as to what can be causing this code to run so slow under Gnu Emacs
> 24 is greatly appreciated.
>
>
>
> Thanks In Advance
>
> Joe
>
>
>
> ===================================================================
>
>
>
> (setq comm-start "/*" )
>
> (setq comm-end "*/" )
>
> (setq slash2 "//" )
>
>
>
> (defun mark-comments () ;; highlight all C comments...
>
> (interactive)
>
>
>
> (setq savepos (point))
>
> (goto-char (point-min))
>
>
>
> (setq startc (search-forward comm-start nil t))
>
> (setq endc (search-forward comm-end nil t))
>
> (while (and startc endc)
>
> (add-text-properties (- startc 2) (- endc 0) '(face
> '(:foreground "gray")))
>
> (add-text-properties (- startc 2) (- endc 0) '(rear-nonsticky t) )
>
> (add-text-properties (- startc 2) (- endc 0) '(front-sticky t) )
>
>
>
> (setq startc (search-forward comm-start nil t))
>
> (setq endc (search-forward comm-end nil t))
>
> )
>
>
>
> (goto-char (point-min))
>
> (setq startc (search-forward slash2 nil t))
>
> (while startc
>
> (end-of-line)
>
> (add-text-properties (- startc 2 ) (point) '(face
> '(:foreground "gray")))
>
> (add-text-properties (- startc 2 ) (point) '(rear-nonsticky t) )
>
> (add-text-properties (- startc 2 ) (point) '(front-sticky t) )
>
>
>
> (setq startc (search-forward slash2 nil t))
>
> )
>
> (goto-char savepos)
>
> t
>
> )
Hello Stefan,
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++.
Actually, I wrote the commenting because font-lock-mode is too slow on large
C/C++ files.
Also, my real routine handles "modification" status and I use the
post-command-hook for real-time commenting as I type, all of which is
blistering fast running under Emacs 21.4.1 .
Under Emacs 24.3.1 linux "top" shows the %CPU at 100.0 for 5 seconds when I run
on 11,000 lines. There is no delay under Emacs 21.4.1 (running same code) as it
is instantaneous.
As an experiment, I built Gnu Emacs 22.3 from source on the same box and it has
the same slowness (taking 5 full seconds on 11,000 lines).
I guess I will have to live with this. I wonder if it has something to do with
the fact that the versions I built from source are slow? I know Emacs 21.4.1
came from the Redhat 5 installation procedure..
Joe
by using (buffer-modified-p) and resetting with (set-buffer-modified-p arg).