Skip to content

Commit fe496dc

Browse files
committed
Merge branch 'ns/trace2-fsync-stat'
Trace2 code has been taught to report stats for fsync operations. * ns/trace2-fsync-stat: trace2: add stats for fsync operations
2 parents da95e25 + 9a49876 commit fe496dc

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

git-compat-util.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,11 @@ enum fsync_action {
12811281
*/
12821282
int git_fsync(int fd, enum fsync_action action);
12831283

1284+
/*
1285+
* Writes out trace statistics for fsync using the trace2 API.
1286+
*/
1287+
void trace_git_fsync_stats(void);
1288+
12841289
/*
12851290
* Preserves errno, prints a message, but gives no warning for ENOENT.
12861291
* Returns 0 on success, which includes trying to unlink an object that does

t/t0211/scrub_perf.perl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
# and highly variable. Just omit them.
6060
goto SKIP_LINE;
6161
}
62+
if ($tokens[$col_category] =~ m/fsync/) {
63+
# fsync events aren't interesting for the test
64+
goto SKIP_LINE;
65+
}
6266
}
6367

6468
# t_abs and t_rel are either blank or a float. Replace the float

trace2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ int trace2_cmd_exit_fl(const char *file, int line, int code)
214214
if (!trace2_enabled)
215215
return code;
216216

217+
trace_git_fsync_stats();
217218
trace2_collect_process_info(TRACE2_PROCESS_INFO_EXIT);
218219

219220
tr2main_exit_code = code;

wrapper.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include "cache.h"
55
#include "config.h"
66

7+
static intmax_t count_fsync_writeout_only;
8+
static intmax_t count_fsync_hardware_flush;
9+
710
#ifdef HAVE_RTLGENRANDOM
811
/* This is required to get access to RtlGenRandom. */
912
#define SystemFunction036 NTAPI SystemFunction036
@@ -564,6 +567,7 @@ int git_fsync(int fd, enum fsync_action action)
564567
{
565568
switch (action) {
566569
case FSYNC_WRITEOUT_ONLY:
570+
count_fsync_writeout_only += 1;
567571

568572
#ifdef __APPLE__
569573
/*
@@ -595,6 +599,8 @@ int git_fsync(int fd, enum fsync_action action)
595599
return -1;
596600

597601
case FSYNC_HARDWARE_FLUSH:
602+
count_fsync_hardware_flush += 1;
603+
598604
/*
599605
* On macOS, a special fcntl is required to really flush the
600606
* caches within the storage controller. As of this writing,
@@ -610,6 +616,12 @@ int git_fsync(int fd, enum fsync_action action)
610616
}
611617
}
612618

619+
void trace_git_fsync_stats(void)
620+
{
621+
trace2_data_intmax("fsync", the_repository, "fsync/writeout-only", count_fsync_writeout_only);
622+
trace2_data_intmax("fsync", the_repository, "fsync/hardware-flush", count_fsync_hardware_flush);
623+
}
624+
613625
static int warn_if_unremovable(const char *op, const char *file, int rc)
614626
{
615627
int err;

0 commit comments

Comments
 (0)