git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 08/11] fsmonitor: log invocation of FSMonitor hook to trace2
Date: Mon, 01 Feb 2021 22:02:17 +0000	[thread overview]
Message-ID: <ef64b60c7a0c85df08198a8f104029742c555bad.1612216941.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.860.git.1612216941.gitgitgadget@gmail.com>

From: Jeff Hostetler <jeffhost@microsoft.com>

Let's measure the time taken to request and receive FSMonitor data
via the hook API and the size of the response.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
 fsmonitor.c | 29 ++++++++++++++++++++++++++++-
 fsmonitor.h |  5 +++++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/fsmonitor.c b/fsmonitor.c
index ca031c3abb8..7a2be24cd43 100644
--- a/fsmonitor.c
+++ b/fsmonitor.c
@@ -142,6 +142,7 @@ void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate)
 static int query_fsmonitor(int version, const char *last_update, struct strbuf *query_result)
 {
 	struct child_process cp = CHILD_PROCESS_INIT;
+	int result;
 
 	if (!core_fsmonitor)
 		return -1;
@@ -152,7 +153,33 @@ static int query_fsmonitor(int version, const char *last_update, struct strbuf *
 	cp.use_shell = 1;
 	cp.dir = get_git_work_tree();
 
-	return capture_command(&cp, query_result, 1024);
+	trace2_region_enter("fsm_hook", "query", NULL);
+
+	result = capture_command(&cp, query_result, 1024);
+
+	if (result)
+		trace2_data_intmax("fsm_hook", NULL, "query/failed", result);
+	else {
+		trace2_data_intmax("fsm_hook", NULL, "query/response-length",
+				   query_result->len);
+
+		if (fsmonitor_is_trivial_response(query_result))
+			trace2_data_intmax("fsm_hook", NULL,
+					   "query/trivial-response", 1);
+	}
+
+	trace2_region_leave("fsm_hook", "query", NULL);
+
+	return result;
+}
+
+int fsmonitor_is_trivial_response(const struct strbuf *query_result)
+{
+	static char trivial_response[3] = { '\0', '/', '\0' };
+	int is_trivial = !memcmp(trivial_response,
+				 &query_result->buf[query_result->len - 3], 3);
+
+	return is_trivial;
 }
 
 static void fsmonitor_refresh_callback(struct index_state *istate, const char *name)
diff --git a/fsmonitor.h b/fsmonitor.h
index 739318ab6d1..7f1794b90b0 100644
--- a/fsmonitor.h
+++ b/fsmonitor.h
@@ -44,6 +44,11 @@ void tweak_fsmonitor(struct index_state *istate);
  */
 void refresh_fsmonitor(struct index_state *istate);
 
+/*
+ * Does the received result contain the "trivial" response?
+ */
+int fsmonitor_is_trivial_response(const struct strbuf *query_result);
+
 /*
  * Set the given cache entries CE_FSMONITOR_VALID bit. This should be
  * called any time the cache entry has been updated to reflect the
-- 
gitgitgadget


  parent reply	other threads:[~2021-02-01 22:04 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 ` Jeff Hostetler via GitGitGadget [this message]
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   ` [PATCH v2 06/11] read-cache: " Jeff Hostetler via GitGitGadget
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=ef64b60c7a0c85df08198a8f104029742c555bad.1612216941.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).