From: Fredrik Gustafsson <iveqy@iveqy.com>
To: spearce@spearce.org
Cc: git@vger.kernel.org, pclouds@gmail.com, iveqy@iveqy.com
Subject: [RFC] Add posibility to preload stat information.
Date: Wed, 20 Mar 2013 13:15:32 +0100 [thread overview]
Message-ID: <1363781732-11396-1-git-send-email-iveqy@iveqy.com> (raw)
When entering a git working dir, optionally run a forked process that
stat all files in the whole workdir and therefore loads stat information
to RAM which will speedup things like git status and so on.
The feature is optional and by default it's off.
Signed-off-by: Fredrik Gustafsson <iveqy@iveqy.com>
---
contrib/completion/git-prompt.sh | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 341422a..e67bc97 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -78,6 +78,12 @@
# If you would like a colored hint about the current dirty state, set
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
# the colored output of "git status -sb".
+#
+# When enter a git work dir you can have a forked process run
+# stat on all files in the top level directory for git and down.
+# This will decrease later calls to git status and alike because
+# stat info will already be loaded into RAM. set GIT_PRE_STAT to
+# a nonempty value.
# __gitdir accepts 0 or 1 arguments (i.e., location)
# returns location of .git repo
@@ -222,6 +228,19 @@ __git_ps1_show_upstream ()
}
+# Forks and recursive do a stat from the toplevel git dir.
+# This will load inodes into RAM for faster access when running
+# A git command, like git show.
+__git_recursive_stat ()
+{
+ if test ! -e /tmp/gitbash.lock
+ then
+ touch /tmp/gitbash.lock
+ cd $(git rev-parse --show-toplevel)
+ find . | xargs stat 2&> /dev/null
+ rm /tmp/gitbash.lock
+ fi
+}
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
# when called from PS1 using command substitution
@@ -320,6 +339,10 @@ __git_ps1 ()
b="GIT_DIR!"
fi
elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
+ if [ -n "${GIT_PRE_STAT-}" ];
+ then
+ (__git_recursive_stat 2&> /dev/null &)
+ fi
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
[ "$(git config --bool bash.showDirtyState)" != "false" ]
then
--
1.8.1.5
next reply other threads:[~2013-03-20 12:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-20 12:15 Fredrik Gustafsson [this message]
2013-03-20 16:48 ` [RFC] Add posibility to preload stat information Jeff King
2013-03-20 17:15 ` Junio C Hamano
2013-03-20 17:47 ` Jeff King
2013-03-21 10:41 ` Thomas Rast
2013-03-21 14:44 ` Junio C Hamano
2013-03-30 19:42 ` Phil Hord
2013-03-20 18:40 ` Fredrik Gustafsson
2013-03-20 17:15 ` Ramkumar Ramachandra
2013-03-20 17:41 ` Fredrik Gustafsson
2013-03-20 17:49 ` Ramkumar Ramachandra
2013-03-20 18:36 ` Fredrik Gustafsson
2013-03-20 18:46 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363781732-11396-1-git-send-email-iveqy@iveqy.com \
--to=iveqy@iveqy.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).