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:
authorNeeraj Singh <neerajsi@microsoft.com>2022-03-30 08:06:40 +0300
committerJunio C Hamano <gitster@pobox.com>2022-03-30 21:15:55 +0300
commit9a4987677d3f65e8cd93b9e77216f0f1026cd9b2 (patch)
treea722fc7be1905b845fd8ef5c6e99cb1c8fc71ed4 /wrapper.c
parent805e0a68082a217f0112db9ee86a022227a9c81b (diff)
trace2: add stats for fsync operations
Add some global trace2 statistics for the number of fsyncs performed during the lifetime of a Git process. These stats are printed as part of trace2_cmd_exit_fl, which is presumably where we might want to print any other cross-cutting statistics. Signed-off-by: Neeraj Singh <neerajsi@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wrapper.c')
-rw-r--r--wrapper.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/wrapper.c b/wrapper.c
index 354d784c03..f512994690 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -4,6 +4,9 @@
#include "cache.h"
#include "config.h"
+static intmax_t count_fsync_writeout_only;
+static intmax_t count_fsync_hardware_flush;
+
#ifdef HAVE_RTLGENRANDOM
/* This is required to get access to RtlGenRandom. */
#define SystemFunction036 NTAPI SystemFunction036
@@ -564,6 +567,7 @@ int git_fsync(int fd, enum fsync_action action)
{
switch (action) {
case FSYNC_WRITEOUT_ONLY:
+ count_fsync_writeout_only += 1;
#ifdef __APPLE__
/*
@@ -595,6 +599,8 @@ int git_fsync(int fd, enum fsync_action action)
return -1;
case FSYNC_HARDWARE_FLUSH:
+ count_fsync_hardware_flush += 1;
+
/*
* On macOS, a special fcntl is required to really flush the
* caches within the storage controller. As of this writing,
@@ -610,6 +616,12 @@ int git_fsync(int fd, enum fsync_action action)
}
}
+void trace_git_fsync_stats(void)
+{
+ trace2_data_intmax("fsync", the_repository, "fsync/writeout-only", count_fsync_writeout_only);
+ trace2_data_intmax("fsync", the_repository, "fsync/hardware-flush", count_fsync_hardware_flush);
+}
+
static int warn_if_unremovable(const char *op, const char *file, int rc)
{
int err;