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: Sun, 23 Jul 2023 13:44:28 +0200 Message-ID: <875y6azwbn.fsf@gmx.de> References: <83v8edzb31.fsf@gnu.org> <87r0p1cta3.fsf@gmx.de> <87pm4ll7ox.fsf@localhost> <87a5vpcmc7.fsf@gmx.de> <878rb9l1f5.fsf@localhost> <87zg3pb6yt.fsf@gmx.de> <83zg3p9s39.fsf@gnu.org> <878rb944wi.fsf@localhost> <83tttx9q4v.fsf@gnu.org> <87pm4lb4fr.fsf@gmx.de> <83pm4l9n0o.fsf@gnu.org> <87jzutb14l.fsf@gmx.de> <83mszp9kl2.fsf@gnu.org> <83h6pwa52z.fsf@gnu.org> <87ilaci637.fsf@catern.com> <83sf9g88eh.fsf@gnu.org> <87cz0jj25g.fsf@catern.com> <83wmyr7sbq.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5779"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: yantar92@posteo.net, rms@gnu.org, sbaugh@catern.com, dmitry@gutov.dev, Eli Zaretskii , 64735@debbugs.gnu.org To: Spencer Baugh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 23 13:45:14 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 1qNXWU-0001J9-9a for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Jul 2023 13:45:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNXWL-0002DG-4q; Sun, 23 Jul 2023 07:45:05 -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 1qNXWI-0002Cm-K1 for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2023 07:45: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 1qNXWI-0001O6-AM for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2023 07:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qNXWI-00068N-6l for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2023 07:45: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: Sun, 23 Jul 2023 11:45: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.169011268623533 (code B ref 64735); Sun, 23 Jul 2023 11:45:02 +0000 Original-Received: (at 64735) by debbugs.gnu.org; 23 Jul 2023 11:44:46 +0000 Original-Received: from localhost ([127.0.0.1]:38848 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qNXW2-00067T-5x for submit@debbugs.gnu.org; Sun, 23 Jul 2023 07:44:46 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:50907) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qNXW0-00067F-2G for 64735@debbugs.gnu.org; Sun, 23 Jul 2023 07:44:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1690112670; x=1690717470; i=michael.albinus@gmx.de; bh=1a+NW7ugdQ/3HVhlZJk7ylEVb6Sfu4llkirb+q+P4rY=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=L7fc4sK8BfREX/qB5ZwEyO9WU/9v5K+h7Eri9Va7lt1SGKaqf0Z9iSJH58OmR66Gz5wSSDb AjDMo4Ny/d/9+cEW/nL9jaDUG1dh19tBoyUdv9GZxESh5wZCvndLcMTRDqQ32Ei7BKDDdeh/E FgQSZJzgs1PdJJ278Q6i/4wtUk9rTD6Sk+atnB9XfyY9NI9zfZjtmKEgi8e6YPIJMjcnbkGXE C/p6AGABrK9t3Y2seiTWslHdeDLnysG054o7auD8XCirjuE2hSYGCtu2zGlPE/NHQo9wslFc2 JZx5jbz2H/dvQ4Dj30lVKPGnSv/fshVB/2qoU+EugswX8OB2HywQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.39.27]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MKbg4-1qbv860BCu-00Kzqg; Sun, 23 Jul 2023 13:44:30 +0200 In-Reply-To: (Spencer Baugh's message of "Sat, 22 Jul 2023 16:53:05 -0400") X-Provags-ID: V03:K1:RtX3AJPAFvxVmGaea4ktSBDmAWhoCvKfotBeglCWyt8Cl7Tlkbn DZ+xaXWrGfpsmRexHmHxFM+yI4s6Ab211WHQFC1BJ3CgwOiB3yGOO/8gdG/eaYXt87/cd97 /DVpEQOeve8JNKsqxWWK37KJphLhuaRz5nscmuB5u1tKX1ovguN8Qe0C8ivOXfZuIVcrvPf owcfxAn2Ezy/C+wGBUYqQ== UI-OutboundReport: notjunk:1;M01:P0:3xh9gDaq5JU=;zjbC969cWaKqfEQ46b3/DnW1fJf t5q6oPu22QmvMgYpOUYZO772sEmHYTrdS9EZTuuHIEiS6r4XEjMc394lOqY/UZ2Yr6ZyNM3mX Ik3aq+3sK34ITMBzFGEVFJheVgjNte5xKbWgGeSaSx37vKJC/9/cFRQbHNKXky7Ze21ZsD0tM 1crfntNxTQnqgMMYEIlm98LuLI87RyJI9pZXGEjlRkSXlMi7/s1uSdA3J+al9Y73XVpg8qQ2Q RxJtgFMZzYrghjasbrmwoloZ38qsLqTtWBvBWAfsrXFX/vJ9BUQ31nzdrG5YG7FCQVIKmYGN1 UsVmRA+GdPs5cx8sz3zRftLRHV6OlfI3EI3cBIcBoNQeynEoAhBSHSgdVSUF5VWUJk34ZSGcR ROrXyLlzvPiZTCg8+dJOIQh490zo0NcGUTHQnxjYekgd5YEWLQusZVVB+auyPLaMh5lWfPqRO d7ph4oC5sBgh1jY9d01XKO0hSIkDKCjwxx5i3xqqVit5TW+haTUW2dnHuR2BspJO7t/f4OeEJ 2Yjk+geP/X9Xkik91nZn0WguZvwnB3KyoO9QBYCffcP/d+ZAtZAJUbxXauGddGoeTdjMQgjv9 HIozorDNtuCdIF8cODPH4SbiPYdNxktjNR3sfkd9599enZZRtEvps5ZUTsaVDoMU0X2KOvZXS jzCTLa53Gt9ZMyeb3dMayEdsAP/+5vsCEBZ5qz6K9wPmdhbEkbOuVS+8YLTY/DLJTIm2OY9K2 m6PgdiER44h+Mn0xkB6x6ueoL47WOX7NUw4ICNxoqtk+wR1ZjxrD/++LsiOIASLHUaavVHsG 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:265892 Archived-At: Spencer Baugh writes: Hi Spencer, > I mean having Emacs read output from the process and turn them into > strings while find is still running and walking the directory tree. So > the two parts are running in parallel. This, specifically: Just as POC, I have modified your function slightly that it runs with both local and remote directories. --8<---------------cut here---------------start------------->8--- (defun find-directory-files-recursively (dir regexp &optional include-directories _predicate follow-symlinks) (let* (buffered result (remote (file-remote-p dir)) (file-name-handler-alist (and remote file-name-handler-alist)) (proc (make-process :name "find" :buffer nil :connection-type 'pipe :noquery t :sentinel #'ignore :file-handler remote :filter (lambda (proc data) (let ((start 0)) (when-let ((end (string-search "\0" data start))) (push (concat buffered (substring data start end)) result) (setq buffered "") (setq start (1+ end)) (while-let ((end (string-search "\0" data start))) (push (substring data start end) result) (setq start (1+ end)))) (setq buffered (concat buffered (substring data start))))) :command (append (list "find" (file-local-name dir)) (if follow-symlinks '("-L") '("!" "(" "-type" "l" "-xtype" "d" ")")) (unless (string-empty-p regexp) "-regex" (concat ".*" regexp ".*")) (unless include-directories '("!" "-type" "d")) '("-print0") )))) (while (accept-process-output proc)) (if remote (mapcar (lambda (file) (concat remote file)) result) result))) --8<---------------cut here---------------end--------------->8--- This returns on my laptop --8<---------------cut here---------------start------------->8--- (my-bench 100 "~/src/tramp" "") (("built-in" . "Elapsed time: 99.177562s (3.403403s in 107 GCs)") ("with-find" . "Elapsed time: 83.432360s (2.820053s in 98 GCs)")) (my-bench 100 "/ssh:remotehost:~/src/tramp" "") (("built-in" . "Elapsed time: 128.406359s (34.981183s in 1850 GCs)") ("with-find" . "Elapsed time: 82.765064s (4.155410s in 163 GCs)")) --8<---------------cut here---------------end--------------->8--- Of course the other problems still remain. For example, you cannot know whether on a given host (local or remote) find supports all arguments. On my NAS, for example, we have --8<---------------cut here---------------start------------->8--- [~] # find -h BusyBox v1.01 (2022.10.27-23:57+0000) multi-call binary Usage: find [PATH...] [EXPRESSION] Search for files in a directory hierarchy. The default PATH is the current directory; default EXPRESSION is '-print' EXPRESSION may consist of: -follow Dereference symbolic links. -name PATTERN File name (leading directories removed) matches PATTERN. -print Print (default and assumed). -type X Filetype matches X (where X is one of: f,d,l,b,c,...) -perm PERMS Permissions match any of (+NNN); all of (-NNN); or exactly (NNN) -mtime TIME Modified time is greater than (+N); less than (-N); or exactly (N) days --8<---------------cut here---------------end--------------->8--- Best regards, Michael.