From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joseph.koziatek@dowjones.com Newsgroups: gmane.emacs.help Subject: GNU Emacs 24 Performance Issues in 'add-text-properties Date: Wed, 3 Sep 2014 13:19:23 -0700 (PDT) Message-ID: <7a14bdfa-e253-440c-999c-1cccde9f5d52@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1409776219 14591 80.91.229.3 (3 Sep 2014 20:30:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 3 Sep 2014 20:30:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Sep 03 22:30:12 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XPHC0-0008MU-Iy for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Sep 2014 22:30:12 +0200 Original-Received: from localhost ([::1]:47607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPHC0-0005Dk-2v for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Sep 2014 16:30:12 -0400 X-Received: by 10.182.91.43 with SMTP id cb11mr25467155obb.13.1409775563663; Wed, 03 Sep 2014 13:19:23 -0700 (PDT) X-Received: by 10.140.27.140 with SMTP id 12mr87181qgx.19.1409775563529; Wed, 03 Sep 2014 13:19:23 -0700 (PDT) Original-Path: usenet.stanford.edu!r2no13790244igi.0!news-out.google.com!q8ni10qal.1!nntp.google.com!m5no5564412qaj.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=205.203.130.22; posting-account=-o2QsAoAAADaaxdBWIzwf7pWGoMlXXiW Original-NNTP-Posting-Host: 205.203.130.22 User-Agent: G2/1.0 Injection-Date: Wed, 03 Sep 2014 20:19:23 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:207352 X-Mailman-Approved-At: Wed, 03 Sep 2014 16:29:59 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:99630 Archived-At: 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. Bel= ow is a simplified function I wrote many years ago to gray out C & C++ comm= ents. I call it from find-file-hooks and other commands where I select a bu= ffer to edit. =20 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 experien= ce a long delay..=20 If I comment out the calls to 'add-text-properties under 24.3.1, it is supe= r fast, so the 'search-forward commands are not the bottleneck. =20 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=3D-rss,-rss looks normal for both versions (VirtMemory=3D150Mb and Rss= =3D30Mb) =20 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.=20 Thanks In Advance=20 Joe =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (setq comm-start "/*" )=20 (setq comm-end "*/" ) (setq slash2 "//" ) (defun mark-comments () ;; highlight all C comments... (interactive) =20 (setq savepos (point)) (goto-char (point-min)) =20 (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)) ) =20 (goto-char (point-min)) (setq startc (search-forward slash2 nil t)) (while startc (end-of-line)=20 (add-text-properties (- startc 2 ) (point) '(face '(:f= oreground "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 )=20