From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#47419: 27.1; Misleading profiler info Date: Fri, 26 Mar 2021 21:55:05 -0400 Message-ID: References: <61UDKwhxkYX18O3D1KM_95yXHL-aAqQ8EFR-k0xhF9q3PGOhe2o2USottxht6UbCzZ_D0eDD7xLB0jI28-04XeW4N2s3iLnil176fW89rC0=@protonmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33304"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 47419@debbugs.gnu.org To: scame Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 27 02:56:16 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 1lPyBS-0008W2-E8 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Mar 2021 02:56:14 +0100 Original-Received: from localhost ([::1]:51088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPyBR-0004Br-04 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 26 Mar 2021 21:56:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPyBG-0004BQ-2A for bug-gnu-emacs@gnu.org; Fri, 26 Mar 2021 21:56:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lPyBF-0006gE-Qj for bug-gnu-emacs@gnu.org; Fri, 26 Mar 2021 21:56:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lPyBF-00083i-QO for bug-gnu-emacs@gnu.org; Fri, 26 Mar 2021 21:56:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Mar 2021 01:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47419 X-GNU-PR-Package: emacs Original-Received: via spool by 47419-submit@debbugs.gnu.org id=B47419.161681011730920 (code B ref 47419); Sat, 27 Mar 2021 01:56:01 +0000 Original-Received: (at 47419) by debbugs.gnu.org; 27 Mar 2021 01:55:17 +0000 Original-Received: from localhost ([127.0.0.1]:43045 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPyAW-00082c-Ri for submit@debbugs.gnu.org; Fri, 26 Mar 2021 21:55:17 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:24017) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPyAV-00082K-CW; Fri, 26 Mar 2021 21:55:15 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 2411C100241; Fri, 26 Mar 2021 21:55:09 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 11F8310021B; Fri, 26 Mar 2021 21:55:07 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1616810107; bh=jK3wqFkQXUY+VYDxgJoFmi+F6PPOmpFU+SrBbwNfOH8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=ka3SikSWfkigUMf9ONJmDX66VckwC3mVLCkuCRxCHLNmePAk+G7BHei4eSTTU2YO/ sgPW2o/cTP3dFlx75NTkuyFEkICrptCUto9AGSO8x3v0AIBnwhjjWNUGJUxpOWWywZ W8634QG09V0TeKQ7wRLjVyNc1dEkEzn6cCXWSrS5Tekvv7rP4mvDHIh37Qzmh6Y3zQ gKOOb9x/yr6Tbtp7opyR5px/+dp7oLZGq3GKMTkKcA6PFKRYop7Qq4uurFINexLsBB opS3rTMQj0tfuRMfysVnTADKm8BCJ9GBRIrFokljRN3UId/ur+lXJWuav312ggItby lwHmW4uN6iP6Q== Original-Received: from alfajor (unknown [216.154.43.249]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id BEC41120232; Fri, 26 Mar 2021 21:55:06 -0400 (EDT) In-Reply-To: <61UDKwhxkYX18O3D1KM_95yXHL-aAqQ8EFR-k0xhF9q3PGOhe2o2USottxht6UbCzZ_D0eDD7xLB0jI28-04XeW4N2s3iLnil176fW89rC0=@protonmail.com> (scame's message of "Fri, 26 Mar 2021 19:56:53 +0000") 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:203091 Archived-At: retitle 47419 Misleading profiler info thanks > As discussed on emacs-help=A0 I'm posting this example here which > reorders the file and runs slowly. [ Right, but the issue was with the profiler info. ] > Though it's an sql dump file with long lines, the file is navigable witho= ut > any problem or slowness. Only this snippet runs slowly. I think I can explain to you why it's going slow: > (re-search-backward (concat "INSERT INTO `test1`.+" > "VALUES (" > item > ",")) The ".+" will first match the whole long rest of the line, after which the regexp matcher will try to match "VALUES (item,", which will fail, so the matcher will go back trying with .+ matching one char less, and try to match "VALUES (item," again, etc for every char on the long line. You can speed it up significantly by tightening the regexp, e.g. replacing .+ with [\s\t]+. It's still not superfast because our regexp engine is not tuned for that kind of situation, but it's better. > And the example file to run it on is attached. (anonymized sql dump) And the real problem (the one for which I wanted the bug report) is that the profiler indeed gives a bogus profile (see below) where `re-search-backwards` doesn't appear at all and all the time is attributed to `save-excursion` instead. -- Stefan 16896 99% - command-execute 16896 99% - call-interactively 16844 99% - funcall-interactively 16812 99% - ielm-return 16812 99% - ielm-send-input 16810 99% - ielm-eval-input 16810 99% - eval 16810 99% - progn 16810 99% - when 16810 99% - if 16808 99% - progn 16808 99% - while 16808 99% - let 16784 99% save-excursion 2 0% - comint-send-input 2 0% - run-hook-with-args 1 0% - ansi-color-process-output 1 0% ansi-color-apply-on-region 1 0% comint-postoutput-scroll-to-bottom 26 0% - minibuffer-complete 26 0% - completion-in-region 26 0% - completion--in-region 26 0% - # 26 0% - apply 26 0% - # 26 0% - completion--in-region-1 26 0% - completion--do-completion 16 0% - completion-try-completion 16 0% - completion--nth-completion 16 0% - completion--some 16 0% - # 8 0% - completion-basic-try-completion 8 0% - try-completion 8 0% - # 8 0% complete-with-action 8 0% - completion-pcm-try-completion 8 0% - completion-pcm--find-all-completions 8 0% - completion-pcm--all-completions 8 0% - all-completions 8 0% - # 8 0% complete-with-action 10 0% - minibuffer-completion-help 6 0% - completion-all-completions 6 0% - completion--nth-completion 6 0% - completion--some 6 0% - # 3 0% - completion-basic-all-completions 3 0% - completion-pcm--all-completions 3 0% - all-completions 3 0% - # 3 0% complete-with-action 3 0% - completion-pcm-all-completions 3 0% - completion-pcm--find-all-completions 3 0% - completion-pcm--all-completions 3 0% - all-completions 3 0% - # 3 0% complete-with-action 4 0% - temp-buffer-window-show 4 0% - display-buffer 2 0% - display-buffer-at-bottom 1 0% - walk-window-tree 1 0% - walk-window-tree-1 1 0% - walk-window-tree-1 1 0% - # 1 0% window-in-direction 1 0% - window-main-window 1 0% - walk-window-tree 1 0% walk-window-tree-1 2 0% - display-buffer-reuse-window 1 0% - window--display-buffer 1 0% - # 1 0% - display-completion-list 1 0% - run-hooks 1 0% - completion-setup-function 1 0% substitute-command-keys 1 0% window--maybe-raise-frame 6 0% - execute-extended-command 4 0% - sit-for 4 0% - redisplay 1 0% - redisplay_internal (C function) 1 0% - funcall 1 0% - # 1 0% - gui-backend-selection-exists-p 1 0% - apply 1 0% # 1 0% - command-execute 1 0% - call-interactively 1 0% - funcall-interactively 1 0% profiler-report 52 0% - byte-code 52 0% - read-extended-command 52 0% - completing-read 52 0% - completing-read-default 34 0% - read-from-minibuffer 1 0% - timer-event-handler 1 0% - apply 1 0% # 1 0% - redisplay_internal (C function) 1 0% - eval 1 0% if 50 0% - ... 50 0% Automatic GC 3 0% - timer-event-handler 3 0% - apply 2 0% - # 1 0% - comint-output-filter 1 0% - run-hook-with-args 1 0% comint-postoutput-scroll-to-bottom 1 0% redisplay 1 0% - blink-cursor-start 1 0% add-hook