Skip to content

Commit d98abce

Browse files
committed
Merge branch 'es/trace-log-progress'
Teach codepaths that show progress meter to also use the start_progress() and the stop_progress() calls as a "region" to be traced. * es/trace-log-progress: trace2: log progress time and throughput
2 parents ac140be + 98a1364 commit d98abce

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

progress.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ static struct progress *start_progress_delay(const char *title, uint64_t total,
265265
progress->title_len = utf8_strwidth(title);
266266
progress->split = 0;
267267
set_progress_signal();
268+
trace2_region_enter("progress", title, the_repository);
268269
return progress;
269270
}
270271

@@ -320,6 +321,22 @@ void stop_progress(struct progress **p_progress)
320321
{
321322
finish_if_sparse(*p_progress);
322323

324+
if (p_progress && *p_progress) {
325+
trace2_data_intmax("progress", the_repository, "total_objects",
326+
(*p_progress)->total);
327+
328+
if ((*p_progress)->throughput)
329+
trace2_data_intmax("progress", the_repository,
330+
"total_bytes",
331+
(*p_progress)->throughput->curr_total);
332+
}
333+
334+
trace2_region_leave("progress",
335+
p_progress && *p_progress
336+
? (*p_progress)->title
337+
: NULL,
338+
the_repository);
339+
323340
stop_progress_msg(p_progress, _("done"));
324341
}
325342

t/t0500-progress-display.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,4 +283,30 @@ test_expect_success 'cover up after throughput shortens a lot' '
283283
test_i18ncmp expect out
284284
'
285285

286+
test_expect_success 'progress generates traces' '
287+
cat >in <<-\EOF &&
288+
throughput 102400 1000
289+
update
290+
progress 10
291+
throughput 204800 2000
292+
update
293+
progress 20
294+
throughput 307200 3000
295+
update
296+
progress 30
297+
throughput 409600 4000
298+
update
299+
progress 40
300+
EOF
301+
302+
GIT_TRACE2_EVENT="$(pwd)/trace.event" test-tool progress --total=40 \
303+
"Working hard" <in 2>stderr &&
304+
305+
# t0212/parse_events.perl intentionally omits regions and data.
306+
grep -e "region_enter" -e "\"category\":\"progress\"" trace.event &&
307+
grep -e "region_leave" -e "\"category\":\"progress\"" trace.event &&
308+
grep "\"key\":\"total_objects\",\"value\":\"40\"" trace.event &&
309+
grep "\"key\":\"total_bytes\",\"value\":\"409600\"" trace.event
310+
'
311+
286312
test_done

0 commit comments

Comments
 (0)