*/
int git_fsync(int fd, enum fsync_action action);
+/*
+ * Writes out trace statistics for fsync using the trace2 API.
+ */
+void trace_git_fsync_stats(void);
+
/*
* Preserves errno, prints a message, but gives no warning for ENOENT.
* Returns 0 on success, which includes trying to unlink an object that does
# and highly variable. Just omit them.
goto SKIP_LINE;
}
+ if ($tokens[$col_category] =~ m/fsync/) {
+ # fsync events aren't interesting for the test
+ goto SKIP_LINE;
+ }
}
# t_abs and t_rel are either blank or a float. Replace the float
if (!trace2_enabled)
return code;
+ trace_git_fsync_stats();
trace2_collect_process_info(TRACE2_PROCESS_INFO_EXIT);
tr2main_exit_code = code;
#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
{
switch (action) {
case FSYNC_WRITEOUT_ONLY:
+ count_fsync_writeout_only += 1;
#ifdef __APPLE__
/*
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,
}
}
+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;