From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#16786: 24.2; PostScript file with long lines locks up UI Date: Mon, 17 Feb 2014 21:15:54 -0500 Message-ID: References: <21250.32840.43915.833076@guava.gson.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1392689834 31908 80.91.229.3 (18 Feb 2014 02:17:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Feb 2014 02:17:14 +0000 (UTC) Cc: 16786@debbugs.gnu.org To: Andreas Gustafsson Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 18 03:17:21 2014 Return-path: Envelope-to: geb-bug-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 1WFaFM-00005R-Nj for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Feb 2014 03:17:20 +0100 Original-Received: from localhost ([::1]:45683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFaFM-0000pK-8y for geb-bug-gnu-emacs@m.gmane.org; Mon, 17 Feb 2014 21:17:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFaFC-0000pD-8c for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2014 21:17:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFaF4-0006p1-NI for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2014 21:17:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFaF4-0006ox-Jq for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2014 21:17:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WFaF3-0002OW-Pu for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2014 21:17:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Feb 2014 02:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16786 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 16786-submit@debbugs.gnu.org id=B16786.13926897639117 (code B ref 16786); Tue, 18 Feb 2014 02:17:01 +0000 Original-Received: (at 16786) by debbugs.gnu.org; 18 Feb 2014 02:16:03 +0000 Original-Received: from localhost ([127.0.0.1]:57324 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WFaE6-0002My-Qb for submit@debbugs.gnu.org; Mon, 17 Feb 2014 21:16:03 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:42466) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WFaE5-0002MH-0d for 16786@debbugs.gnu.org; Mon, 17 Feb 2014 21:16:01 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFLd/lO/2dsb2JhbABEuzWDWRdzgh8BBVYjEAsOJhIUGA0kiCTBLZEKA4hhnBmBXoMV X-IPAS-Result: Av8EABK/CFFLd/lO/2dsb2JhbABEuzWDWRdzgh8BBVYjEAsOJhIUGA0kiCTBLZEKA4hhnBmBXoMV X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="47913032" Original-Received: from 75-119-249-78.dsl.teksavvy.com (HELO pastel.home) ([75.119.249.78]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 17 Feb 2014 21:15:55 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id E415661186; Mon, 17 Feb 2014 21:15:54 -0500 (EST) In-Reply-To: <21250.32840.43915.833076@guava.gson.org> (Andreas Gustafsson's message of "Mon, 17 Feb 2014 23:34:00 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:85804 Archived-At: > (progn > (switch-to-buffer "test") > (insert (make-string 100000 97)) > (ps-mode) > ) For this test, the main bottleneck seems to be the ("([^()\n%]*\\|[^()\n]*)" . font-lock-warning-face) rule in ps-mode-font-lock-keywords-1. The problem is the second half of the regexp, which will take O(N) time to fail to match at a particular position and which will try matching at every buffer position, for a total of O(N^2). This can be fixed by anchoring the search, e.g. with the patch below. Of course, a small variation of the above test leads to other bottlenecks. Stefan === modified file 'lisp/progmodes/ps-mode.el' --- lisp/progmodes/ps-mode.el 2014-01-08 18:28:43 +0000 +++ lisp/progmodes/ps-mode.el 2014-02-18 02:10:59 +0000 @@ -220,7 +220,8 @@ (ps-mode-match-string-or-comment (1 font-lock-comment-face nil t) (2 font-lock-string-face nil t)) - ("([^()\n%]*\\|[^()\n]*)" . font-lock-warning-face) + ("\\(([^()\n%]*\\)\\|\\(?:^\\|[()]\\)\\(?1:[^()\n]*)\\)" + (1 font-lock-warning-face)) ("[\200-\377]+" (0 font-lock-warning-face prepend nil))) "Subdued level highlighting for PostScript mode.")