Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Hostetler <jeffhost@microsoft.com>2021-02-03 18:34:47 +0300
committerJunio C Hamano <gitster@pobox.com>2021-02-17 04:14:34 +0300
commit940b94f35cf1858adf23fe939bcbbe73147ca1f3 (patch)
tree88ce2e0ee163c46f077f05c3392e1e23ad7303a7 /fsmonitor.c
parent15268d12bef12a40753767882088f4fcfefb3b2b (diff)
fsmonitor: log invocation of FSMonitor hook to trace2
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> Reviewed-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fsmonitor.c')
-rw-r--r--fsmonitor.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/fsmonitor.c b/fsmonitor.c
index ca031c3abb..7a2be24cd4 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)