Skip to content

Commit 7c7719a

Browse files
committed
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()
2 parents 36d7bd1 + 3a251ba commit 7c7719a

File tree

3 files changed

+42
-9
lines changed

3 files changed

+42
-9
lines changed

t/t0212/parse_events.perl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,19 @@
216216

217217
elsif ($event eq 'data') {
218218
my $cat = $line->{'category'};
219-
if ($cat eq 'test_category') {
220-
221-
my $key = $line->{'key'};
222-
my $value = $line->{'value'};
223-
$processes->{$sid}->{'data'}->{$cat}->{$key} = $value;
224-
}
219+
my $key = $line->{'key'};
220+
my $value = $line->{'value'};
221+
$processes->{$sid}->{'data'}->{$cat}->{$key} = $value;
222+
}
223+
224+
elsif ($event eq 'data_json') {
225+
# NEEDSWORK: Ignore due to
226+
# compat/win32/trace2_win32_process_info.c, which should log a
227+
# "cmd_ancestry" event instead.
228+
}
229+
230+
else {
231+
push @{$processes->{$sid}->{$event}} => $line->{value};
225232
}
226233

227234
# This trace2 target does not emit 'printf' events.

t/t5351-unpack-large-objects.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,33 @@ test_expect_success 'unpack big object in stream' '
4848
test_dir_is_empty dest.git/objects/pack
4949
'
5050

51+
check_fsync_events () {
52+
local trace="$1" &&
53+
shift &&
54+
55+
cat >expect &&
56+
sed -n \
57+
-e '/^{"event":"data",.*"category":"fsync",/ {
58+
s/.*"category":"fsync",//;
59+
s/}$//;
60+
p;
61+
}' \
62+
<"$trace" >actual &&
63+
test_cmp expect actual
64+
}
65+
5166
BATCH_CONFIGURATION='-c core.fsync=loose-object -c core.fsyncmethod=batch'
5267

5368
test_expect_success 'unpack big object in stream (core.fsyncmethod=batch)' '
5469
prepare_dest 1m &&
5570
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
71+
GIT_TEST_FSYNC=true \
5672
git -C dest.git $BATCH_CONFIGURATION unpack-objects <pack-$PACK.pack &&
57-
grep fsync/hardware-flush trace2.txt &&
73+
check_fsync_events trace2.txt <<-\EOF &&
74+
"key":"fsync/writeout-only","value":"6"
75+
"key":"fsync/hardware-flush","value":"1"
76+
EOF
77+
5878
test_dir_is_empty dest.git/objects/pack &&
5979
git -C dest.git cat-file --batch-check="%(objectname)" <obj-list >current &&
6080
cmp obj-list current

wrapper.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,16 @@ int git_fsync(int fd, enum fsync_action action)
616616
}
617617
}
618618

619+
static void log_trace_fsync_if(const char *key, intmax_t value)
620+
{
621+
if (value)
622+
trace2_data_intmax("fsync", the_repository, key, value);
623+
}
624+
619625
void trace_git_fsync_stats(void)
620626
{
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);
627+
log_trace_fsync_if("fsync/writeout-only", count_fsync_writeout_only);
628+
log_trace_fsync_if("fsync/hardware-flush", count_fsync_hardware_flush);
623629
}
624630

625631
static int warn_if_unremovable(const char *op, const char *file, int rc)

0 commit comments

Comments
 (0)