From patchwork Wed Sep 1 13:10:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12469357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3C42C432BE for ; Wed, 1 Sep 2021 13:10:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 990CE60FED for ; Wed, 1 Sep 2021 13:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344395AbhIANLM (ORCPT ); Wed, 1 Sep 2021 09:11:12 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:58879 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344396AbhIANLG (ORCPT ); Wed, 1 Sep 2021 09:11:06 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 76D545C013C; Wed, 1 Sep 2021 09:10:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 01 Sep 2021 09:10:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=GYOU5gPPQF+G93mSqq/ZTCNWbmP RnjC6KRfDlCIwuCo=; b=m6TBa4plOGHZ75u21Utbds2AD2giTJ6445tntTRbxOb b5Hq7dMPRTVV/MFmG1oymySI8NLn5Vih1PfjrMtdI+K5tYQ6a/ZUjQJkiWSrs+SD Yey9m01fBRrIaxJx2egeDBjqr31R/4xtpH7Db7yxIXVjq55/8xJg0IkuyynNtnuN GGMVHX2yx6Vo0HSxcUJCbtUALC9iuci2J99IezqhK1dQa6Nmgtbmd9WrucODIivI +9RIhgld2cWc2zdzp9qTUCgOXf2bi7nWQLFThvpiudrPLBuwWx9GYEGFTy5V4Ji7 hMIoHvuId6M2XMcBtb8Umuqbe3nuFl7DtwOJ0JBq9fQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=GYOU5g PPQF+G93mSqq/ZTCNWbmPRnjC6KRfDlCIwuCo=; b=afkSZVokY3m/yzRrHEI+Vz tMJu5v8b2zpdoC4SsGNreb/J/cq6yrIPyPD5fUdWxoXtJXeMEn25loUNiL7N4WTO Gq+h7oreoU8L20dlOrvH38dUDYW+nej0lp0ORar0G9W0GhrV5xM+32YdRZQeq6mx 3CRpx1CgOL4LZCM5Yp+ZL90wptshuCQ+hO1w1xcQxFdk3KW7mdhNjamcepXuERbk acOESMWg7TuGLJv/7snvMErWE0CfxlTTI5SrC6hybFZEMREze6MxmkKXTwUHmME+ aKPtqOKvC2RpRkFxcKdyw45nozMg+ec30DzZoK7gp151LiBjQwaRL+VGQvmU0ZLw == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddvfedgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttdejnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrh hnpeehgfejueevjeetudehgffffeffvdejfeejiedvkeffgfekuefgheevteeufeelkeen ucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesph hkshdrihhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 1 Sep 2021 09:10:08 -0400 (EDT) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 9092f07c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 1 Sep 2021 13:10:08 +0000 (UTC) Date: Wed, 1 Sep 2021 15:10:06 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , =?iso-8859-1?q?=C6var_Arnfj=F6r=F0?= Bjarmason , Junio C Hamano , Derrick Stolee , =?iso-8859-1?q?Ren=E9?= Scharfe Subject: [PATCH v3 7/7] fetch: avoid second connectivity check if we already have all objects Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When fetching refs, we are doing two connectivity checks: - The first one is done such that we can skip fetching refs in the case where we already have all objects referenced by the updated set of refs. - The second one verifies that we have all objects after we have fetched objects. We always execute both connectivity checks, but this is wasteful in case the first connectivity check already notices that we have all objects locally available. Skip the second connectivity check in case we already had all objects available. This gives us a nice speedup when doing a mirror-fetch in a repository with about 2.3M refs where the fetching repo already has all objects: Benchmark #1: HEAD~: git-fetch Time (mean ± σ): 30.025 s ± 0.081 s [User: 27.070 s, System: 4.933 s] Range (min … max): 29.900 s … 30.111 s 5 runs Benchmark #2: HEAD: git-fetch Time (mean ± σ): 25.574 s ± 0.177 s [User: 22.855 s, System: 4.683 s] Range (min … max): 25.399 s … 25.765 s 5 runs Summary 'HEAD: git-fetch' ran 1.17 ± 0.01 times faster than 'HEAD~: git-fetch' Signed-off-by: Patrick Steinhardt --- builtin/fetch.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 09f7742d0f..6fdd01fb01 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1293,7 +1293,7 @@ static int check_exist_and_connected(struct ref *ref_map) static int fetch_and_consume_refs(struct transport *transport, struct ref *ref_map) { - int connectivity_checked; + int connectivity_checked = 1; int ret; /* @@ -1307,11 +1307,10 @@ static int fetch_and_consume_refs(struct transport *transport, struct ref *ref_m trace2_region_leave("fetch", "fetch_refs", the_repository); if (ret) goto out; + connectivity_checked = transport->smart_options ? + transport->smart_options->connectivity_checked : 0; } - connectivity_checked = transport->smart_options - ? transport->smart_options->connectivity_checked : 0; - trace2_region_enter("fetch", "consume_refs", the_repository); ret = store_updated_refs(transport->url, transport->remote->name,