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: Re: GNU Emacs 24 Performance Issues in 'add-text-properties Date: Thu, 4 Sep 2014 11:12:22 -0700 (PDT) Message-ID: <953e862c-6623-41be-b29e-5e07ff0af387@googlegroups.com> References: <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 1409854543 23657 80.91.229.3 (4 Sep 2014 18:15:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Sep 2014 18:15:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 04 20:15:37 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 1XPbZH-0006Jp-Tt for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Sep 2014 20:15:36 +0200 Original-Received: from localhost ([::1]:53481 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPbZH-0000WJ-DY for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Sep 2014 14:15:35 -0400 X-Received: by 10.224.14.82 with SMTP id f18mr3399234qaa.2.1409854342492; Thu, 04 Sep 2014 11:12:22 -0700 (PDT) X-Received: by 10.140.30.36 with SMTP id c33mr151403qgc.2.1409854342446; Thu, 04 Sep 2014 11:12:22 -0700 (PDT) Original-Path: usenet.stanford.edu!dc16no1170808qab.1!news-out.google.com!i10ni1qaf.0!nntp.google.com!dc16no1170803qab.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: <7a14bdfa-e253-440c-999c-1cccde9f5d52@googlegroups.com> 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: Thu, 04 Sep 2014 18:12:22 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:207366 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:99639 Archived-At: On Wednesday, September 3, 2014 4:19:23 PM UTC-4, joseph....@dowjones.com w= rote: > Hello All, >=20 >=20 >=20 > 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. B= elow is a simplified function I wrote many years ago to gray out C & C++ co= mments. I call it from find-file-hooks and other commands where I select a = buffer to edit. >=20 > =20 >=20 > In Gnu Emacs 21.4.1 this routine is blistering fast on a buffer of C++ co= de 11,000 lines long with lots of comments. Under Gnu Emacs 24.3.1 I experi= ence a long delay..=20 >=20 >=20 >=20 > If I comment out the calls to 'add-text-properties under 24.3.1, it is su= per fast, so the 'search-forward commands are not the bottleneck. =20 >=20 >=20 >=20 > It is the calls to 'add-text-properties causing the long delay. >=20 >=20 >=20 > The memory usage (virtual memory and physical memory) reported by ps aux = --sort=3D-rss,-rss looks normal for both versions (VirtMemory=3D150Mb and R= ss=3D30Mb) =20 >=20 >=20 >=20 > I'm running on a 16 Cpu box with 32 Gig ram, so I have plenty of horsepow= er. >=20 >=20 >=20 > Any help as to what can be causing this code to run so slow under Gnu Ema= cs 24 is greatly appreciated.=20 >=20 >=20 >=20 > Thanks In Advance=20 >=20 > Joe >=20 >=20 >=20 > =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 >=20 >=20 >=20 > (setq comm-start "/*" )=20 >=20 > (setq comm-end "*/" ) >=20 > (setq slash2 "//" ) >=20 >=20 >=20 > (defun mark-comments () ;; highlight all C comments... >=20 > (interactive) >=20 > =20 >=20 > (setq savepos (point)) >=20 > (goto-char (point-min)) >=20 > =20 >=20 > (setq startc (search-forward comm-start nil t)) >=20 > (setq endc (search-forward comm-end nil t)) >=20 > (while (and startc endc) >=20 > (add-text-properties (- startc 2) (- endc 0) '(face = '(:foreground "gray"))) >=20 > (add-text-properties (- startc 2) (- endc 0) '(rear-nonsticky= t) ) >=20 > (add-text-properties (- startc 2) (- endc 0) '(front-sticky t= ) ) >=20 >=20 >=20 > (setq startc (search-forward comm-start nil t)) >=20 > (setq endc (search-forward comm-end nil t)) >=20 > ) >=20 > =20 >=20 > (goto-char (point-min)) >=20 > (setq startc (search-forward slash2 nil t)) >=20 > (while startc >=20 > (end-of-line)=20 >=20 > (add-text-properties (- startc 2 ) (point) '(face '(= :foreground "gray"))) >=20 > (add-text-properties (- startc 2 ) (point) '(rear-nonsticky t)= ) >=20 > (add-text-properties (- startc 2 ) (point) '(front-sticky t) ) >=20 >=20 >=20 > (setq startc (search-forward slash2 nil t)) >=20 > ) >=20 > (goto-char savepos) >=20 > t >=20 > ) Hello Stefan,=20 Thanks for your response. This does work well with no interference from fon= t-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 larg= e C/C++ files. =20 Also, my real routine handles "modification" status and I use the post-comm= and-hook for real-time commenting as I type, all of which is blistering fas= t running under Emacs 21.4.1 .=20 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 co= de) 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).=20 I guess I will have to live with this. I wonder if it has something to do w= ith the fact that the versions I built from source are slow? I know Emacs = 21.4.1 came from the Redhat 5 installation procedure..=20 Joe=20 =20 by using (buffer-modified-p) and resetting with (set-buffer-modified-p ar= g). =20