emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A project-files implementation for Git projects


From: Tassilo Horn
Subject: Re: A project-files implementation for Git projects
Date: Thu, 03 Oct 2019 10:33:43 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Dmitry Gutov <address@hidden> writes:

Hi Dmitry,

> Here's an updated patch.
>
> - project--vc-list-files now has '--' in its name.
>
> - Turns out that sometimes Git repositories include symlinks, and even broken
>  ones. Grep, subsequently, chokes on those with "file not found", so we now
> suppress all "not found" messages from Grep.
>
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index 4693d07fa8..4556c0bdb9 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -277,6 +277,67 @@ project-try-vc
>       (funcall project-vc-external-roots-function)))
>     (project-roots project)))
>  
> +(cl-defmethod project-files ((project (head vc)) &optional dirs)
> +  (cl-mapcan
> +   (lambda (dir)
> +     (let (backend)
> +       (if (and (file-equal-p dir (cdr project))
> +                (setq backend (vc-responsible-backend dir))
> +                nil
                   ^^^

So this disables the VC operation.  I've removed it, and the speed
improvement is good here.  This is my test case (the Emacs repository):

--8<---------------cut here---------------start------------->8---
(let* ((dir "~/Repos/el/emacs")
       (p (project-current nil dir))
       f1 f2)
  (let ((t1 (benchmark-run 10
              (setq f1 (project-files p))))
        (t2 (benchmark-run 10
              (setq f2 (project--files-in-directory
                        dir (project--dir-ignores p dir))))))
    (message "Files: %d (VC) vs. %d (find)" (length f1) (length f2))
    (message "VC) Elapsed time: %fs (%fs in %d GCs)"
             (car t1) (nth 2 t1) (nth 1 t1))
    (message "Find) Elapsed time: %fs (%fs in %d GCs)"
             (car t2) (nth 2 t2) (nth 1 t2)))
  (let ((d1 (cl-set-difference f1 f2 :test #'string=))
        (d2 (cl-set-difference f2 f1 :test #'string=)))
    (message "Files found by VC but not by find:")
    (dolist (f d1)
      (message "  %s" f))
    (message "Files found by find but not by VC:")
    (dolist (f d2)
      (message "  %s" f))))
--8<---------------cut here---------------end--------------->8---

Here is the output:

--8<---------------cut here---------------start------------->8---
VC) Elapsed time: 1.379560s (0.308720s in 6 GCs)
Find) Elapsed time: 4.397054s (0.200695s in 4 GCs)
Files found by VC but not by find:
  /home/horn/Repos/el/emacs/doc/lispintro/cons-1.pdf
  /home/horn/Repos/el/emacs/doc/lispintro/cons-2.pdf
  /home/horn/Repos/el/emacs/doc/lispintro/cons-2a.pdf
  /home/horn/Repos/el/emacs/doc/lispintro/cons-3.pdf
  /home/horn/Repos/el/emacs/doc/lispintro/cons-4.pdf
  /home/horn/Repos/el/emacs/doc/lispintro/cons-5.pdf
  /home/horn/Repos/el/emacs/doc/lispintro/drawers.pdf
  /home/horn/Repos/el/emacs/doc/lispintro/lambda-1.pdf
  /home/horn/Repos/el/emacs/doc/lispintro/lambda-2.pdf
  /home/horn/Repos/el/emacs/doc/lispintro/lambda-3.pdf
  /home/horn/Repos/el/emacs/etc/refcards/Makefile
  /home/horn/Repos/el/emacs/etc/refcards/gnus-logo.pdf
  /home/horn/Repos/el/emacs/lib/_Noreturn.h
  /home/horn/Repos/el/emacs/lib/stdalign.in.h
  /home/horn/Repos/el/emacs/lib/stddef.in.h
  /home/horn/Repos/el/emacs/lib/stdint.in.h
  /home/horn/Repos/el/emacs/lib/stdio-impl.h
  /home/horn/Repos/el/emacs/lib/stdio.in.h
  /home/horn/Repos/el/emacs/lib/stdlib.in.h
  /home/horn/Repos/el/emacs/m4/__inline.m4
  /home/horn/Repos/el/emacs/test/data/xdg/mimeinfo.cache
  /home/horn/Repos/el/emacs/test/lisp/progmodes/flymake-resources/Makefile
  /home/horn/Repos/el/emacs/test/manual/etags/Makefile
  /home/horn/Repos/el/emacs/test/manual/etags/make-src/Makefile
  /home/horn/Repos/el/emacs/test/manual/indent/Makefile
Files found by find but not by VC:
  /home/horn/Repos/el/emacs/aclocal.m4
  /home/horn/Repos/el/emacs/config.status
  /home/horn/Repos/el/emacs/configure
  /home/horn/Repos/el/emacs/info/dir
--8<---------------cut here---------------end--------------->8---

Then I did it on a clean checkout of the gtk repository and got this
result:

--8<---------------cut here---------------start------------->8---
Files: 4774 (VC) vs. 4774 (find)
VC) Elapsed time: 1.721054s (0.461112s in 9 GCs)
Find) Elapsed time: 0.634624s (0.152549s in 3 GCs)
Files found by VC but not by find:
Files found by find but not by VC:
nil
--8<---------------cut here---------------end--------------->8---

So here, Git has been much slower that find!

And again with gnulib:

--8<---------------cut here---------------start------------->8---
Files: 9936 (VC) vs. 9936 (find)
VC) Elapsed time: 3.444869s (0.902124s in 16 GCs)
Find) Elapsed time: 1.380269s (0.285082s in 5 GCs)
Files found by VC but not by find:
Files found by find but not by VC:
--8<---------------cut here---------------end--------------->8---

Again Git was slower.  What my gtk and gnulib repositories have in
common is that they are clean, i.e., no build artifacts which would be
matched by the exclude args passed to find...

Bye,
Tassilo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]