git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GSOC][PATCH] describe: enable sparse index for describe
@ 2023-03-31 14:27 Raghul Nanth A
  0 siblings, 0 replies; 3+ messages in thread
From: Raghul Nanth A @ 2023-03-31 14:27 UTC (permalink / raw)
  To: git; +Cc: Raghul Nanth A, Derrick Stolee, Victoria Dye

Add usage and performance tests for describe

git describe compares the index with the working tree when (and only
when) it is run with the "--dirty" flag. This is done by the
run_diff_index() function. The function has been made aware of the
sparse-index in the series that led to 8d2c3732 (Merge branch
'ld/sparse-diff-blame', 2021-12-21). Hence we can just set the
requires-full-index to false for "describe".

Performance metrics

  Test                                                     HEAD~1            HEAD
  -------------------------------------------------------------------------------------------------
  2000.2: git describe --dirty (full-v3)                   0.08(0.09+0.01)   0.08(0.06+0.03) +0.0%
  2000.3: git describe --dirty (full-v4)                   0.09(0.07+0.03)   0.08(0.05+0.04) -11.1%
  2000.4: git describe --dirty (sparse-v3)                 0.88(0.82+0.06)   0.02(0.01+0.05) -97.7%
  2000.5: git describe --dirty (sparse-v4)                 0.68(0.60+0.08)   0.02(0.02+0.04) -97.1%
  2000.6: echo >>new && git describe --dirty (full-v3)     0.08(0.04+0.05)   0.08(0.05+0.04) +0.0%
  2000.7: echo >>new && git describe --dirty (full-v4)     0.08(0.07+0.03)   0.08(0.05+0.04) +0.0%
  2000.8: echo >>new && git describe --dirty (sparse-v3)   0.75(0.69+0.07)   0.02(0.03+0.03) -97.3%
  2000.9: echo >>new && git describe --dirty (sparse-v4)   0.81(0.73+0.09)   0.02(0.01+0.05) -97.5%

Signed-off-by: Raghul Nanth A <nanth.raghul@gmail.com>
---
 builtin/describe.c                       |  2 ++
 t/perf/p2000-sparse-operations.sh        |  3 +++
 t/t1092-sparse-checkout-compatibility.sh | 30 ++++++++++++++++++++++++
 3 files changed, 35 insertions(+)

diff --git a/builtin/describe.c b/builtin/describe.c
index 5b5930f5c8..7ff9b5e4b2 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -654,6 +654,8 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 			int fd, result;
 
 			setup_work_tree();
+			prepare_repo_settings(the_repository);
+			the_repository->settings.command_requires_full_index = 0;
 			repo_read_index(the_repository);
 			refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
 				      NULL, NULL, NULL);
diff --git a/t/perf/p2000-sparse-operations.sh b/t/perf/p2000-sparse-operations.sh
index 3242cfe91a..db7887470f 100755
--- a/t/perf/p2000-sparse-operations.sh
+++ b/t/perf/p2000-sparse-operations.sh
@@ -43,6 +43,7 @@ test_expect_success 'setup repo and indexes' '
 	done &&
 
 	git sparse-checkout init --cone &&
+	git tag -a v1.0 -m "Final" &&
 	git sparse-checkout set $SPARSE_CONE &&
 	git checkout -b wide $OLD_COMMIT &&
 
@@ -125,5 +126,7 @@ test_perf_on_all git checkout-index -f --all
 test_perf_on_all git update-index --add --remove $SPARSE_CONE/a
 test_perf_on_all "git rm -f $SPARSE_CONE/a && git checkout HEAD -- $SPARSE_CONE/a"
 test_perf_on_all git grep --cached --sparse bogus -- "f2/f1/f1/*"
+test_perf_on_all git describe --dirty
+test_perf_on_all 'echo >>new && git describe --dirty'
 
 test_done
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
index 801919009e..2b46fb2a48 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
@@ -1514,6 +1514,36 @@ test_expect_success 'sparse-index is not expanded: stash' '
 	ensure_not_expanded stash pop
 '
 
