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: Sun, 21 May 2023 00:13:36 -0700 Message-ID: References: <83zg5yqkr1.fsf@gnu.org> 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="22405"; mail-complaints-to="usenet@ciao.gmane.io" Cc: kobarity , Stefan Monnier , 63622@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 21 09:14:41 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 1q0dH7-0005dc-1u for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 May 2023 09:14:41 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q0dGd-0002GQ-Ug; Sun, 21 May 2023 03:14:11 -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 1q0dGV-0002GB-OF for bug-gnu-emacs@gnu.org; Sun, 21 May 2023 03:14:04 -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 1q0dGV-0000xf-8N for bug-gnu-emacs@gnu.org; Sun, 21 May 2023 03:14:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q0dGU-0000Ql-I5 for bug-gnu-emacs@gnu.org; Sun, 21 May 2023 03:14: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 07:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63622 X-GNU-PR-Package: emacs Original-Received: via spool by 63622-submit@debbugs.gnu.org id=B63622.16846532351634 (code B ref 63622); Sun, 21 May 2023 07:14:02 +0000 Original-Received: (at 63622) by debbugs.gnu.org; 21 May 2023 07:13:55 +0000 Original-Received: from localhost ([127.0.0.1]:59953 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0dGN-0000QI-2Q for submit@debbugs.gnu.org; Sun, 21 May 2023 03:13:55 -0400 Original-Received: from mail-yw1-f177.google.com ([209.85.128.177]:61598) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0dGL-0000Q1-Hi for 63622@debbugs.gnu.org; Sun, 21 May 2023 03:13:54 -0400 Original-Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-561f10b6139so31015477b3.2 for <63622@debbugs.gnu.org>; Sun, 21 May 2023 00:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684653227; x=1687245227; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WezCPdWpUWZCisNsFJ0VfoJBn9jsntHVHs2REFPakgQ=; b=fzUqfNRFFkq+NxFkkO+GCojeuGrpnz/jwK+a2hgtI9wUS3WZW84TPdQWso6PIO/k+s VQjZ3xkfqaI4MJhOV8N1vCQawqV7o4eFjRl6bfG7T3eZpagWfTL8nYdzTYp9XewecOhv q0sQvj46eUmjn14CzWo5SqEpiKOdooB8Z0ieGHgrCOG649mE3ROJxDGxBk9QTA2OrfwS KWzNkiVZkZZUQRyy3fxBT2ZlOoNjTAqm+x4trpA7V4IVYm2fSZiX8PcnMRHbKISS/G4F JDAeebOg6hCIWtrWNf0Et6JzHRArNk7nbpRIVAmZBclsO6qDqhkYnARjz7ncZLqnv/y1 CyTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684653227; x=1687245227; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WezCPdWpUWZCisNsFJ0VfoJBn9jsntHVHs2REFPakgQ=; b=byhLtPBeoG1B7xAAwfRr+X6j2Yuuzs8NZKP8C+KPQatf3aTrdN6TAIZQEEpnbdHklW VqZCi9RK6mij+cl36SOdqRBZNEWTTIscyyN4bOw8Bav2bXhEqzrIfEmrYP78MRLeQqRQ b5giuIliP0gzMioNf938Rk3IAEcSzrQAyKK5gbQ/VbmXCH9z348FWZ6m07ANIbRAXvp1 K73zWNAbLiMwCbQ+PSyAzM7v5vjcsGN6W458bXmuA+wZO6n4WMXJ8UH1+YKRYBJczH6n 266Qyenc6VJedQMP8xIqH4RUIObuf/i9aTQpF6w7+LkAP00U1S9wfYXemm669M7LiTuA 77sg== X-Gm-Message-State: AC+VfDyMd3KHLfWddwD3hre5ZkCkSnBXaEcCSvIIm09ddQcK4xr4VunE lizK47ATJP77bfqXoI8EznUKDzT5vzMHe0Suqhs= X-Google-Smtp-Source: ACHHUZ7kX4Q8xzETvh2tr4bq9X0lrt5lIZDBGe1H6VNyWNIcxHFtS5SPscV2u7pFPd6vnBDWrWUjOZriBkysHrMGs8c= X-Received: by 2002:a81:8787:0:b0:561:b58e:31ff with SMTP id x129-20020a818787000000b00561b58e31ffmr6858120ywf.44.1684653227618; Sun, 21 May 2023 00:13:47 -0700 (PDT) In-Reply-To: <83zg5yqkr1.fsf@gnu.org> 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:262089 Archived-At: > If the problem is so severe, I wonder how come this comes up only now, > 9 months after those changes were installed. It probably means these > cases are quite rare in practice. Nevertheless, it would be good to > solve them, of course. I suspect it is because there are 3 factors that have to be just right to notice. 1 the opening paren and the quote must be immediately adjacent to get exceptionally bad behavior, there is still some performance degradation when there is separation, but it would be harder to notice. 2 a user would have to directly edit a dictionary literal with enough lines to notice the slowdown. 3 assigning the dictionary to a variable mitigates the issue, so only a dict that is not assigned results in the full slowdown. > FWIW, python-ts-mode doesn't show performance issues in the examples > you posted. I would imagine so. I've continued trying to hunt down the source of the issue, and it is triggered by setting python-font-lock-extend-region as the font-lock-extend-after-change-region-function function for python this is true in old versions of Emacs (e.g. 28.2) as well. As far as I can tell the existing implementation for python font locking has some quadratic behavior that is revealed when a region is extended inside a nested dictionary with multiple lines. > Any chance of your posting some real-life Python code where the issue > rears its head? I mean, real-life code that makes sense, not just > syntactically correct code invented to make a point? Yep, basically any nested dictionary literal with more than 15 lines is affected. With a note that the issue is masked if there is an equal sign (=) before the opening paren, which is the common case. An example of the particular file that caused me to spot the issue: https://github.com/tgbugs/pyontutils/blob/master/pyontutils/auth-config.py > P.S. Tom, please don't change the Subject when posting followups, > please use the same Subject for all your messages that discuss this > bug. Ack, apologies. I will keep it the same in the future. > Also, for the record, please state which Emacs version are you using. > You didn't use "M-x report-emacs-bug" to submit the bug report, so > this and other important information is missing from your OP. Ok, I wasn't sure how to handle it in this case since I was able to reproduce the issue in multiple versions. For the record: The version I spotted it on was the emacs-29 branch at 3bc5efb87e5ac9b7068e71307466b2d0220e92fb but everything on emacs-29 after 4915ca5dd4245a909c046e6691e8d4a1919890c8 is affected (according to git bisect results). So 29.0.90 and 29.0.91 should be affected as well.