From bbddf3508e08929872c777f9824f64ec2811fea8 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Fri, 21 Jun 2024 17:18:59 -0400 Subject: [PATCH] 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 --- wt-status.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/wt-status.c b/wt-status.c index b98e4f69942711..9ebbe405b387a4 100644 --- a/wt-status.c +++ b/wt-status.c @@ -2560,6 +2560,36 @@ void wt_status_print(struct wt_status *s) s->untracked.nr); trace2_data_intmax("status", s->repo, "count/ignored", s->ignored.nr); + switch (s->state.sparse_checkout_percentage) { + case SPARSE_CHECKOUT_DISABLED: + break; + case SPARSE_CHECKOUT_SPARSE_INDEX: + /* + * Log just the observed size of the sparse-index. + * + * When sparse-index is enabled we can have + * sparse-directory entries in addition to individual + * sparse-file entries, so we don't know the complete + * size of the index. And we do not want to force + * expand it just to emit some telemetry data. So we + * cannot report a percentage for the space savings. + * + * It is possible that if the telemetry data is + * aggregated, someone will have a good estimate for + * the size of a fully populated index and can compute + * a percentage after the fact. + */ + trace2_data_intmax("status", s->repo, + "sparse-index/size", + s->repo->index->cache_nr); + break; + default: + trace2_data_intmax("status", s->repo, + "sparse-checkout/percentage", + s->state.sparse_checkout_percentage); + break; + } + trace2_region_enter("status", "print", s->repo); switch (s->status_format) {