Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PR] vcs_info-examples: optimize +vi-git-untracked() #76

# sunaku@xxxxxxxxxx / 2021-06-28 15:57:36 -0700:
> On Sun, 27 Jun 2021 15:03:17 +0200, Roman Perepelitsa wrote:
> > On Sun, Jun 27, 2021 at 8:07 AM Suraj N. Kurapati wrote:
> > > Speed up the prompt on large and/or deep working directories [...]  
> > 
> > Do you have an estimate of the speedup? Numbers from at least one
> > repository on one machine would be useful to see.
> I see a 4x speedup on a large Git-enabled home directory, as follows:
>     $ time (git status --porcelain | wc -l)
>     212
>     0.01s user 0.02s system 0% cpu 9.021 total
>     $ time (git status --porcelain | grep '??' &>/dev/null)
>     0.01s user 0.02s system 0% cpu 12.294 total
>     $ time (git status --porcelain | grep -q '^?? ' 2>/dev/null)
>     0.01s user 0.01s system 0% cpu 3.097 total

this might be of interest (example code should be exemplary, no? :)

  By default, git status will automatically refresh the index, updating
  the cached stat information from the working tree and writing out the
  result. Writing out the updated index is an optimization that isn’t
  strictly necessary (status computes the values for itself, but writing
  them out is just to save subsequent programs from repeating our
  computation). When status is run in the background, the lock held
  during the write may conflict with other simultaneous processes,
  causing them to fail. Scripts running status in the background should
  consider using git --no-optional-locks status (see git(1) for details).


Messages sorted by: Reverse Date, Date, Thread, Author