From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#38104: 27.0.50; elixir-mode fontification is very slow Date: Tue, 26 Nov 2019 20:32:29 +0100 Message-ID: <01F6BECA-B48A-4B8F-BFBC-1FBED482864F@acm.org> References: <3b0bfb66-437d-3606-dc06-05957f01b516@yandex.ru> <2ec58f9d-b979-7ad1-d53f-4cc454e50395@yandex.ru> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="37041"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 38104@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 26 20:33:39 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iZgag-0009Qt-Ic for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Nov 2019 20:33:38 +0100 Original-Received: from localhost ([::1]:58326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZgae-0005gi-DI for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Nov 2019 14:33:36 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35885) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZga9-0005gE-7x for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2019 14:33:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZga6-0007vn-S1 for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2019 14:33:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46991) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iZga5-0007uK-Qk for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2019 14:33:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iZga5-0000MG-Nd for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2019 14:33:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Nov 2019 19:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38104 X-GNU-PR-Package: emacs Original-Received: via spool by 38104-submit@debbugs.gnu.org id=B38104.15747967621345 (code B ref 38104); Tue, 26 Nov 2019 19:33:01 +0000 Original-Received: (at 38104) by debbugs.gnu.org; 26 Nov 2019 19:32:42 +0000 Original-Received: from localhost ([127.0.0.1]:52964 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iZgZm-0000Ld-0c for submit@debbugs.gnu.org; Tue, 26 Nov 2019 14:32:42 -0500 Original-Received: from mail1439c50.megamailservers.eu ([91.136.14.39]:59874 helo=mail264c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iZgZj-0000LP-EA for 38104@debbugs.gnu.org; Tue, 26 Nov 2019 14:32:40 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1574796753; bh=Se7w51RCXhcubQIOz58CrAmP0Xt97IpxFRZOuOXdiDE=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=VgPm77InMg/qov/PZpi3W8R2DuXFjWl5eaW59FTkQG9BXhavqecFX1DyFtb+sz6Zf RRb4vQJ3kWyhPTIyzxbxSS+iKoNYgP24RT+YOAb8ccviNnhyV4/gH4epxSd5zKrQz1 ZsOTlNBmt4mgzA+7FKw1TbjzW9ZpztoSwqYViw0o= Feedback-ID: mattiase@acm.or Original-Received: from stanniol.lan (c-3d4ce655.032-75-73746f71.bbcust.telenor.se [85.230.76.61]) (authenticated bits=0) by mail264c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id xAQJWUo6011511; Tue, 26 Nov 2019 19:32:32 +0000 In-Reply-To: <2ec58f9d-b979-7ad1-d53f-4cc454e50395@yandex.ru> X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B020A.5DDD7DD0.003D, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=ar3M9hRV c=1 sm=1 tr=0 a=2CSmQ8xxRPzqj0RSDwU2Pw==:117 a=2CSmQ8xxRPzqj0RSDwU2Pw==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=vaJtXVxTAAAA:8 a=fK-uz95lq1QNwa5CEh0A:9 a=CjuIK1q_8ugA:10 a=pHzHmUro8NiASowvMSCR:22 a=6VlIyEUom7LUIeUMNQJH:22 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.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" Xref: news.gmane.org gmane.emacs.bugs:172472 Archived-At: 26 nov. 2019 kl. 17.26 skrev Dmitry Gutov : > elixir-mode does use rx, heavily. Albeit with a thin wrapper. As it turned out, rx is fine (now); elixir-mode, not quite. In = elixir-mode.el, we have (identifiers . ,(rx (one-or-more (any "A-Z" "a-z" "_")) (zero-or-more (any "A-Z" "a-z" "0-9" "_")) (optional (or "?" "!")))) First, this regex is suboptimal: the first character of an identifier = should occur exactly once, or you get bad backtracking behaviour. Just = remove the one-or-more construct: (identifiers . ,(rx (any "A-Z" "a-z" "_") (zero-or-more (any "A-Z" "a-z" "0-9" "_")) (optional (or "?" "!")))) This definition is then used in several places, but two in particular = are of interest to us: ;; Module attributes (,(elixir-rx (and "@" (1+ identifiers))) The construct (1+ identifiers) was perhaps meant to match multiple = identifiers, but it doesn't (no separator); it just matches an = identifier in several ways, which again leads to bad backtracking = behaviour. The same problem here: ;; Map keys (,(elixir-rx (group (and (one-or-more identifiers) ":")) space) Remove the 1+ and one-or-more and it's fast again. Why did this "work" with the old rx implementation? Because that code = had a nasty bug: it does not bracket definitions in rx-constituents = properly. Example: (let ((rx-constituents (cons '(hello . "HELLO") rx-constituents))) (rx-to-string '(1+ hello) t)) =3D> "HELLO+" The new rx implementation does not suffer from this bug. The result in your case is that the old rx, when translating (1+ = identifiers), only tacked the "+" onto whatever regexp 'identifiers' = produced, resulting in "[A-Z_a-z]+[0-9A-Z_a-z]*[!?]?+" which is a lot faster, since only the final [!?] is repeated twice (and = it probably doesn't match very often).