Skip to content

Commit 98a1364

Browse files
nasamuffingitster
authored andcommitted
trace2: log progress time and throughput
Rather than teaching only one operation, like 'git fetch', how to write down throughput to traces, we can learn about a wide range of user operations that may seem slow by adding tooling to the progress library itself. Operations which display progress are likely to be slow-running and the kind of thing we want to monitor for performance anyways. By showing object counts and data transfer size, we should be able to make some derived measurements to ensure operations are scaling the way we expect. Signed-off-by: Emily Shaffer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b994622 commit 98a1364

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)