From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: kobarity Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Fix python-info-current-defun performance for large defuns Date: Tue, 05 Sep 2023 23:17:48 +0900 Message-ID: References: <83h6oa5fbd.fsf@gnu.org> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10313"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Cc: emacs-devel@gnu.org To: Tom Gillespie , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 05 16:26:37 2023 Return-path: Envelope-to: ged-emacs-devel@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 1qdX0m-0002Te-NO for ged-emacs-devel@m.gmane-mx.org; Tue, 05 Sep 2023 16:26:36 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdX0D-0003RC-DO; Tue, 05 Sep 2023 10:26:01 -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 1qdWsn-0000uN-4S for emacs-devel@gnu.org; Tue, 05 Sep 2023 10:18:21 -0400 Original-Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qdWsk-000742-QS; Tue, 05 Sep 2023 10:18:20 -0400 Original-Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-56c250ff3d3so2158171a12.1; Tue, 05 Sep 2023 07:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693923496; x=1694528296; darn=gnu.org; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=50LHTj95HTfUbigkS9Y2SaquWT6l2bhZUzJK6JOCy8U=; b=dwziTO3OOU11EhmdqQFXg7hJ8w8NCjDLCi5/rNF92NtlfFCt9ffk3FqI8j/iF/FlhA HLoH0XocZddz4107wkzb7WEAYXKViMPOXxfAE4KzPP8YGETY4DhWJp6T35JP0uLaUyET 96EvAesY02DClUBo6VEg7xN81oZ/qbit6T1LAGIvHRCKpmHnYnj6cIZy0bW15i1ZZkBS GR7vkOYfw9+u2ucUPwNe5XBCpjFUs2Dy3tL2GligrEBFz0iC4VEqo9hYBc4dn7xqWWRr lHSxsjF+RGQQneS7eRQ2eb8ukUmDut4HLz0CzJUrGHgF/TLML4xgpsMsuNPpCi/WisNr tN4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693923496; x=1694528296; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=50LHTj95HTfUbigkS9Y2SaquWT6l2bhZUzJK6JOCy8U=; b=FqgUAT+QYxfbDXngl0wrkoTWSrtjo1EqX2Hzy7YOTMbtWxgAAsq/XRvfWVv1oZ6Z8H Wv/QZjZ2o6+8RNoZ0fF7g9fTQ1bWdBbUDMbGuJhJLUoW2VlUP2NaB9eyoIRc4ZvlPZLs 5MinZ31FExhIGikveUW3ZibwPa5uW6P+npOZ9sce2jnfqCx9SwGiZqsG8elkrQit+tD3 TlpPCHy0nPYPv+l+hCPlAZwrqeP3bRza/SX/3Rcq4GfjDCF/P56lvwW7kIdnS5/BnSG2 fHgqPz0foAsyvVGEvDgHMn7gBvGyaVrVppIIpVdLq2dNomCZTBqdZjGupSi1ok8Fnlb1 VHaA== X-Gm-Message-State: AOJu0YwDooyKSb3IeOL2l2wJ68viKTIbRP82mTbdtsSOLMWoMIp/9V0i F2tFFXA0AF0rGbOqFuH10uU= X-Google-Smtp-Source: AGHT+IFqxNsTUSMPIgp/tUNMUAzWFxGn4U5bPZqEH6VGVaRqr2ZVfOyLAqjCKgF3+gBengRd3cFUBQ== X-Received: by 2002:a17:90b:38d0:b0:26b:2ba4:add8 with SMTP id nn16-20020a17090b38d000b0026b2ba4add8mr16762232pjb.21.1693923495960; Tue, 05 Sep 2023 07:18:15 -0700 (PDT) Original-Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id ck1-20020a17090afe0100b00262eb0d141esm9306630pjb.28.2023.09.05.07.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 07:18:15 -0700 (PDT) In-Reply-To: <83h6oa5fbd.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=kobarity@gmail.com; helo=mail-pg1-x533.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 05 Sep 2023 10:26:00 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:310131 Archived-At: Eli Zaretskii wrote: > > From: Tom Gillespie > > Date: Sun, 3 Sep 2023 18:37:34 -0700 > > > > Hi, > > Here is a patch to fix a performance issue in > > python-info-current-defun that appears when the function > > is run on large defuns. The issue can appear to the user as a > > noticeable (~500ms) freeze when the point is in a large defun > > in a python buffer with which-function-mode enabled. More > > details in the commit message and comments in the code. > > > > I made the patch against the emacs-29 branch, but will also > > on master without issue. > > Thanks. > > kobarity, any comments? Hi, Thank you for the patch. I have tried it and have confirmed that it improves performance. I think that not using the time-consuming `python-nav-end-of-defun' has helped. However, I found one unexpected behavior. The following code is an example added as an ERT: def a(): def b(): return if True: def c(): return if True: if True: def d(): return In this example, `python-info-current-defun' seems to return "a" if the point is on the second line from the bottom. Could you please take a look? My personal impression is that 114 characters per line is a bit long.