From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 18/20] update-index: manually enable or disable untracked cache
Date: Wed, 7 May 2014 21:51:58 +0700 [thread overview]
Message-ID: <1399474320-6840-19-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1399474320-6840-1-git-send-email-pclouds@gmail.com>
Some numbers below. In short, the saving on wt_status_collect_untracked()
is about 80%. There are some overhead on read/write_cache, but it seems
lower than 50ms, while the .._untracked() saving is in the 500ms range
(except linux-2.6, about 150ms). "git status" time saving ranges from
33% to 42%.
On gentoo-x86.git (100k files, 23k dirs, quite balance
tree, 8.5MB index v4, cache-tree fully populated), before turning
untracked cache on (the most important line is wt_status_collect:625)
184.650 gitmodules_config:201 if (read_cache() < 0) die("index
0.004 cmd_status:1299 read_cache_preload(&s.pathspec)
226.231 cmd_status:1300 refresh_index(&the_index, REFRESH_QUIET
3.096 cmd_status:1304 update_index_if_able(&the_index, &index_lock)
6.788 wt_status_collect:619 wt_status_collect_changes_worktree(s)
6.780 wt_status_collect:624 wt_status_collect_changes_index(s)
772.866 wt_status_collect:625 wt_status_collect_untracked(s)
786.686 cmd_status:1308 wt_status_collect(&s)
real 0m1.211s
user 0m0.566s
sys 0m0.638s
and after (saving 42% total time):
220.888 gitmodules_config:201 if (read_cache() < 0) die("index
36.368 cmd_status:1299 read_cache_preload(&s.pathspec)
223.936 cmd_status:1300 refresh_index(&the_index, REFRESH_QUIET
2.935 cmd_status:1304 update_index_if_able(&the_index, &index_lock)
7.031 wt_status_collect:619 wt_status_collect_changes_worktree(s)
7.156 wt_status_collect:624 wt_status_collect_changes_index(s)
148.022 wt_status_collect:625 wt_status_collect_untracked(s)
162.443 cmd_status:1308 wt_status_collect(&s)
36.943 cmd_status:1348 if (the_index.untracked) { struct
real 0m0.696s
user 0m0.406s
sys 0m0.288s
On webkit.git (182k files, 6k dirs, 14M index v4), before:
283.182 gitmodules_config:201 if (read_cache() < 0) die("index
0.004 cmd_status:1299 read_cache_preload(&s.pathspec)
515.836 cmd_status:1300 refresh_index(&the_index, REFRESH_QUIET
5.428 cmd_status:1304 update_index_if_able(&the_index, &index_lock)
11.162 wt_status_collect:619 wt_status_collect_changes_worktree(s)
11.068 wt_status_collect:624 wt_status_collect_changes_index(s)
887.247 wt_status_collect:625 wt_status_collect_untracked(s)
909.722 cmd_status:1308 wt_status_collect(&s)
real 0m1.729s
user 0m0.785s
sys 0m0.941s
and after (saving 38% total time):
290.994 gitmodules_config:201 if (read_cache() < 0) die("index
10.132 cmd_status:1299 read_cache_preload(&s.pathspec)
516.656 cmd_status:1300 refresh_index(&the_index, REFRESH_QUIET
5.159 cmd_status:1304 update_index_if_able(&the_index, &index_lock)
12.605 wt_status_collect:619 wt_status_collect_changes_worktree(s)
11.262 wt_status_collect:624 wt_status_collect_changes_index(s)
186.032 wt_status_collect:625 wt_status_collect_untracked(s)
210.134 cmd_status:1308 wt_status_collect(&s)
12.332 cmd_status:1348 if (the_index.untracked) { struct index_state
real 0m1.058s
user 0m0.525s
sys 0m0.532s
And linux-2.6 (45k files, 3k dirs, 3.2MB index v4), before:
68.668 gitmodules_config:201 if (read_cache() < 0) die("index
0.004 cmd_status:1299 read_cache_preload(&s.pathspec)
114.270 cmd_status:1300 refresh_index(&the_index, REFRESH_QUIET
1.180 cmd_status:1304 update_index_if_able(&the_index, &index_lock)
4.027 wt_status_collect:619 wt_status_collect_changes_worktree(s)
4.265 wt_status_collect:624 wt_status_collect_changes_index(s)
191.285 wt_status_collect:625 wt_status_collect_untracked(s)
199.825 cmd_status:1308 wt_status_collect(&s)
real 0m0.392s
user 0m0.177s
sys 0m0.215s
and after (saving 33%):
71.756 gitmodules_config:201 if (read_cache() < 0) die("index
5.201 cmd_status:1299 read_cache_preload(&s.pathspec)
111.064 cmd_status:1300 refresh_index(&the_index, REFRESH_QUIET
1.171 cmd_status:1304 update_index_if_able(&the_index, &index_lock)
3.054 wt_status_collect:619 wt_status_collect_changes_worktree(s)
4.945 wt_status_collect:624 wt_status_collect_changes_index(s)
27.203 wt_status_collect:625 wt_status_collect_untracked(s)
35.475 cmd_status:1308 wt_status_collect(&s)
25.759 cmd_status:1348 if (the_index.untracked) { struct index_state
real 0m0.259s
user 0m0.106s
sys 0m0.132s
---
builtin/update-index.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/builtin/update-index.c b/builtin/update-index.c
index ba54e19..003e28e 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -734,6 +734,7 @@ static int reupdate_callback(struct parse_opt_ctx_t *ctx,
int cmd_update_index(int argc, const char **argv, const char *prefix)
{
int newfd, entries, has_errors = 0, line_termination = '\n';
+ int untracked_cache = -1;
int read_from_stdin = 0;
int prefix_length = prefix ? strlen(prefix) : 0;
int preferred_index_format = 0;
@@ -822,6 +823,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
resolve_undo_clear_callback},
OPT_INTEGER(0, "index-version", &preferred_index_format,
N_("write index in this format")),
+ OPT_BOOL(0, "untracked-cache", &untracked_cache,
+ N_("enable/disable untracked cache")),
OPT_END()
};
@@ -915,6 +918,20 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
strbuf_release(&buf);
}
+ if (untracked_cache > 0) {
+ struct untracked_cache *uc;
+
+ uc = xcalloc(1, sizeof(*uc));
+ uc->exclude_per_dir = ".gitignore";
+ /* should be the same flags used by git-status */
+ uc->dir_flags = DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;
+ the_index.untracked = uc;
+ active_cache_changed = 1;
+ } else if (!untracked_cache) {
+ the_index.untracked = NULL;
+ active_cache_changed = 1;
+ }
+
if (active_cache_changed) {
if (newfd < 0) {
if (refresh_args.flags & REFRESH_QUIET)
--
1.9.1.346.ga2b5940
next prev parent reply other threads:[~2014-05-07 14:53 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-07 14:51 [PATCH 00/20] Untracked cache to speed up "git status" Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 01/20] dir.c: coding style fix Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 02/20] dir.h: move struct exclude declaration to top level Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 03/20] prep_exclude: remove the artificial PATH_MAX limit Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 04/20] dir.c: optionally compute sha-1 of a .gitignore file Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 05/20] untracked cache: record .gitignore information and dir hierarchy Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 06/20] untracked cache: initial untracked cache validation Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 07/20] untracked cache: invalidate dirs recursively if .gitignore changes Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 08/20] untracked cache: record/validate dir mtime and reuse cached output Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 09/20] untracked cache: mark what dirs should be recursed/saved Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 10/20] untracked cache: don't open non-existent .gitignore Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 11/20] untracked cache: save to an index extension Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 12/20] untracked cache: load from UNTR " Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 13/20] untracked cache: invalidate at index addition or removal Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 14/20] untracked cache: print untracked statistics with $GIT_TRACE_UNTRACKED Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 15/20] read-cache.c: split racy stat test to a separate function Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 16/20] untracked cache: avoid racy timestamps Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` [PATCH 17/20] status: support untracked cache Nguyễn Thái Ngọc Duy
2014-05-07 14:51 ` Nguyễn Thái Ngọc Duy [this message]
2014-05-07 14:51 ` [PATCH 19/20] update-index: test the system before enabling " Nguyễn Thái Ngọc Duy
2014-05-07 14:52 ` [PATCH 20/20] t7063: tests for " Nguyễn Thái Ngọc Duy
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=1399474320-6840-19-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.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).