+test_expect_success 'describe tested on all' '
+	init_repos &&
+
+	# Add tag to be read by describe
+
+	run_on_all git tag -a v1.0 -m "Version 1" &&
+	test_all_match git describe --dirty &&
+	run_on_all rm g &&
+	test_all_match git describe --dirty
+'
+
+
+test_expect_success 'sparse-index is not expanded: describe' '
+	init_repos &&
+
+	# Add tag to be read by describe
+
+	git -C sparse-index tag -a v1.0 -m "Version 1" &&
+
+	ensure_not_expanded describe --dirty &&
+	echo "test" >>sparse-index/g &&
+	ensure_not_expanded describe --dirty &&
+	echo "v1.0-dirty" >actual &&
+
+	# Check describe on dirty work tree
+
+	test_cmp sparse-index-out actual &&
+	ensure_not_expanded describe
+'
+
 test_expect_success 'sparse index is not expanded: diff' '
 	init_repos &&
 
-- 
2.40.0

As for the previous questions, yes I am intereseted in GSOC. I had
missed the part regarding the micro projects when I was going through
the requirements. Sorry about that. Would I be required to make one now?

^ permalink raw reply related	[flat|nested] 3+ messages in thread
* Re: [PATCH v3] describe: enable sparse index for describe
@ 2023-03-30 16:23 Victoria Dye
  2023-03-31 15:43 ` [GSOC][PATCH] " Raghul Nanth A
  0 siblings, 1 reply; 3+ messages in thread
From: Victoria Dye @ 2023-03-30 16:23 UTC (permalink / raw)
  To: Raghul Nanth A via GitGitGadget, git; +Cc: Derrick Stolee, Raghul Nanth A

Raghul Nanth A via GitGitGadget wrote:
> diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
> index 801919009e1..8bc35c51426 100755
> --- a/t/t1092-sparse-checkout-compatibility.sh
> +++ b/t/t1092-sparse-checkout-compatibility.sh
> @@ -1514,6 +1514,24 @@ test_expect_success 'sparse-index is not expanded: stash' '
>  	ensure_not_expanded stash pop
>  '
>  
> +test_expect_success 'sparse-index is not expanded: describe' '
> +	init_repos &&
> +	# Add tag to be read by describe

Please add newlines before these comments to visually space out the test &
make it more readable.

> +	git -C sparse-index tag -a v1.0 -m "Version 1" &&
> +	ensure_not_expanded describe --dirty &&
> +	cp sparse-index-out sparse-index-dirty &&
> +	ensure_not_expanded describe &&
> +	cp sparse-index-out sparse-index-normal &&
> +	# Check describe has same output on clean tree
> +	test_cmp sparse-index-dirty sparse-index-normal &&
> +	echo "test" >>sparse-index/g &&
> +	ensure_not_expanded describe --dirty &&
> +	echo "v1.0-dirty" > actual &&
> +	# Check describe on dirty work tree
> +	test_cmp sparse-index-out actual &&
> +	ensure_not_expanded describe

Sorry if I was unclear in my last review [1], but I did not mean that you
should add cases to this test (and, to be honest, the comparison of
'sparse-index-dirty' and 'sparse-index-normal' doesn't add much here).
Please add separate tests (as in, full 'test_expect_success' blocks) for
checking that the functionality of 'git describe' is consistent across
'full-checkout', 'sparse-checkout', and 'sparse-index'. Past sparse index
integrations ('git grep' [2], 'git read-tree' [3], 'git show' [4], etc.) are
a good reference for the types of tests that should be added.

[1] https://lore.kernel.org/git/8cb2b7a2-78f2-9221-1234-62814557d2d3@github.com/
[2] https://lore.kernel.org/git/20220923041842.27817-2-shaoxuan.yuan02@gmail.com/
[3] https://lore.kernel.org/git/90ebcb7b8ff4b4f1ba09abcbe636d639fa597e74.1646166271.git.gitgitgadget@gmail.com/
[4] https://lore.kernel.org/git/8c2fdb5a4fc3317c05324da54692036e36fc15f3.1651005800.git.gitgitgadget@gmail.com/

> +'
> +
>  test_expect_success 'sparse index is not expanded: diff' '
>  	init_repos &&
>  
> 
> base-commit: 27d43aaaf50ef0ae014b88bba294f93658016a2e


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-31 16:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-31 14:27 [GSOC][PATCH] describe: enable sparse index for describe Raghul Nanth A
  -- strict thread matches above, loose matches on Subject: below --
2023-03-30 16:23 [PATCH v3] " Victoria Dye
2023-03-31 15:43 ` [GSOC][PATCH] " Raghul Nanth A
2023-03-31 16:34   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).