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

[PATCH 2/8] p5400: add perf tests for git-receive-pack(1)

From
Patrick Steinhardt <ps@pks.im>
Date
May 19, 2021, 19:13 UTC
Message-ID
<f248b41d6e2df2d34a4304e2655df8cb094483e9.1621451532.git.ps@pks.im>
In-Reply-To
<cover.1621451532.git.ps@pks.im>

We'll the connectivity check logic for git-receive-pack(1) in the following commits to make it perform better. As a preparatory step, add some benchmarks such that we can measure these changes.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/perf/p5400-receive-pack.sh | 74 ++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100755 t/perf/p5400-receive-pack.sh
diff --git a/t/perf/p5400-receive-pack.sh b/t/perf/p5400-receive-pack.sh
new file mode 100755
index 0000000000..2b0c89d977
--- /dev/null
+++ b/t/perf/p5400-receive-pack.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+test_description="Tests performance of receive-pack"
+
+. ./perf-lib.sh
+
+test_perf_large_repo
+
+test_expect_success 'setup' '
+	# Create a main branch such that we do not have to rely on any specific
+	# branch to exist in the perf repository.
+	git switch --force-create main &&
+
+	TARGET_REPO_CLONE=$(pwd)/target-clone.git &&
+	git clone --bare --dissociate --branch main "$(pwd)" "$TARGET_REPO_CLONE" &&
+	TARGET_REPO_REFS=$(pwd)/target-refs.git &&
+	git clone --bare --dissociate --branch main "$(pwd)" "$TARGET_REPO_REFS" &&
+	TARGET_REPO_EMPTY=$(pwd)/target-empty.git &&
+	git init --bare "$TARGET_REPO_EMPTY" &&
+
+	# Set up a pre-receive hook such that no refs will ever be changed.
+	# This easily allows multiple perf runs, but still exercises
+	# server-side reference negotiation and checking for consistency.
+	mkdir hooks &&
+	write_script hooks/pre-receive <<-EOF &&
+		#!/bin/sh
+		echo "failed in pre-receive hook"
+		exit 1
+	EOF
+	cat >config <<-EOF &&
+		[core]
+			hooksPath=$(pwd)/hooks
+	EOF
+	GIT_CONFIG_GLOBAL="$(pwd)/config" &&
+	export GIT_CONFIG_GLOBAL &&
+
+	# Create a reference for each commit in the target repository with
+	# extra-refs. While this may be an atypical setup, biggish repositories
+	# easily end up with hundreds of thousands of refs, and this is a good
+	# enough approximation.
+	git -C "$TARGET_REPO_REFS" log --all --format="tformat:create refs/commit/%h %H" |
+		git -C "$TARGET_REPO_REFS" update-ref --stdin &&
+
+	git switch --create updated &&
+	test_commit --no-tag updated
+'
+
+while read name repo
+do
+	refs=("create updated:new")
+
+	# If the target repository is the empty one, then the only thing we can
+	# do is to create a new branch.
+	if test "$repo" != "$TARGET_REPO_EMPTY"
+	then
+		refs+=("update updated:main" "reset main~:main" "delete :main")
+	fi
+
+	while read desc ref
+	do
+		test_expect_success "setup $name $desc" "
+			test_must_fail git push --force '$repo' '$ref' \
+				--receive-pack='tee pack | git receive-pack' 2>err &&
+			grep 'failed in pre-receive hook' err
+		"
+
+		test_perf "receive-pack $name $desc" "
+			git receive-pack '$repo' <pack >negotiation &&
+			grep 'pre-receive hook declined' negotiation
+		"
+	done < <(printf "%s\n" "${refs[@]}")
+done < <(printf "%s\n" "clone $TARGET_REPO_CLONE" "extrarefs $TARGET_REPO_REFS" "empty $TARGET_REPO_EMPTY")
+
+test_done
-- 
2.31.1
Previous: Chris TorekNext: Chris Torek
Message 4 of 22 in “Speed up connectivity checks via quarantine dir”
  1. 0/8 Speed up connectivity checks via quarantine dirPatrick Steinhardt, May 19, 2021
  2. 1/8 perf: fix when running with TEST_OUTPUT_DIRECTORYPatrick Steinhardt, May 19, 2021
  3. Chris TorekMay 20, 2021
  4. 2/8 p5400: add perf tests for git-receive-pack(1)Patrick Steinhardt, May 19, 2021
  5. Chris TorekMay 20, 2021
  6. Jeff KingMay 20, 2021
  7. SZEDER GáborMay 21, 2021
  8. 3/8 tmp-objdir: expose function to retrieve pathPatrick Steinhardt, May 19, 2021
  9. Elijah NewrenMay 20, 2021
  10. 4/8 packfile: have `for_each_file_in_pack_dir()` return error codesPatrick Steinhardt, May 19, 2021
  11. 5/8 object-file: allow reading loose objects without reading their contentsPatrick Steinhardt, May 19, 2021
  12. 6/8 connected: implement connectivity check via temporary object dirsPatrick Steinhardt, May 19, 2021
  13. 7/8 receive-pack: skip connectivity checks on delete-only commandsPatrick Steinhardt, May 19, 2021
  14. Felipe ContrerasMay 21, 2021
  15. Jeff KingMay 27, 2021
  16. 8/8 receive-pack: check connectivity via quarantined objectsPatrick Steinhardt, May 19, 2021
  17. Chris TorekMay 20, 2021
  18. Jeff KingMay 20, 2021
  19. Junio C HamanoMay 20, 2021
  20. Jeff KingMay 21, 2021
  21. Patrick SteinhardtMay 21, 2021
  22. Ævar Arnfjörð BjarmasonMay 21, 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.