Merge branch 'ab/squelch-empty-fsync-traces'
Omit fsync-related trace2 entries when their values are all zero. * ab/squelch-empty-fsync-traces: trace2: only include "fsync" events if we git_fsync()
This commit is contained in:
@@ -216,12 +216,19 @@ while (<>) {
|
||||
|
||||
elsif ($event eq 'data') {
|
||||
my $cat = $line->{'category'};
|
||||
if ($cat eq 'test_category') {
|
||||
|
||||
my $key = $line->{'key'};
|
||||
my $value = $line->{'value'};
|
||||
$processes->{$sid}->{'data'}->{$cat}->{$key} = $value;
|
||||
}
|
||||
my $key = $line->{'key'};
|
||||
my $value = $line->{'value'};
|
||||
$processes->{$sid}->{'data'}->{$cat}->{$key} = $value;
|
||||
}
|
||||
|
||||
elsif ($event eq 'data_json') {
|
||||
# NEEDSWORK: Ignore due to
|
||||
# compat/win32/trace2_win32_process_info.c, which should log a
|
||||
# "cmd_ancestry" event instead.
|
||||
}
|
||||
|
||||
else {
|
||||
push @{$processes->{$sid}->{$event}} => $line->{value};
|
||||
}
|
||||
|
||||
# This trace2 target does not emit 'printf' events.
|
||||
|
||||
@@ -48,13 +48,33 @@ test_expect_success 'unpack big object in stream' '
|
||||
test_dir_is_empty dest.git/objects/pack
|
||||
'
|
||||
|
||||
check_fsync_events () {
|
||||
local trace="$1" &&
|
||||
shift &&
|
||||
|
||||
cat >expect &&
|
||||
sed -n \
|
||||
-e '/^{"event":"data",.*"category":"fsync",/ {
|
||||
s/.*"category":"fsync",//;
|
||||
s/}$//;
|
||||
p;
|
||||
}' \
|
||||
<"$trace" >actual &&
|
||||
test_cmp expect actual
|
||||
}
|
||||
|
||||
BATCH_CONFIGURATION='-c core.fsync=loose-object -c core.fsyncmethod=batch'
|
||||
|
||||
test_expect_success 'unpack big object in stream (core.fsyncmethod=batch)' '
|
||||
prepare_dest 1m &&
|
||||
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
|
||||
GIT_TEST_FSYNC=true \
|
||||
git -C dest.git $BATCH_CONFIGURATION unpack-objects <pack-$PACK.pack &&
|
||||
grep fsync/hardware-flush trace2.txt &&
|
||||
check_fsync_events trace2.txt <<-\EOF &&
|
||||
"key":"fsync/writeout-only","value":"6"
|
||||
"key":"fsync/hardware-flush","value":"1"
|
||||
EOF
|
||||
|
||||
test_dir_is_empty dest.git/objects/pack &&
|
||||
git -C dest.git cat-file --batch-check="%(objectname)" <obj-list >current &&
|
||||
cmp obj-list current
|
||||
|
||||
10
wrapper.c
10
wrapper.c
@@ -616,10 +616,16 @@ 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)
|
||||
{
|
||||
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);
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user