Skip to content

Commit 7975c98

Browse files
authored
virtualization: add new builtin command to print hydration level (microsoft#659)
GVFS users can easily (and accidentally) over-hydrate their enlistments. This causes some commands to be very slow. Create a command to print the current hydration level. This should help our support team investigate the state of their enlistment. This command will print something like: ``` % git virtualization Skipped: 2 Hydrated: 3 Total: 5 Hydration: 60.00% ``` and log those values to Trace2 in a `data_json` record of the form: ``` {"skipped":2,"hydrated":3,"total":5,"hydration":60.00} ```
2 parents 78b268c + e774223 commit 7975c98

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

.github/workflows/scalar-functional-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
# Order by runtime (in descending order)
23-
os: [windows-2019, macos-11, ubuntu-20.04, ubuntu-22.04]
23+
os: [windows-2019, macos-13, ubuntu-20.04, ubuntu-22.04]
2424
# Scalar.NET used to be tested using `features: [false, experimental]`
2525
# But currently, Scalar/C ignores `feature.scalar` altogether, so let's
2626
# save some electrons and run only one of them...

t/t1093-virtualfilesystem.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ test_expect_success 'verify status is clean' '
6969
git status > actual &&
7070
cat > expected <<-\EOF &&
7171
On branch main
72+
You are in a partially-hydrated checkout with 75% of tracked files present.
73+
7274
nothing to commit, working tree clean
7375
EOF
7476
test_cmp expected actual

wt-status.c

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,10 +1604,15 @@ static void show_sparse_checkout_in_use(struct wt_status *s,
16041604
{
16051605
if (s->state.sparse_checkout_percentage == SPARSE_CHECKOUT_DISABLED)
16061606
return;
1607-
if (core_virtualfilesystem)
1608-
return;
1609-
1610-
if (s->state.sparse_checkout_percentage == SPARSE_CHECKOUT_SPARSE_INDEX)
1607+
if (core_virtualfilesystem) {
1608+
if (s->state.sparse_checkout_percentage == SPARSE_CHECKOUT_SPARSE_INDEX)
1609+
status_printf_ln(s, color,
1610+
_("You are in a partially-hydrated checkout with a sparse index."));
1611+
else
1612+
status_printf_ln(s, color,
1613+
_("You are in a partially-hydrated checkout with %d%% of tracked files present."),
1614+
s->state.sparse_checkout_percentage);
1615+
} else if (s->state.sparse_checkout_percentage == SPARSE_CHECKOUT_SPARSE_INDEX)
16111616
status_printf_ln(s, color, _("You are in a sparse checkout."));
16121617
else
16131618
status_printf_ln(s, color,
@@ -2560,6 +2565,36 @@ void wt_status_print(struct wt_status *s)
25602565
s->untracked.nr);
25612566
trace2_data_intmax("status", s->repo, "count/ignored", s->ignored.nr);
25622567

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

25652600
switch (s->status_format) {

0 commit comments

Comments
 (0)