From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tom Gillespie Newsgroups: gmane.emacs.bugs Subject: bug#63622: lisp/progmodes/python.el: performance regression introduced by multiline font-lock Date: Sat, 20 May 2023 20:14:19 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14473"; mail-complaints-to="usenet@ciao.gmane.io" To: 63622@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 21 05:15:21 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q0ZXV-0003Yo-L6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 May 2023 05:15:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q0ZXE-0004tV-Ps; Sat, 20 May 2023 23:15:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q0ZXD-0004tC-Dx for bug-gnu-emacs@gnu.org; Sat, 20 May 2023 23:15:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q0ZXD-0001qn-3R for bug-gnu-emacs@gnu.org; Sat, 20 May 2023 23:15:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q0ZXC-0001T2-GA for bug-gnu-emacs@gnu.org; Sat, 20 May 2023 23:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tom Gillespie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 May 2023 03:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 63622 X-GNU-PR-Package: emacs X-Debbugs-Original-To: Emacs Bug Report Original-Received: via spool by submit@debbugs.gnu.org id=B.16846388785592 (code B ref -1); Sun, 21 May 2023 03:15:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 May 2023 03:14:38 +0000 Original-Received: from localhost ([127.0.0.1]:59761 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0ZWo-0001S7-9u for submit@debbugs.gnu.org; Sat, 20 May 2023 23:14:38 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:58576) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0ZWk-0001Ry-PQ for submit@debbugs.gnu.org; Sat, 20 May 2023 23:14:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q0ZWk-0004qW-1Z for bug-gnu-emacs@gnu.org; Sat, 20 May 2023 23:14:34 -0400 Original-Received: from mail-yb1-xb2f.google.com ([2607:f8b0:4864:20::b2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q0ZWi-0001nE-HR for bug-gnu-emacs@gnu.org; Sat, 20 May 2023 23:14:33 -0400 Original-Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-ba878d5e75fso6413201276.3 for ; Sat, 20 May 2023 20:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684638871; x=1687230871; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=aKX3lU9/IL3jNjlM/sihf/4MRR1Yf4y2vZrX5p6z7fE=; b=h8JnHWBDGZ2CzU2XhJcnU/wkdidX6iR992vGhHefm1My8XnuNIb/rUuwAVJwgHbUIw 5ocr8M/oICyNnpGZLj8UPXNdt+A8N4XIOOtcFEWX/7aT3AhZmkKUikoccy4wPUpUc7/i w4hbvytXJ9WGgCBx8hHVRgR8aH59PYAfqEvO5/XPeEGede/NuqwS4NoGmpm5SPU2qA+1 JVT39cl1aYo4zcf5dVg2nwE1l1ZkUt0N9/QYQdCUnw3sdwiHuTYe0JHgB4ChStB9oXF/ xjFdd8RIGA0v6hgPHJnCXybqH9idpWtz/LLBYETrwwaFh9/UzSEh+C+wHi6nmg/eIVzV EhBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684638871; x=1687230871; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=aKX3lU9/IL3jNjlM/sihf/4MRR1Yf4y2vZrX5p6z7fE=; b=ipfSklvVmMtKxjw61EwyHb2yfbS+Qod8r5QQVbWb0APD+DZJNsbcylRvQ1EmuCH254 yNDid8YQo/dE6bTQYXmrVEmPBeeWyKBcbgavgKj/R3l4ji4EKI5Ybd9MuS2R4YdzN7rz LjaAGQAlGVDVNNThiAKFI97dbdM7IMXR1S+dr21CqEM5FOCQwi2+dDd95OluvLwUy7Cm 2pXpmXnqEIWiK8LsUEgz6qTQavCfG/Sj94qgxC2hc2dqFDVywY+vgvF/qoF0C+FHcpr9 3IhmLcAmSVpC2HN5NddtHgYaibdaalMYtB7tK7yN6q1982sjHg4UxBNqbUm1l/RMJbS0 9dAQ== X-Gm-Message-State: AC+VfDySdgstzgO/0HXIv13yXuM5CnmPoNGjitAyXg7V4yfN9lKiLU1a wrcb3+3RkmoYxtELZWm6qhU0nNGgutJ4j9y+YRS7v8rm3ow= X-Google-Smtp-Source: ACHHUZ4r/sVcd2J43RqN+1SlcS+25H2Fi/HqVa8zKW2ZVahDAWGOdkEHK5DrvfLprKvUs+IgZKEpEu1dBvols2uF6nA= X-Received: by 2002:a25:b601:0:b0:ba8:373d:821a with SMTP id r1-20020a25b601000000b00ba8373d821amr6617726ybj.23.1684638870854; Sat, 20 May 2023 20:14:30 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::b2f; envelope-from=tgbugs@gmail.com; helo=mail-yb1-xb2f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:262077 Archived-At: The changes in 4915ca5dd4245a909c046e6691e8d4a1919890c8 have introduced a significant performance regression when editing python code that contains dictionary structures across multiple lines. The current behavior makes Emacs unusable when editing python dictionaries with more than 20 or so lines. I would suggest reverting the commit until the performance issue can be addressed. If I had to guess, this is probably being caused by a double zero-or-more pattern (possibly implicit) in the new regexps that were added/changed. The literal dictionary below is sufficient to demonstrate the issue and if you bisect and compare the behavior to the immediately prior commit 31e32212670f5774a6dbc0debac8854fa01d8f92 the difference is clear. Open the file and hit enter a couple of times and the lag is obvious (if you can't detect the issue try doubling the number of lines at the deepest nesting level from 25 to 50). By profiling and varying the number of repeated lines (e.g. by doubling them) it appears that the issue is some lurking quadratic behavior in syntax-ppss as a result of the changes in 4914ca. In my testing 25, 50, and 100 lines take 100ms, 800ms, and 5 seconds respectively to insert a new line while the cursor is inside the outer most paren. Collapsing all the structures into one line hides the issue. The longer each individual line the more rapid the slowdown. The example below is not syntactically correct python, however it highlights the issue in a way that is clearer than it would be otherwise. Examples that trigger the issue (repeat the 2nd line 50 or 100 times to see the effect). Any combination of paren types will cause the issue. The closing paren does not have to be present and does not prevent the issue. #+begin_src python ['' '' [] #+end_src #+begin_src python ['' [] '' #+end_src #+begin_src python ['' '' {} #+end_src #+begin_src python {'' '' () #+end_src #+begin_src python ["" '' [] #+end_src Examples that are do not cause the issue. #+begin_src python [a '' [] #+end_src #+begin_src python ['' '' a #+end_src #+begin_src python ['' '' '' #+end_src #+begin_src python [[] [] [] #+end_src #+begin_src python [[] [] '' #+end_src Example of syntactically correct python that causes the issue. #+begin_src python {'': { '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, '': {'': ''}, }, '': ['']} #+end_src