Skip to content

Commit 5e6e299

Browse files
jeffhostetlerdscho
authored andcommitted
wt-status: add trace2 data for sparse-checkout percentage
When sparse-checkout is enabled, add the sparse-checkout percentage to the Trace2 data stream. This number was already computed and printed on the console in the "You are in a sparse checkout..." message. It would be helpful to log it too for performance monitoring. Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
1 parent 3f8b4f7 commit 5e6e299

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

wt-status.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2571,6 +2571,36 @@ void wt_status_print(struct wt_status *s)
25712571
s->untracked.nr);
25722572
trace2_data_intmax("status", s->repo, "count/ignored", s->ignored.nr);
25732573

2574+
switch (s->state.sparse_checkout_percentage) {
2575+
case SPARSE_CHECKOUT_DISABLED:
2576+
break;
2577+
case SPARSE_CHECKOUT_SPARSE_INDEX:
2578+
/*
2579+
* Log just the observed size of the sparse-index.
2580+
*
2581+
* When sparse-index is enabled we can have
2582+
* sparse-directory entries in addition to individual
2583+
* sparse-file entries, so we don't know the complete
2584+
* size of the index. And we do not want to force
2585+
* expand it just to emit some telemetry data. So we
2586+
* cannot report a percentage for the space savings.
2587+
*
2588+
* It is possible that if the telemetry data is
2589+
* aggregated, someone will have a good estimate for
2590+
* the size of a fully populated index and can compute
2591+
* a percentage after the fact.
2592+
*/
2593+
trace2_data_intmax("status", s->repo,
2594+
"sparse-index/size",
2595+
s->repo->index->cache_nr);
2596+
break;
2597+
default:
2598+
trace2_data_intmax("status", s->repo,
2599+
"sparse-checkout/percentage",
2600+
s->state.sparse_checkout_percentage);
2601+
break;
2602+
}
2603+
25742604
trace2_region_enter("status", "print", s->repo);
25752605

25762606
switch (s->status_format) {

0 commit comments

Comments
 (0)