From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#52593: 28.0.90; (thing-at-point thing) has so much overhead since commit 7db376e560448e61485ba054def8c82b21f33d6a Date: Sat, 18 Dec 2021 09:48:40 +0200 Message-ID: <83zgoybbfr.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23781"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 52593@debbugs.gnu.org To: Kang Niu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 18 08:50:17 2021 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 1myUTw-00060J-KJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Dec 2021 08:50:16 +0100 Original-Received: from localhost ([::1]:58698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1myUTu-00038P-Gw for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Dec 2021 02:50:14 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myUTn-00037H-Kl for bug-gnu-emacs@gnu.org; Sat, 18 Dec 2021 02:50:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57898) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1myUTi-0004wS-EN for bug-gnu-emacs@gnu.org; Sat, 18 Dec 2021 02:50:07 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1myUTi-0000ij-AA for bug-gnu-emacs@gnu.org; Sat, 18 Dec 2021 02:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Dec 2021 07:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52593 X-GNU-PR-Package: emacs Original-Received: via spool by 52593-submit@debbugs.gnu.org id=B52593.16398137432697 (code B ref 52593); Sat, 18 Dec 2021 07:50:02 +0000 Original-Received: (at 52593) by debbugs.gnu.org; 18 Dec 2021 07:49:03 +0000 Original-Received: from localhost ([127.0.0.1]:41211 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1myUSk-0000hR-Jn for submit@debbugs.gnu.org; Sat, 18 Dec 2021 02:49:02 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60668) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1myUSg-0000gv-Gp for 52593@debbugs.gnu.org; Sat, 18 Dec 2021 02:49:00 -0500 Original-Received: from [2001:470:142:3::e] (port=39170 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myUSb-0004q6-8I; Sat, 18 Dec 2021 02:48:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=IRWGA78Fcxkm2PtRWU42z8xU3cYpT/6bBHte6B0rqgk=; b=oRkG1VAgjADc DSUZ2BmowS4wjeyDhL0LsI+qxGQfAIT1pJSm7xB4tRj4E2qnV7Pr3mY5WQUESVxXVWZ/BdD8tMpZr 0ekGpvRK277qGQ72Dny4ZJE9Uba+8hvKwOU7K+WKa/8PMAmzpKr9EdkwpqxMTxsClfRGTf0Lly/L8 /WAi6/fLm+zb+ZxbHeCEDmcCVO/SUvQJs4KsfrhByabmMxQx+q7LOGxXjMqTRplndpn4ykKjBLN+J P4kEibwDQkPOfN7gqNS4FMMCQTseW8j2LIcjOhI9heRBKBlOpCSC4IZiFl/+/cxAMFX1T6HwlWdQw b0UqWKRlCdGCZMSDigEmHg==; Original-Received: from [87.69.77.57] (port=4042 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myUSa-0007QP-Ku; Sat, 18 Dec 2021 02:48:53 -0500 In-Reply-To: (message from Kang Niu on Sat, 18 Dec 2021 13:59:24 +0800) 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" Xref: news.gmane.io gmane.emacs.bugs:222600 Archived-At: > From: Kang Niu > Date: Sat, 18 Dec 2021 13:59:24 +0800 > > 1. emacs -q > 2. Load a elpa package, symbol-overlay, which has symbol-overlay-post-command in post-command-hook > 3. Open a file buffer, enable symbol-overlay-mode > 4. Hold C-n, symbol-overlay-post-command will call thing-at-point frequently and the cpu profiler-report is as > follows > > Samples % Function > 29500 93% - symbol-overlay-post-command > 29497 93% - if > 29480 93% - string= > 29474 93% - symbol-overlay-get-symbol > 29471 93% - or > 29466 93% - thing-at-point > 29447 93% - save-restriction > 29129 92% narrow-to-region > 309 0% + let > 13 0% + symbol-overlay-remove-temp > 1388 4% + command-execute > 269 0% + redisplay_internal (C function) > 216 0% + ... > 191 0% + timer-event-handler > 20 0% + internal-timer-start-idle > 15 0% jit-lock--antiblink-post-command > 11 0% + undo-auto--add-boundary > 4 0% + clear-minibuffer-message > > The cpu profiler-report of the same process with thingatpt.el before commit > 7db376e560448e61485ba054def8c82b21f33d6a is as follows: > > Samples % Function > 3859 42% + redisplay_internal (C function) > 2895 31% + command-execute > 892 9% + ... > 689 7% + timer-event-handler > 618 6% - symbol-overlay-post-command > 611 6% - if > 576 6% - string= > 563 6% - symbol-overlay-get-symbol > 563 6% - or > 557 6% - thing-at-point > 557 6% - let > 545 5% - cond > 510 5% - let > 493 5% - bounds-of-thing-at-point > 493 5% - if > 478 5% - let > 471 5% - condition-case > 471 5% - progn > 451 4% - save-excursion > 261 2% + funcall > 182 2% + let > 4 0% get Thanks. The NEWS entry about the change you mention says the feature of respecting fields in thing-at-point is only active when the buffer uses fields. The implementation uses (save-restriction (narrow-to-region (field-beginning) (field-end)) AFAICT, field-beginning returns BOB and field-end returns EOB, when there are no fields in the buffer. Looking at the code of narrow-to-region, I see that it basically does very little when called with BOB and EOB as its arguments. So it is strange that narrow-to-region takes such a large percent of CPU time in the profile. If you make narrow-to-region return immediately when called with BOB and EOB, does the profile change in any way?