From patchwork Thu Apr 4 05:48:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13617304 Received: from fhigh7-smtp.messagingengine.com (fhigh7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1F29208AF for ; Thu, 4 Apr 2024 05:48:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712209703; cv=none; b=o+6CQfiqeVjTvsJCp+S957UxwtMQHvWVP19GGyzjrx0wICgxTd6kBBjV8nIUm28HBoEaHYpaBAIL4+o/GZhMbHo2h61sYCseveOrDafmpJaUUDzwHJDP9ewmdHcdXwL6ag2ow2a07Sma4f7Sj1GrsO4Mby1DTSUR/BsxkOYRNeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712209703; c=relaxed/simple; bh=ey/GG7+CEOlx8VGEgkEZ6Tktl7ZvWmGmm7RTm32wyLA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lS9GCR9xHqG5rEeC6EK2bIIfz9OO2hFigOPigzLkpgC4NllNHLMVcdEUcEGnFhrLFEAM0j2TauLn8mR7Bq4zYWrbThzKf8qXAbk2yK8bSgnRcEiLS3rzGpts3VI2+SaIYnt5VJjef9V1lQbZAP72UjI3oSv/XpyB9jS0+X+82X4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=ehWkrFLK; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=mXKDTQDM; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="ehWkrFLK"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mXKDTQDM" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id B35C61140116; Thu, 4 Apr 2024 01:48:20 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 04 Apr 2024 01:48:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1712209700; x=1712296100; bh=l3+GOPD7B/ sd278+NC3wm1yDk8JIBufNvgRT5/7ZG2c=; b=ehWkrFLKgLrpzhYJK7SQRZOvTI OnX4R2oBU8BVLvywmkk71MUJQfpb0cm0pzXRxkeiGCZVWROi7PA7o9x3mvr4++x3 ocMnxIIv+bm203hvtHM6PAsnpmOZ8bDlBe/rpEortD4pxKu9mGEvdguO35ag3icM uDdnAw6bl1MRWYafRedEP5cM+EZrkxqogXriqlofHaLX1BVOw7cTi97uykjEk0f3 nIQkv6fzFc4zi9ddgqoxb44qMP7nnYLcHr9oquddExe+/mkOcJHErALIFErI3nvn S9qZdt9Him9cRmc1S77RNTmNEUERtgUxC51VksdVyBl6ANQZ2fsdRhXYKcnA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1712209700; x=1712296100; bh=l3+GOPD7B/sd278+NC3wm1yDk8JI BufNvgRT5/7ZG2c=; b=mXKDTQDMWG2woim75d+mXTzw1TjYCccelvrl7DZlkJfs mcuVALyfR2CTku8FaOR8lCtjVt/DMKrYCr7m5kLlcmWDAWhQBuspmM50MTMb2sOy AFJ8LA/fIVLUO2WumiDbpnwlQwx7rqxCuyHXmxmMM7lmAEg+umCwIDsxgJfVOr0O frp8POksPmYjxUiQ/2XYPhoYeefTjMTqopyrUh8N7Hw72FELMdsN5aHQilyF3iD8 YDNI/iCqrJv72rcjfnGaD64kcyH6XO7xoDvwjvjkFMOM3l1Le6kzOnspZ9XU5Utv NggGcgiItC+GD2KDnBqSutjWIeI4UMthWjbxADMtWw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefjedguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvfevuffkfhggtggujgesgh dtreertddtjeenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhs sehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepteeuvefhhfdufedvgeeiueeileegtd fhgeeftdeuveejjedtgfejhedujeeutddunecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Apr 2024 01:48:19 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 134d9060 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 4 Apr 2024 05:48:16 +0000 (UTC) Date: Thu, 4 Apr 2024 07:48:17 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Junio C Hamano , Han-Wen Nienhuys Subject: [PATCH v2 03/11] refs/reftable: skip duplicate name checks Message-ID: <80008cc5e7772f5b6cc93d3cc898b2d2951a3588.1712209149.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: All the callback functions which write refs in the reftable backend perform D/F conflict checks via `refs_verify_refname_available()`. But in reality we perform these D/F conflict checks a second time in the reftable library via `stack_check_addition()`. Interestingly, the code in the reftable library is inferior compared to the generic function: - It is slower than `refs_verify_refname_available()`, even though this can probably be optimized. - It does not provide a proper error message to the caller, and thus all the user would see is a generic "file/directory conflict" message. Disable the D/F conflict checks in the reftable library by setting the `skip_name_check` write option. This results in a non-negligible speedup when writing many refs. The following benchmark writes 100k refs in a single transaction: Benchmark 1: update-ref: create many refs (HEAD~) Time (mean ± σ): 3.241 s ± 0.040 s [User: 1.854 s, System: 1.381 s] Range (min … max): 3.185 s … 3.454 s 100 runs Benchmark 2: update-ref: create many refs (HEAD) Time (mean ± σ): 2.878 s ± 0.024 s [User: 1.506 s, System: 1.367 s] Range (min … max): 2.838 s … 2.960 s 100 runs Summary update-ref: create many refs (HEAD~) ran 1.13 ± 0.02 times faster than update-ref: create many refs (HEAD) Signed-off-by: Patrick Steinhardt --- refs/reftable-backend.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c index 8a54b0d8b2..7515dd3019 100644 --- a/refs/reftable-backend.c +++ b/refs/reftable-backend.c @@ -247,6 +247,11 @@ static struct ref_store *reftable_be_init(struct repository *repo, refs->write_options.block_size = 4096; refs->write_options.hash_id = repo->hash_algo->format_id; refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask); + /* + * We verify names via `refs_verify_refname_available()`, so there is + * no need to do the same checks in the reftable library again. + */ + refs->write_options.skip_name_check = 1; /* * Set up the main reftable stack that is hosted in GIT_COMMON_DIR.