unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp
@ 2019-07-30 17:20 Eric Abrahamsen
  2019-07-30 18:44 ` Dmitry Gutov
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Abrahamsen @ 2019-07-30 17:20 UTC (permalink / raw)
  To: 36857


This is a proper bug report for an issue I raised on emacs.devel:

When marking multiple files in Dired, then running a search with
`dired-do-find-regexp', `xref-collect-matches' is called once per marked
file, when it could just be called once for the whole search. This can
slow things down quite a bit.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp
  2019-07-30 17:20 bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp Eric Abrahamsen
@ 2019-07-30 18:44 ` Dmitry Gutov
  2019-07-30 18:45   ` Dmitry Gutov
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2019-07-30 18:44 UTC (permalink / raw)
  To: Eric Abrahamsen, 36857

On 30.07.2019 20:20, Eric Abrahamsen wrote:
> When marking multiple files in Dired

Could you estimate how many files you need to mark for this to become a 
problem? I'm really curious.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp
  2019-07-30 18:44 ` Dmitry Gutov
@ 2019-07-30 18:45   ` Dmitry Gutov
  2019-07-30 18:56     ` Eric Abrahamsen
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2019-07-30 18:45 UTC (permalink / raw)
  To: Eric Abrahamsen, 36857

On 30.07.2019 21:44, Dmitry Gutov wrote:
> On 30.07.2019 20:20, Eric Abrahamsen wrote:
>> When marking multiple files in Dired
> 
> Could you estimate how many files you need to mark for this to become a 
> problem? I'm really curious.

Never mind, saw your reply on emacs-devel. 200-300 is a respectable amount.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp
  2019-07-30 18:45   ` Dmitry Gutov
@ 2019-07-30 18:56     ` Eric Abrahamsen
  2019-07-31 14:06       ` Dmitry Gutov
  2019-12-25 16:31       ` Dmitry Gutov
  0 siblings, 2 replies; 9+ messages in thread
From: Eric Abrahamsen @ 2019-07-30 18:56 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 36857

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 30.07.2019 21:44, Dmitry Gutov wrote:
>> On 30.07.2019 20:20, Eric Abrahamsen wrote:
>>> When marking multiple files in Dired
>>
>> Could you estimate how many files you need to mark for this to
>> become a problem? I'm really curious.
>
> Never mind, saw your reply on emacs-devel. 200-300 is a respectable amount.

Does "respectable" mean "quite a few" or "a number we should be able to
handle without significant slowdowns"? :)





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp
  2019-07-30 18:56     ` Eric Abrahamsen
@ 2019-07-31 14:06       ` Dmitry Gutov
  2019-07-31 15:56         ` Eric Abrahamsen
  2019-12-25 16:31       ` Dmitry Gutov
  1 sibling, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2019-07-31 14:06 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 36857

On 30.07.2019 21:56, Eric Abrahamsen wrote:

>> Never mind, saw your reply on emacs-devel. 200-300 is a respectable amount.
> 
> Does "respectable" mean "quite a few" or "a number we should be able to
> handle without significant slowdowns"? :)

Hopefully both. :-)

I have an improvement in mind that would fix it, but there are a couple 
change I'll need to make in a related area (project.el) first, so please 
stay tuned.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp
  2019-07-31 14:06       ` Dmitry Gutov
