From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#64735: 29.0.92; find invocations are ~15x slower because of ignores Date: Fri, 21 Jul 2023 15:01:56 +0200 Message-ID: <87r0p1cta3.fsf@gmx.de> References: <1fd5e3ed-e1c3-5d6e-897f-1d5d55e379fa@gutov.dev> <87wmyupvlw.fsf@localhost> <5c4d9bea-3eb9-b262-138a-4ea0cb203436@gutov.dev> <87tttypp2e.fsf@localhost> <837cqu35lw.fsf@gnu.org> <87o7k6pmk3.fsf@localhost> <834jly351p.fsf@gnu.org> <87lefapkdx.fsf@localhost> <831qh230h5.fsf@gnu.org> <87wmyu8mi0.fsf@localhost> <83wmyu1l1k.fsf@gnu.org> <87fs5hemi1.fsf@gmx.de> <83edl11qzn.fsf@gnu.org> <874jlxebz5.fsf@gmx.de> <87lef9mqio.fsf@localhost> <87edl1scbw.fsf@gmx.de> <87fs5hmp6i.fsf@localhost> <87cz0lmoxy.fsf@localhost> <83v8edzb31.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9240"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: dmitry@gutov.dev, Ihor Radchenko , 64735@debbugs.gnu.org, sbaugh@janestreet.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 21 15:03:15 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 1qMpmr-00028R-ON for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Jul 2023 15:03:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMpmj-00081i-3d; Fri, 21 Jul 2023 09:03:06 -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 1qMpmg-00080p-Pw for bug-gnu-emacs@gnu.org; Fri, 21 Jul 2023 09:03:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qMpmg-00019o-CS for bug-gnu-emacs@gnu.org; Fri, 21 Jul 2023 09:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qMpmg-0000Zg-7G for bug-gnu-emacs@gnu.org; Fri, 21 Jul 2023 09:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Jul 2023 13:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64735 X-GNU-PR-Package: emacs Original-Received: via spool by 64735-submit@debbugs.gnu.org id=B64735.16899445412104 (code B ref 64735); Fri, 21 Jul 2023 13:03:02 +0000 Original-Received: (at 64735) by debbugs.gnu.org; 21 Jul 2023 13:02:21 +0000 Original-Received: from localhost ([127.0.0.1]:60885 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMpm0-0000Xr-QO for submit@debbugs.gnu.org; Fri, 21 Jul 2023 09:02:21 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:47201) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMplr-0000XA-QZ for 64735@debbugs.gnu.org; Fri, 21 Jul 2023 09:02:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1689944518; x=1690549318; i=michael.albinus@gmx.de; bh=CrA1BJulU/5ibdeCNbGQ+hDEjrXAKL3OmN0+uEZwIe0=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=miYFMKG5gh3Grf4LpJtNHCO3jBfhkcvxsWWzOx6a0XLJD1aUUeByXifYyfJuZoVKfTSPh2g 8jCFIibS1F4oLRelJbHaosuBME7RwB5IbibFyJB5FUiWlXyfG6pbJvG37VVDFiYQxDbglsVBw j207VPOyycm3Eyng0ZG/obwS8ahFt0ed6I4Wibgozxg5g/1TMA2cEXN+qmfu8Uj9tws/gNWKN 9CwJ1kuPZx86Ns6W3mX9ABsFo32Kd39q6k8RVPXvgtzfD+svSlg6bv3jmPV7v56xKkEUHJN0J R3yZm3406LWSx7Q0nyYukdifWS7cSQpr1n7LJGjn7xmbMKDFd0sQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.39.27]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MoO2E-1pY9xG0gXI-00ojoE; Fri, 21 Jul 2023 15:01:58 +0200 In-Reply-To: <83v8edzb31.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 21 Jul 2023 15:46:26 +0300") X-Provags-ID: V03:K1:rrfDIcNewcxn2AyGKRlVyVU0RKUnxdVBaiInX+Nual2vbMMsMy9 KwyoEZ5P0+Rc+fKFwiSKGw9MuSQMvTnga79OEVqCqo9JsG8NRRDFnynpl7j1RpRb2UN2Pfe s3pzhPf2HHCYbH7P0sLNpCS9e96U1PrQzS4DSK5cHsO1bNca6BRt3Gx7LiSJ8TdpSRV8X2e r+ktqDmzhBpYFHJsCmGBQ== UI-OutboundReport: notjunk:1;M01:P0:kO388ASvuTQ=;3l80Xhr7SG1qDsAAiN8b0MJNhV8 ghOcG6USDkQCO9AJo1aQ+i50QDZt1ngb06t2mpPldWFhio8bsGzCfV2GTa/05v3oHGwjXrQFd IRh5IKjga8xTS5CDwkOQ+xks3cYCOrBrnvpwHotqB2Qy1Y0J9U+Fd35jheOwC1Ny1At9cw7HI YLNKezDEb7JTkVPm6XlEsfKxT7cT2tcnxasiA9KhMD8KL4ZcIg5KVweK/iNZKBVSmAGOVytH8 ucmb1tOoZVQGQIr5TdNaa2cERPfeZLjyTJyikXD2RJOWiBhoaaJfvbYpPVgiLgT8hMYqTTllA 1s7xb/8fN1Tk5kc4jOSiVFWoFdSqc/85LKQvH9/nOaXGMpwGc60a3Tt5XSkcIg627sgyFmRSl PJt4d7/FaiXqouhakZMW8RTX9dgyNgnKZ3gVZfm8XseH+IowgwvQYBVCFjT7uiDrswv54QoTZ KCC2gsejjHAdFCS9TjNkU2Yi/K/nMfrwbbhI8whzUnQKV+gatMnBrmP02gHz1TJ51V2dEqAUn ZcuoWC78r0ZAZcm3HlB71CD3x9814SQN6AvdRzndObJtjnB35wqtRwfcUNpglSnZRK3cnC8nq IOV6M45IOEwkzU8vnWTJRwNEv2JuG2FP+Q4x7PF/AcmBRM4TEXuQwzUSPjFXdQfG+bhQJ1H1A dlWau/ClJU1MvY2dAeeDQHmjw1niQIAcdTnBJG098eCEHexv8TvASKvsCAYI1eRI+FJrwwqc4 8EMkbELVhTj8tvt2X6epOQeJ74TtSbQVg0yGvum10djAt2qdfGnP3mm8d8spkVOtpOlCEyaz 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:265700 Archived-At: Eli Zaretskii writes: >> From: Ihor Radchenko >> Cc: dmitry@gutov.dev, Eli Zaretskii , 64735@debbugs.gnu.o= rg, >> sbaugh@janestreet.com >> Date: Fri, 21 Jul 2023 12:25:29 +0000 >> >> Ihor Radchenko writes: >> >> > The question is: what is more costly >> > (a) matching complex regexp && call function or >> > (b) call function (lambda (fn) (when (and foo (match-string- ... fn))= ...)) >> >> (benchmark-run-compiled 10000000 (string-match-p (caar file-name-handle= r-alist) "/path/to/very/deep/file")) >> ;; =3D> (1.495432981 0 0.0) >> (benchmark-run-compiled 10000000 (funcall (lambda (fn) (and nil (string= -match-p (caar file-name-handler-alist) fn))) "/path/to/very/deep/file")) >> ;; =3D> (0.42053276500000003 0 0.0) >> >> Looks like even funcall overheads are not as bad as invoking regexp sea= rch. > > But "nil" is not a faithful emulation of the real test which will have > to be put there, is it? Here are some other numbers. The definition of inhibit-remote-files and without-remote-files is below. =2D-8<---------------cut here---------------start------------->8--- (length (directory-files-recursively "~/src" "")) 146121 =2D-8<---------------cut here---------------end--------------->8--- A sufficient large directory. =2D-8<---------------cut here---------------start------------->8--- (benchmark-run-compiled 1 (directory-files-recursively "~/src" "")) (38.133906724000006 13 0.5019186470000001) (benchmark-run-compiled 1 (let (file-name-handler-alist) (directory-files-= recursively "~/src" ""))) (32.944982886 13 0.5274874450000002) =2D-8<---------------cut here---------------end--------------->8--- There are indeed 5 sec overhead just for file name handler regexp checks. =2D-8<---------------cut here---------------start------------->8--- (benchmark-run-compiled 1 (without-remote-files (directory-files-recursive= ly "~/src" ""))) (33.261659676 13 0.5338916200000003) =2D-8<---------------cut here---------------end--------------->8--- Removing just the Tramp file name handlers comes near to let-binding file-name-handler-alist. =2D-8<---------------cut here---------------start------------->8--- (inhibit-remote-files) nil (benchmark-run-compiled 1 (directory-files-recursively "~/src" "")) (34.344226758000005 13 0.5421030509999998) =2D-8<---------------cut here---------------end--------------->8--- And that's for the innocents, which aren't aware of Tramp overhead, and which don't need it. As said, ~50% of Emacs users. Just adding (inhibit-remote-files) to .emacs gives them a performance boost. W/o touching any other code. =2D-8<---------------cut here---------------start------------->8--- ;;;###autoload (progn (defun inhibit-remote-files () "Deactivate remote file names." (interactive) (when (fboundp 'tramp-cleanup-all-connections) (funcall 'tramp-cleanup-all-connections)) (tramp-unload-file-name-handlers) (setq tramp-mode nil))) ;;;###autoload (progn (defmacro without-remote-files (&rest body) "Deactivate remote file names temporarily. Run BODY." (declare (indent 0) (debug ((form body) body))) `(let ((file-name-handler-alist (copy-tree file-name-handler-alist)) tramp-mode) (tramp-unload-file-name-handlers) ,@body))) =2D-8<---------------cut here---------------end--------------->8--- Best regards, Michael.