diff options
Diffstat (limited to 'wrapper.c')
-rw-r--r-- | wrapper.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -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 @@ -390,7 +393,7 @@ FILE *xfopen(const char *path, const char *mode) FILE *xfdopen(int fd, const char *mode) { FILE *stream = fdopen(fd, mode); - if (stream == NULL) + if (!stream) die_errno("Out of memory? fdopen failed"); return stream; } @@ -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,18 @@ int git_fsync(int fd, enum fsync_action action) } } +static void log_trace_fsync_if(const char *key, intmax_t value) +{ + if (value) + trace2_data_intmax("fsync", the_repository, key, value); +} + +void trace_git_fsync_stats(void) +{ + log_trace_fsync_if("fsync/writeout-only", count_fsync_writeout_only); + log_trace_fsync_if("fsync/hardware-flush", count_fsync_hardware_flush); +} + static int warn_if_unremovable(const char *op, const char *file, int rc) { int err; |