all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* GNU Emacs 24 Performance Issues in  'add-text-properties
@ 2014-09-03 20:19 joseph.koziatek
  2014-09-04  2:45 ` Stefan Monnier
  2014-09-04 18:12 ` joseph.koziatek
  0 siblings, 2 replies; 4+ messages in thread
From: joseph.koziatek @ 2014-09-03 20:19 UTC (permalink / raw)
  To: help-gnu-emacs

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
) 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-04 20:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-03 20:19 GNU Emacs 24 Performance Issues in 'add-text-properties joseph.koziatek
2014-09-04  2:45 ` Stefan Monnier
2014-09-04 18:12 ` joseph.koziatek
2014-09-04 20:04   ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.