git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 4/4] read-cache perf: add a perf test for refresh_index()

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 24, 2021, 09:15 UTC
Message-ID
<patch-v2-4.4-e3648bf78c7-20210824T091204Z-avarab@gmail.com>
In-Reply-To
<cover-v2-0.4-00000000000-20210824T091204Z-avarab@gmail.com>

Add a perf test for the refresh_index() function to compliment the existing read()/discard() in a loop perf test added in 1ecb5ff141f (read-cache: add simple performance test, 2013-06-09).

Since this test is much slower (around 10x) than the previous read()/discard() test let's run it 100 times instead of the 1000 time the first one runs.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/helper/test-read-cache-perf.c | 12 ++++++++++++
 t/perf/p0002-read-cache.sh      |  5 +++++
 2 files changed, 17 insertions(+)
diff --git a/t/helper/test-read-cache-perf.c b/t/helper/test-read-cache-perf.c
index 301e98797b4..630c126fbf3 100644
--- a/t/helper/test-read-cache-perf.c
+++ b/t/helper/test-read-cache-perf.c
@@ -11,8 +11,11 @@ int cmd__read_cache_perf(int argc, const char **argv)
 {
 	struct repository *r = the_repository;
 	int cnt = -1;
+	int refresh = 0;
 	struct option options[] = {
 		OPT_INTEGER(0, "count", &cnt, "number of passes"),
+		OPT_BOOL(0, "refresh", &refresh,
+			 "call refresh_index() in a loop, not read()/discard()"),
 		OPT_END()
 	};
 
@@ -26,10 +29,19 @@ int cmd__read_cache_perf(int argc, const char **argv)
 			      options);
 
 	setup_git_directory();
+	if (refresh)
+		repo_read_index(r);
 	while (cnt--) {
+		if (refresh) {
+			unsigned int flags = REFRESH_QUIET|REFRESH_PROGRESS;
+			refresh_index(r->index, flags, NULL, NULL, NULL);
+			continue;
+		}
 		repo_read_index(r);
 		discard_index(r->index);
 	}
+	if (refresh)
+		discard_index(r->index);
 
 	return 0;
 }
diff --git a/t/perf/p0002-read-cache.sh b/t/perf/p0002-read-cache.sh
index 1762b648654..cbccc5ace95 100755
--- a/t/perf/p0002-read-cache.sh
+++ b/t/perf/p0002-read-cache.sh
@@ -11,4 +11,9 @@ test_perf "read_cache/discard_cache $count times" "
 	test-tool read-cache-perf --count=$count
 "
 
+count=100
+test_perf "refresh_index() $count times" "
+	test-tool read-cache-perf --count=$count --refresh
+"
+
 test_done
-- 
2.33.0.663.gbaff4edb973
Previous: Ævar Arnfjörð BjarmasonNext: Taylor Blau
Message 15 of 18 in “test-tool: split up "read-cache" tool”
  1. 0/4 test-tool: split up "read-cache" toolÆvar Arnfjörð Bjarmason, Jun 7, 2021
  2. 4/4 read-cache perf: add a perf test for refresh_index()Ævar Arnfjörð Bjarmason, Jun 7, 2021
  3. 3/4 test-tools: migrate read-cache-again to parse_options()Ævar Arnfjörð Bjarmason, Jun 7, 2021
  4. 2/4 test-tools: migrate read-cache-perf to parse_options()Ævar Arnfjörð Bjarmason, Jun 7, 2021
  5. 1/4 test-tool: split up test-tool read-cacheÆvar Arnfjörð Bjarmason, Jun 7, 2021
  6. Junio C HamanoJun 7, 2021
  7. Ævar Arnfjörð BjarmasonJun 8, 2021
  8. Junio C HamanoJun 8, 2021
  9. Emily ShafferJun 30, 2021
  10. Ævar Arnfjörð BjarmasonJun 30, 2021
  11. 0/4 test-tool: split up "read-cache" toolÆvar Arnfjörð Bjarmason, Aug 24, 2021
  12. 1/4 test-tool: split up test-tool read-cacheÆvar Arnfjörð Bjarmason, Aug 24, 2021
  13. 2/4 test-tool: migrate read-cache-perf to parse_options()Ævar Arnfjörð Bjarmason, Aug 24, 2021
  14. 3/4 test-tool: migrate read-cache-again to parse_options()Ævar Arnfjörð Bjarmason, Aug 24, 2021
  15. 4/4 read-cache perf: add a perf test for refresh_index()Ævar Arnfjörð Bjarmason, Aug 24, 2021
  16. Taylor BlauAug 24, 2021
  17. Junio C HamanoAug 25, 2021
  18. Ævar Arnfjörð BjarmasonAug 27, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.