@ 2019-07-31 15:56         ` Eric Abrahamsen
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Abrahamsen @ 2019-07-31 15:56 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 36857

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 30.07.2019 21:56, Eric Abrahamsen wrote:
>
>>> Never mind, saw your reply on emacs-devel. 200-300 is a respectable amount.
>>
>> Does "respectable" mean "quite a few" or "a number we should be able to
>> handle without significant slowdowns"? :)
>
> Hopefully both. :-)
>
> I have an improvement in mind that would fix it, but there are a
> couple change I'll need to make in a related area (project.el) first,
> so please stay tuned.

Cool, thanks!





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp
  2019-07-30 18:56     ` Eric Abrahamsen
  2019-07-31 14:06       ` Dmitry Gutov
@ 2019-12-25 16:31       ` Dmitry Gutov
  2019-12-25 21:46         ` Eric Abrahamsen
  1 sibling, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2019-12-25 16:31 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 36857

[-- Attachment #1: Type: text/plain, Size: 95 bytes --]

Hi Eric,

Please try the attached patch. It should cut down on the number of 
process calls.



[-- Attachment #2: dired-do-find-regexp-speedup.diff --]
[-- Type: text/x-patch, Size: 1585 bytes --]

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index fb1ad6266d..0fb8839a3f 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -2975,19 +2975,24 @@ dired-do-find-regexp
   (require 'xref)
   (defvar grep-find-ignored-files)
   (declare-function rgrep-find-ignored-directories "grep" (dir))
-  (let* ((files (dired-get-marked-files nil nil nil nil t))
+  (let* ((marks (dired-get-marked-files nil nil nil nil t))
          (ignores (nconc (mapcar
                           #'file-name-as-directory
                           (rgrep-find-ignored-directories default-directory))
                          grep-find-ignored-files))
          (fetcher
           (lambda ()
-            (let ((xrefs (mapcan
-                          (lambda (file)
-                            (xref-collect-matches regexp "*" file
-                                                  (and (file-directory-p file)
-                                                       ignores)))
-                          files)))
+            (let (files xrefs)
+              (mapc
+               (lambda (mark)
+                 (if (file-directory-p mark)
+                     (setq files (nconc
+                                  (project--files-in-directory mark ignores "*")
+                                  files))
+                   (push mark files)))
+               (nreverse marks))
+              (setq xrefs
+                    (project--find-regexp-in-files regexp files))
               (unless xrefs
                 (user-error "No matches for: %s" regexp))
               xrefs))))


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp
  2019-12-25 16:31       ` Dmitry Gutov
@ 2019-12-25 21:46         ` Eric Abrahamsen
  2019-12-26 16:00           ` Dmitry Gutov
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Abrahamsen @ 2019-12-25 21:46 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 36857


On 12/25/19 18:31 PM, Dmitry Gutov wrote:
> Hi Eric,
>
> Please try the attached patch. It should cut down on the number of
> process calls.

That's great! The searches that once took "longer than I was willing to
wait" now return nearly instantly. Thanks a lot. The compiler complains
that `project--files-in-directory' and `project--find-regexp-in-files'
are unknown, but presumably that's easily addressed.

Thanks,
Eric





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp
  2019-12-25 21:46         ` Eric Abrahamsen
@ 2019-12-26 16:00           ` Dmitry Gutov
  0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Gutov @ 2019-12-26 16:00 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 36857-done

On 25.12.2019 23:46, Eric Abrahamsen wrote:

>> Please try the attached patch. It should cut down on the number of
>> process calls.
> 
> That's great! The searches that once took "longer than I was willing to
> wait" now return nearly instantly. Thanks a lot. The compiler complains
> that `project--files-in-directory' and `project--find-regexp-in-files'
> are unknown, but presumably that's easily addressed.

Thanks for testing!

Pushed as ccd7cd2c51.





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-12-26 16:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-30 17:20 bug#36857: 27.0.50; Reduce calls to xref-collect-matches in dired-do-find-regexp Eric Abrahamsen
2019-07-30 18:44 ` Dmitry Gutov
2019-07-30 18:45   ` Dmitry Gutov
2019-07-30 18:56     ` Eric Abrahamsen
2019-07-31 14:06       ` Dmitry Gutov
2019-07-31 15:56         ` Eric Abrahamsen
2019-12-25 16:31       ` Dmitry Gutov
2019-12-25 21:46         ` Eric Abrahamsen
2019-12-26 16:00           ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).