Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PR] vcs_info-examples: optimize +vi-git-untracked() #76
- X-seq: zsh-workers 49240
- From: Roman Neuhauser <neuhauser@xxxxxxxxxx>
- To: "Suraj N. Kurapati" <sunaku@xxxxxxxxxx>
- Cc: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [PR] vcs_info-examples: optimize +vi-git-untracked() #76
- Date: Wed, 4 Aug 2021 10:55:03 +0200
- Archived-at: <https://zsh.org/workers/49240>
- In-reply-to: <20210628155736.6982862a@ratham>
- List-id: <zsh-workers.zsh.org>
- References: <20210626230903.43ba5516@ratham> <CAN=4vMp1MAi8ncK3n9V95m0AcE=jTG6qbYr+eRYVpWrsEMBY8Q@mail.gmail.com> <20210628155736.6982862a@ratham>
# 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? :)
BACKGROUND REFRESH
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).
--
roman
Messages sorted by:
Reverse Date,
Date,
Thread,
Author