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

[PATCH 8/8] receive-pack: check connectivity via quarantined objects

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

Convert git-receive-pack(1) to use the new connectivity check which uses the quarantine directory to enumerate new objects instead of using references. This change significantly decreases the time required to accept reference updates due to the fact that we don't need to do a graph walk anymore. The following measurements have been executed on linux.git:

Test v2.32.0-rc0 HEAD -------------------------------------------------------------------------------------------- 5400.3: receive-pack clone create 1.27(1.11+0.16) 0.02(0.01+0.01) -98.4% 5400.5: receive-pack clone update 1.27(1.13+0.13) 0.02(0.02+0.00) -98.4% 5400.7: receive-pack clone reset 0.13(0.11+0.02) 0.02(0.01+0.01) -84.6% 5400.9: receive-pack clone delete 0.02(0.01+0.01) 0.03(0.02+0.01) +50.0% 5400.11: receive-pack extrarefs create 33.01(18.80+14.43) 9.00(4.30+4.65) -72.7% 5400.13: receive-pack extrarefs update 33.13(18.85+14.50) 9.01(4.28+4.67) -72.8% 5400.15: receive-pack extrarefs reset 32.90(18.82+14.32) 9.04(4.26+4.77) -72.5% 5400.17: receive-pack extrarefs delete 9.13(4.35+4.77) 8.94(4.29+4.64) -2.1% 5400.19: receive-pack empty create 223.35(640.63+127.74) 227.55(651.75+130.94) +1.9%

Interestingly enough, the normal "clone" repository shows a more extreme improvement compared to the "extrarefs" repository, which has one reference per commit. While I haven't yet dived into the root cause, I expect that there is another location besides the connectivity check which does scale with the number of references.

Notably, the connectivity check when pushing into an empty repository shows comparable performance with the previous implementation. This is because in both cases we're actually performing a complete graph walk to determine whether there are any unreachable commits.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 builtin/receive-pack.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index b9263cec15..23087acad0 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1937,8 +1937,12 @@ static void execute_commands(struct command *commands,
 	 * first place. As a result, we do not set up a quarantine environment
 	 * because we know no new objects will be received. And that in turn
 	 * means that we can skip connectivity checks here.
+	 *
+	 * Using the quarantine directory to determine connectivity may not
+	 * work with shallow clones, so let's let's play it safe for now and
+	 * fall back to the old connectivity check.
 	 */
-	if (tmp_objdir) {
+	if (tmp_objdir && (si->nr_ours || si->nr_theirs)) {
 		struct check_connected_options opt = CHECK_CONNECTED_INIT;
 		struct async muxer;
 		int err_fd = 0;
@@ -1960,6 +1964,10 @@ static void execute_commands(struct command *commands,
 
 		if (use_sideband)
 			finish_async(&muxer);
+	} else if (tmp_objdir) {
+		if (check_connected_quarantine(the_repository, tmp_objdir,
+					       iterate_receive_command_list, &data))
+			set_connectivity_errors(commands, si);
 	}
 
 	reject_updates_to_hidden(commands);
-- 
2.31.1
Previous: Jeff KingNext: Chris Torek
Message 16 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.