unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 39595@debbugs.gnu.org, jidanni@jidanni.org, pogonyshev@gmail.com,
	monnier@iro.umontreal.ca
Subject: bug#39595: #39595: M-x compile still very line-length weak
Date: Fri, 14 Feb 2020 23:47:43 +0100	[thread overview]
Message-ID: <7A842DF4-BACB-4CB2-A9DD-40AA57CA8DF0@acm.org> (raw)
In-Reply-To: <83tv3tnlx3.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 702 bytes --]

14 feb. 2020 kl. 18.00 skrev Eli Zaretskii <eliz@gnu.org>:

> Is there some forum where the relevant people could be asked about
> this?

Not sure where to go for that. The problem is really in Emacs's hacky implementation: when 'omake' is included in compilation-error-regexp-alist, many other regexps are rewritten in a way that makes them potentially slower. This is why it's not an ideal feature to have enabled by default.

Attached are two patches: one that anchors the regexp for Maven, and one that speeds up 'msft' and 'watcom' by eliminating the same repetition-after-repetition flaw in each (not much different from those found by the latest relint/xr scan posted to emacs-devel).


[-- Attachment #2: 0001-Speed-up-maven-compilation-error-message-regexp.patch --]
[-- Type: application/octet-stream, Size: 1756 bytes --]

From 3d589111903e823c9fab3a94e42a7339ad9edd89 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Fri, 14 Feb 2020 21:26:20 +0100
Subject: [PATCH 1/2] Speed up 'maven' compilation error message regexp

Anchor the regexp at line-start to prevent quadratic behaviour when
it doesn't match (bug#39595).

* lisp/progmodes/compile.el (compilation-error-regexp-alist-alist):
Rewrite 'maven' regexp, using rx for clarity.
---
 lisp/progmodes/compile.el | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 48ac85a73b..65c2978c9e 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -273,7 +273,23 @@ compilation-error-regexp-alist-alist
     ;; due to matching filenames via \\(.*?\\).  This might be faster.
     (maven
      ;; Maven is a popular free software build tool for Java.
-     "\\(\\[WARNING\\] *\\)?\\([^ \n]\\(?:[^\n :]\\| [^-/\n]\\|:[^ \n]\\)*?\\):\\[\\([0-9]+\\),\\([0-9]+\\)\\] " 2 3 4 (1))
+     ,(rx bol
+          (? (* " ")
+             "["
+             (or "ERROR" (group-n 1 "WARNING") (group-n 2 "INFO"))
+             "]"
+             (+ " "))
+          (group-n 3
+                   (not (any "\n "))
+                   (* (| (not (any "\n :"))
+                         (: " " (not (any "\n/-")))
+                         (: ":" (not (any "\n ["))))))
+          ":["
+          (group-n 4 (+ digit))
+          ","
+          (group-n 5 (+ digit))
+          "] ")
+     3 4 5 (1 . 2))
 
     (jikes-line
      "^ *\\([0-9]+\\)\\.[ \t]+.*\n +\\(<-*>\n\\*\\*\\* \\(?:Error\\|Warnin\\(g\\)\\)\\)"
-- 
2.21.1 (Apple Git-122.3)


[-- Attachment #3: 0002-Speed-up-msft-and-watcom-compilation-error-regexps.patch --]
[-- Type: application/octet-stream, Size: 1705 bytes --]

From 5d749520ddde466fd8ae5412ace567a7e6cc313b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Fri, 14 Feb 2020 23:38:24 +0100
Subject: [PATCH 2/2] Speed up 'msft' and 'watcom' compilation error regexps

They have similar structure, and both suffer from being able to
match leading spaces in multiple ways which leads to bad performance
when backtracking (bug#39595).

* lisp/progmodes/compile.el (compilation-error-regexp-alist-alist):
Improved 'msft' and 'watcom' regexps.
---
 lisp/progmodes/compile.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 65c2978c9e..79d2293e21 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -221,7 +221,7 @@ compilation-error-regexp-alist-alist
      ;; considered before EDG.
      ;; The message may be a "warning", "error", or "fatal error" with
      ;; an error code, or "see declaration of" without an error code.
-     "^ *\\([0-9]+>\\)?\\(\\(?:[a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) ?\
+     "^ *\\([0-9]+>\\)?\\(\\(?:[a-zA-Z]:\\)?[^ :(\t\n][^:(\t\n]*\\)(\\([0-9]+\\)) ?\
 : \\(?:see declaration\\|\\(?:warnin\\(g\\)\\|[a-z ]+\\) C[0-9]+:\\)"
      2 3 nil (4))
 
@@ -459,7 +459,7 @@ compilation-error-regexp-alist-alist
      "^\\([^, \n\t]+\\), line \\([0-9]+\\), char \\([0-9]+\\)[:., (-]" 1 2 3)
 
     (watcom
-     "^[ \t]*\\(\\(?:[a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)): ?\
+     "^[ \t]*\\(\\(?:[a-zA-Z]:\\)?[^ :(\t\n][^:(\t\n]*\\)(\\([0-9]+\\)): ?\
 \\(?:\\(Error! E[0-9]+\\)\\|\\(Warning! W[0-9]+\\)\\):"
      1 2 nil (4))
 
-- 
2.21.1 (Apple Git-122.3)


  reply	other threads:[~2020-02-14 22:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-13  5:51 bug#39595: M-x compile still very line-length weak 積丹尼 Dan Jacobson
2020-02-14 11:18 ` bug#39595: #39595: " Mattias Engdegård
2020-02-14 16:27   ` Mattias Engdegård
2020-02-14 17:00     ` Eli Zaretskii
2020-02-14 22:47       ` Mattias Engdegård [this message]
2020-02-15  7:35         ` Eli Zaretskii
2020-02-15 16:45           ` Mattias Engdegård
2020-02-16 12:15             ` Mattias Engdegård
2020-02-15  1:28 ` 積丹尼 Dan Jacobson
2020-02-15 13:57   ` Stefan Monnier
2020-02-16 15:37 ` 積丹尼 Dan Jacobson
2020-02-17 11:07   ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7A842DF4-BACB-4CB2-A9DD-40AA57CA8DF0@acm.org \
    --to=mattiase@acm.org \
    --cc=39595@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=jidanni@jidanni.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=pogonyshev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).