From: "Jeff Hostetler via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Jeff Hostetler <jeffhost@microsoft.com>,
Jeff Hostetler <jeffhost@microsoft.com>
Subject: [PATCH v2 06/11] read-cache: log the number of lstat calls to trace2
Date: Wed, 03 Feb 2021 15:34:45 +0000 [thread overview]
Message-ID: <d150a2d4576e1519e3a4b228a30ad3c3e63fa150.1612366490.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.860.v2.git.1612366490.gitgitgadget@gmail.com>
From: Jeff Hostetler <jeffhost@microsoft.com>
Report the total number of calls made to lstat() inside of refresh_index().
FSMonitor improves the performance of commands like `git status` by
avoiding scanning the disk for changed files. This can be seen in
`refresh_index()`. Let's measure this.
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
read-cache.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index ecf6f689940..893cc41e1d9 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1364,7 +1364,8 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti
static struct cache_entry *refresh_cache_ent(struct index_state *istate,
struct cache_entry *ce,
unsigned int options, int *err,
- int *changed_ret)
+ int *changed_ret,
+ int *t2_did_lstat)
{
struct stat st;
struct cache_entry *updated;
@@ -1406,6 +1407,8 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
return NULL;
}
+ if (t2_did_lstat)
+ *t2_did_lstat = 1;
if (lstat(ce->name, &st) < 0) {
if (ignore_missing && errno == ENOENT)
return ce;
@@ -1519,6 +1522,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
const char *added_fmt;
const char *unmerged_fmt;
struct progress *progress = NULL;
+ int t2_sum_lstat = 0;
if (flags & REFRESH_PROGRESS && isatty(2))
progress = start_delayed_progress(_("Refresh index"),
@@ -1536,11 +1540,13 @@ int refresh_index(struct index_state *istate, unsigned int flags,
* we only have to do the special cases that are left.
*/
preload_index(istate, pathspec, 0);
+ trace2_region_enter("index", "refresh", NULL);
for (i = 0; i < istate->cache_nr; i++) {
struct cache_entry *ce, *new_entry;
int cache_errno = 0;
int changed = 0;
int filtered = 0;
+ int t2_did_lstat = 0;
ce = istate->cache[i];
if (ignore_submodules && S_ISGITLINK(ce->ce_mode))
@@ -1566,7 +1572,10 @@ int refresh_index(struct index_state *istate, unsigned int flags,
if (filtered)
continue;
- new_entry = refresh_cache_ent(istate, ce, options, &cache_errno, &changed);
+ new_entry = refresh_cache_ent(istate, ce, options,
+ &cache_errno, &changed,
+ &t2_did_lstat);
+ t2_sum_lstat += t2_did_lstat;
if (new_entry == ce)
continue;
if (progress)
@@ -1602,6 +1611,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,
replace_index_entry(istate, i, new_entry);
}
+ trace2_data_intmax("index", NULL, "refresh/sum_lstat", t2_sum_lstat);
+ trace2_region_leave("index", "refresh", NULL);
if (progress) {
display_progress(progress, istate->cache_nr);
stop_progress(&progress);
@@ -1614,7 +1625,7 @@ struct cache_entry *refresh_cache_entry(struct index_state *istate,
struct cache_entry *ce,
unsigned int options)
{
- return refresh_cache_ent(istate, ce, options, NULL, NULL);
+ return refresh_cache_ent(istate, ce, options, NULL, NULL, NULL);
}
--
gitgitgadget
next prev parent reply other threads:[~2021-02-03 15:40 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-01 22:02 [PATCH 00/11] FSMonitor Preliminary Commits Jeff Hostetler via GitGitGadget
2021-02-01 22:02 ` [PATCH 01/11] p7519: use xargs -0 rather than -d in test Jeff Hostetler via GitGitGadget
2021-02-01 23:25 ` Junio C Hamano
2021-02-02 18:16 ` Jeff Hostetler
2021-02-02 21:23 ` Junio C Hamano
2021-02-01 22:02 ` [PATCH 02/11] p7519: fix watchman watch-list test on Windows Jeff Hostetler via GitGitGadget
2021-02-01 22:02 ` [PATCH 03/11] p7519: move watchman cleanup earlier in the test Jeff Hostetler via GitGitGadget
2021-02-01 22:02 ` [PATCH 04/11] p7519: add trace logging during perf test Jeff Hostetler via GitGitGadget
2021-02-01 22:02 ` [PATCH 05/11] preload-index: log the number of lstat calls to trace2 Jeff Hostetler via GitGitGadget
2021-02-01 22:02 ` [PATCH 06/11] read-cache: " Jeff Hostetler via GitGitGadget
2021-02-01 22:02 ` [PATCH 07/11] read-cache: log the number of scanned files " Jeff Hostetler via GitGitGadget
2021-02-01 22:02 ` [PATCH 08/11] fsmonitor: log invocation of FSMonitor hook " Jeff Hostetler via GitGitGadget
2021-02-01 22:02 ` [PATCH 09/11] fsmonitor: log FSMN token when reading and writing the index Jeff Hostetler via GitGitGadget
2021-02-01 22:02 ` [PATCH 10/11] fsmonitor: allow all entries for a folder to be invalidated Kevin Willford via GitGitGadget
2021-02-01 22:02 ` [PATCH 11/11] fsmonitor: refactor initialization of fsmonitor_last_update token Jeff Hostetler via GitGitGadget
2021-02-03 15:34 ` [PATCH v2 00/11] FSMonitor Preliminary Commits Jeff Hostetler via GitGitGadget
2021-02-03 15:34 ` [PATCH v2 01/11] p7519: do not rely on "xargs -d" in test Jeff Hostetler via GitGitGadget
2021-02-03 15:34 ` [PATCH v2 02/11] p7519: fix watchman watch-list test on Windows Jeff Hostetler via GitGitGadget
2021-02-03 15:34 ` [PATCH v2 03/11] p7519: move watchman cleanup earlier in the test Jeff Hostetler via GitGitGadget
2021-02-03 15:34 ` [PATCH v2 04/11] p7519: add trace logging during perf test Jeff Hostetler via GitGitGadget
2021-02-03 15:34 ` [PATCH v2 05/11] preload-index: log the number of lstat calls to trace2 Jeff Hostetler via GitGitGadget
2021-02-03 15:34 ` Jeff Hostetler via GitGitGadget [this message]
2021-02-03 15:34 ` [PATCH v2 07/11] read-cache: log the number of scanned files " Jeff Hostetler via GitGitGadget
2021-02-03 15:34 ` [PATCH v2 08/11] fsmonitor: log invocation of FSMonitor hook " Jeff Hostetler via GitGitGadget
2021-02-03 15:34 ` [PATCH v2 09/11] fsmonitor: log FSMN token when reading and writing the index Jeff Hostetler via GitGitGadget
2021-02-03 15:34 ` [PATCH v2 10/11] fsmonitor: allow all entries for a folder to be invalidated Kevin Willford via GitGitGadget
2021-02-03 15:34 ` [PATCH v2 11/11] fsmonitor: refactor initialization of fsmonitor_last_update token Jeff Hostetler via GitGitGadget
2021-02-16 19:00 ` [PATCH v2 00/11] FSMonitor Preliminary Commits Jeff Hostetler
2021-02-17 1:54 ` Junio C Hamano
2021-02-03 21:19 ` [PATCH " Taylor Blau
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=d150a2d4576e1519e3a4b228a30ad3c3e63fa150.1612366490.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=jeffhost@microsoft.com \
/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).