From patchwork Mon Nov 28 14:09:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 13057564 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1464C433FE for ; Mon, 28 Nov 2022 14:10:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232340AbiK1OKN (ORCPT ); Mon, 28 Nov 2022 09:10:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232099AbiK1OKG (ORCPT ); Mon, 28 Nov 2022 09:10:06 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE37A2F7 for ; Mon, 28 Nov 2022 06:10:05 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id k5so9578887pjo.5 for ; Mon, 28 Nov 2022 06:10:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GaX2bT7uVTzl4d9utxx2MU4TwG5fEWKWKpooBTBekfQ=; b=qu6tYkbgIG7ayLEqHjbAhpi16nhaezwU9c3s7f3vh6jkMG1KU7FIZUXptH93xB1E+s cf/z3s/JmcHbCpkVen39kegMkr5OD++Et4hUqj/sOm/1vqx+AfuITFFYXQEhbjrIFD/6 jRuJLE/wd9H4kg0BBbDExhclvZzQU0N7QPxmn2pmWfT5Jmo5RpRYI4xdbCUEn6ESVXDz jm6NWZHHywZOPd4It3IZls9B9j7T/hv+UmE67jY7d3c1EePECuW+/Gnscrhj71qU4xTt ZcbBoQJ/Pja78V3f6Sg0fLVYHIaggnw38rpae1VSlSOJwlcVmBl8/riQcpu8YHKHKMF4 sxLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GaX2bT7uVTzl4d9utxx2MU4TwG5fEWKWKpooBTBekfQ=; b=r6c4UDo/5NShX5zW2P+cUxdLpkY2wW2FnjWtWzWa8Kn1xX50HwjA24RukI5w+DMsqZ OUGcmxl0GWD5x+f4cUt5AwZXHwLRlPGiQ7A3KpOUkM7VQrIshwbS5+LBqUsRUwCc0lpK QzjVNwk0cQQ94zewH+Ji4LmqsNHz298qLA5v66XBlPpaxgV72ou/BwoCJN6DgJXQj+aU LMTxrrMLj40fZbHp9bO5gjENJroFhmhnLnRLo8HWAK4JqO+45hEfAqaOLkdo1CikDefO ByaE2IeProV+slIzN6HJukoPhoJQiGnMmVS8ee7OWAX91zY6ZwFQCRvl+524EBaOFLWz mquQ== X-Gm-Message-State: ANoB5pnohJstHzLRbtbuOqZ/CGUHm9PAqaaJy5+CxzopYvvWYultTsQc iY5RpAFVLFHrsbvRPLSWb5o= X-Google-Smtp-Source: AA0mqf6XfIi4J9jarTUqIP+5GQyFnnTlPPlnRUQ+RxXHLyF5669hsRD3XrV/qBFO+nYjjjNQG8+5kA== X-Received: by 2002:a17:90a:e387:b0:212:da06:88ae with SMTP id b7-20020a17090ae38700b00212da0688aemr54302949pjz.228.1669644605302; Mon, 28 Nov 2022 06:10:05 -0800 (PST) Received: from localhost.localdomain ([47.246.101.57]) by smtp.gmail.com with ESMTPSA id 13-20020a170902c24d00b0017f64ab80e5sm8842819plg.179.2022.11.28.06.10.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2022 06:10:04 -0800 (PST) From: Teng Long X-Google-Original-From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, peff@peff.net, tenglong.tl@alibaba-inc.com Subject: [PATCH v5 1/4] pack-bitmap.c: remove unnecessary "open_pack_index()" calls Date: Mon, 28 Nov 2022 22:09:50 +0800 Message-Id: X-Mailer: git-send-email 2.38.1.385.g28306b7e8d5 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Teng Long When trying to open a pack bitmap, we call open_pack_bitmap_1() in a loop, during which it tries to open up the pack index corresponding with each available pack. It's likely that we'll end up relying on objects in that pack later in the process (in which case we're doing the work of opening the pack index optimistically), but not guaranteed. For instance, consider a repository with a large number of small packs, and one large pack with a bitmap. If we see that bitmap pack last in our loop which calls open_pack_bitmap_1(), the current code will have opened *all* pack index files in the repository. If the request can be served out of the bitmapped pack alone, then the time spent opening these idx files was wasted.S Since open_pack_bitmap_1() calls is_pack_valid() later on (which in turns calls open_pack_index() itself), we can just drop the earlier call altogether. Signed-off-by: Teng Long --- pack-bitmap.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 440407f1be..982e286bac 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -411,9 +411,6 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git struct stat st; char *bitmap_name; - if (open_pack_index(packfile)) - return -1; - bitmap_name = pack_bitmap_filename(packfile); fd = git_open(bitmap_name); From patchwork Mon Nov 28 14:09:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 13057565 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D49A8C43217 for ; Mon, 28 Nov 2022 14:10:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232123AbiK1OKP (ORCPT ); Mon, 28 Nov 2022 09:10:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232233AbiK1OKJ (ORCPT ); Mon, 28 Nov 2022 09:10:09 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA5FE3AB for ; Mon, 28 Nov 2022 06:10:08 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id s196so10020525pgs.3 for ; Mon, 28 Nov 2022 06:10:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J1RYpHYSUKbhu8r3cf8HAvYclchOWchCOjxqlJBnTkM=; b=EAumgRZQQkNxQliqFdM3CVIspMN0v6F6dIGLM0XwdKZqlTPKKkGLNRoiI80exkFR57 vQP4KeU+cQNREb0iSpKQXwIFLbJel/Cwffn3m1tKELPC99jXm2AZm0N/9oz/u/KEP8Fd cIG5GpTq0P0xbMSLCNh/nQG4Z80jE74z51XeSNc7ZBb7DCgbF35xpNH/SvFqrLkeOkcP eI2en2R9R4Q9JLa+RoQPhHdUCYK+7IOL3gSf1nljo6IYKBcYchxZhqT3vH/6UDvB5gkN 2/REzXa7AZK20l28sCGhBTirygyIk0F8o6pI18D1lwlMCe2nNO8l10vFHOK1dpErq4r0 Eirw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J1RYpHYSUKbhu8r3cf8HAvYclchOWchCOjxqlJBnTkM=; b=ch+PS4P92fdw/4P7qCUXTeLjgrIkHzy4nTTWdVhu/6fMM8UmrKaP4VLuNt38xNgGio aJqcgPGp3GDIAzOjNAR8Rkke+XmR1m5C/8BTtTwgnh2VNmpJZnVEM6GXoAtG5TSBdpes LbVpsxIaXIXfnxnQczomK5yHu20Ufr9Hk0R+JhGRAZIuFIl0frfn1cvjy1SciTldoJCj WU6fNvTYEgLvhoWcL4WGK49lpZfYERS2+8zfyefqIwjR4BToJ42nfqaCjmL3ktuJFFWq kz/iLFuZSCMd3ZB4n2xODdqC5shcnaMzSZux9TjFMRIMpBOq0rMyt/eav1FOMQFF1Y5Z ZOpw== X-Gm-Message-State: ANoB5plolmzKLMvxks3It0lx7Q3S6yRnuMEiWo3P9PM7SpolzLcQeHyj oegX1BQNtX3u9wmJa1O6YmU= X-Google-Smtp-Source: AA0mqf5FwSZph5UL8QSASEuqqqtRHOsf7s8AdYQpk+31rfREPf1L2HZ3U0lEbMwgUc3OZs6mx7SBXw== X-Received: by 2002:a65:58ca:0:b0:470:2c91:9579 with SMTP id e10-20020a6558ca000000b004702c919579mr26920965pgu.22.1669644608439; Mon, 28 Nov 2022 06:10:08 -0800 (PST) Received: from localhost.localdomain ([47.246.101.57]) by smtp.gmail.com with ESMTPSA id 13-20020a170902c24d00b0017f64ab80e5sm8842819plg.179.2022.11.28.06.10.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2022 06:10:07 -0800 (PST) From: Teng Long X-Google-Original-From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, peff@peff.net, tenglong.tl@alibaba-inc.com, XingXin Subject: [PATCH v5 2/4] pack-bitmap.c: avoid exposing absolute paths Date: Mon, 28 Nov 2022 22:09:51 +0800 Message-Id: <9d5a491887b57bbcc30010aa7efb63e316c6d190.1669644101.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.38.1.385.g28306b7e8d5 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Teng Long In "open_midx_bitmap_1()" and "open_pack_bitmap_1()", when we find that there are multiple bitmaps, we will only open the first one and then leave warnings about the remaining pack information, the information will contain the absolute path of the repository, for example in a alternates usage scenario. So let's hide this kind of potentially sensitive information in this commit. Found-by: XingXin Signed-off-by: Teng Long --- pack-bitmap.c | 10 ++++++---- t/t5310-pack-bitmaps.sh | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 982e286bac..aaa2d9a104 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -354,8 +354,8 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git, if (bitmap_git->pack || bitmap_git->midx) { struct strbuf buf = STRBUF_INIT; get_midx_filename(&buf, midx->object_dir); - /* ignore extra bitmap file; we can only handle one */ - warning(_("ignoring extra bitmap file: '%s'"), buf.buf); + trace2_data_string("bitmap", the_repository, + "ignoring extra midx bitmap file", buf.buf); close(fd); strbuf_release(&buf); return -1; @@ -429,8 +429,8 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git } if (bitmap_git->pack || bitmap_git->midx) { - /* ignore extra bitmap file; we can only handle one */ - warning(_("ignoring extra bitmap file: '%s'"), packfile->pack_name); + trace2_data_string("bitmap", the_repository, + "ignoring extra bitmap file", packfile->pack_name); close(fd); return -1; } @@ -455,6 +455,8 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git return -1; } + trace2_data_string("bitmap", the_repository, "opened bitmap file", + packfile->pack_name); return 0; } diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh index 6d693eef82..7d8dee41b0 100755 --- a/t/t5310-pack-bitmaps.sh +++ b/t/t5310-pack-bitmaps.sh @@ -428,8 +428,9 @@ test_bitmap_cases () { test_line_count = 2 packs && test_line_count = 2 bitmaps && - git rev-list --use-bitmap-index HEAD 2>err && - grep "ignoring extra bitmap file" err + GIT_TRACE2_EVENT=$(pwd)/trace2.txt git rev-list --use-bitmap-index HEAD && + grep "opened bitmap" trace2.txt && + grep "ignoring extra bitmap" trace2.txt ) ' } From patchwork Mon Nov 28 14:09:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 13057566 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E287DC433FE for ; Mon, 28 Nov 2022 14:10:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232357AbiK1OKS (ORCPT ); Mon, 28 Nov 2022 09:10:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232336AbiK1OKM (ORCPT ); Mon, 28 Nov 2022 09:10:12 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B105110F3 for ; Mon, 28 Nov 2022 06:10:11 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id 9so10555836pfx.11 for ; Mon, 28 Nov 2022 06:10:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QcX6O+2x7hVt7hCMHxxPsA7VyEPMDY+1esqmocG1yhA=; b=c2/njlOp0FJcBQEpwRNi18VE8tndGzZG2UZqyoMgSky25Ayrt9bwAxvC3bWSHFPMfK M9Zlp8HWNqAbgOgSRV53DUvXhJXUVMlKmspr1qKJ07+a+C2ChHTKXBbTxj94RL+X7uq9 JCHICXX66BQP4vxKTrXNcH8y1SGF0wpJ/zfLSPt5Jag4usAUB+saaYLSi8ge27hULMpm S35CtM/016aremk0+R6YtN1r4u4FqlFwCI4yLxXnKwvVmxWbw26n+jBk8ACybySDb7XG AglXJHzchAWIeUuMp5vF9brHbbMInyUKoAEQCepiy4tLX9w5CUr2gDU7jhMrQ4L00WoJ 2spQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QcX6O+2x7hVt7hCMHxxPsA7VyEPMDY+1esqmocG1yhA=; b=AAH6r5pyLwg7XeC2rmqzaT9oePjnLn6JK0rpffV3i8v7PhAB5KoFVMdjS5abkthxKp PYFGlpn6nOSUg76KFwCQBIA+ed3jnJvZrVY5ysc4WmPHnAx+2CPsI9acm5RZIBBPg4Za GMO7d0SKeCrzJvQysDm12VkKWw2eb7riBXT/92Dn++1RzKyleN3yf3zVg4/wolOD0AE9 /aT2+cGae3zkTPanSfdt0y42VLiEh1+S3/o0I85P7pZCHRZwxLHGTpzSNZiOmPFlbdTq mECHcWzqY8X7tJJV1+a7CJTv9R0eGgmGLvAw+cgZGRH30DmPK5+Vsk3Dm1yF/cFJuE4Y 19NA== X-Gm-Message-State: ANoB5pkD7ujlNa6kaYnfwZJOC7pXZh7wI+FozCoBaL1fGIywKMKp/50/ D7rRLapX8cH6a0tnzJM5/z0= X-Google-Smtp-Source: AA0mqf7kTfcQcC1tCJzM1mhyXE+1vE8n6jerE+rKqCCNR5EQRBJ9X9P1I26Lb5SuxbVl95cD62Zapw== X-Received: by 2002:aa7:800f:0:b0:575:5774:44b5 with SMTP id j15-20020aa7800f000000b00575577444b5mr1760599pfi.5.1669644611159; Mon, 28 Nov 2022 06:10:11 -0800 (PST) Received: from localhost.localdomain ([47.246.101.57]) by smtp.gmail.com with ESMTPSA id 13-20020a170902c24d00b0017f64ab80e5sm8842819plg.179.2022.11.28.06.10.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2022 06:10:10 -0800 (PST) From: Teng Long X-Google-Original-From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, peff@peff.net, tenglong.tl@alibaba-inc.com Subject: [PATCH v5 3/4] pack-bitmap.c: break out of the bitmap loop early if not tracing Date: Mon, 28 Nov 2022 22:09:52 +0800 Message-Id: <22deec6aab6649b228af7d858b93672f9ce2b925.1669644101.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.38.1.385.g28306b7e8d5 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff King After opening a bitmap successfully, we try opening others only because we want to report that other bitmap files are ignored in the trace2 log. When trace2 is not enabled, we do not have to do any of that. Signed-off-by: Jeff King Signed-off-by: Teng Long --- pack-bitmap.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index aaa2d9a104..3b6c2f804a 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -527,8 +527,15 @@ static int open_pack_bitmap(struct repository *r, assert(!bitmap_git->map); for (p = get_all_packs(r); p; p = p->next) { - if (open_pack_bitmap_1(bitmap_git, p) == 0) + if (open_pack_bitmap_1(bitmap_git, p) == 0) { ret = 0; + /* + * The only reason to keep looking is to report + * duplicates. + */ + if (!trace2_is_enabled()) + break; + } } return ret; From patchwork Mon Nov 28 14:09:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 13057567 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACE17C433FE for ; Mon, 28 Nov 2022 14:10:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232414AbiK1OKj (ORCPT ); Mon, 28 Nov 2022 09:10:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232333AbiK1OKT (ORCPT ); Mon, 28 Nov 2022 09:10:19 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D10AA1084 for ; Mon, 28 Nov 2022 06:10:14 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id b21so10240458plc.9 for ; Mon, 28 Nov 2022 06:10:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GYzX5I6rIXKYxYK9hhceUWgq+/nrljfdmEc4WBAJG5U=; b=MGpY1Vx6nD+jR206gHvK29FAkyJd25vimQqZSQEmN0zWowc+4/7MMlGIdZdigNxnfd jklt0Svb97kQEdkEDN7NCM/4M/dsdkkleoKglQE9wyKDCLexwEH88JAUZMih33etVW1p 6yHAtFdlrtqNGm+TN13JeVZotDi2biey/3H1ftV0uP/FLyrfPLaKAQ/KyuEr47Kzdghs SDrkkIIvAn4FowP4NVFFjqho4PH3paSXxN0QmRbYhkhljcpCrrWU8xNBtQ+KNMTwbvaF aga+STsDhPoAGWs6SPfB4PuZmfVRarAqLG9bry6TMsKwTnOmfjEI3OVD2xH2WQo5/Zyg 7ckg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GYzX5I6rIXKYxYK9hhceUWgq+/nrljfdmEc4WBAJG5U=; b=Zthlr4AdqDKN8ZfixJIrdMx4EZP5Uhu3QIvjJWc5cX4Y4qw6P/drAv6zWMyFDUCDEa dqWj1BJFylBuTytiG2siz1VvlGCtet58bZhyOwQoBlL14o1VqNlYU14TjozHQ9/gSs+D FEgeBdIsYgnk8OE/rSCKCrOmCP85SXuuxVG3jL4yJK07p4Gxz+Ki1d4B2gvdyXBDHGSX 9zhcCzJ0wcMR4+7vWnfR05hVZ35ROkBnBj6MsN66Cjvwp4Vp+D1ABiRB8A8MJtrCh7eA 7jXcB0/s4ixYYjaaxqfYIl+hF1Du2MFHMU2yzcDRwLj0Rv1Tgk/pfHAuXsbL+L+yjAB8 Xo6A== X-Gm-Message-State: ANoB5pk3QlahPSB5LImlqJAdByyFvCGzdiREU3XFLmr7eHawsNTAdZCa Hbw5NBbZ7lpUrkBRalyslOI= X-Google-Smtp-Source: AA0mqf6i6HbLXlEcgQQEVslg0XJi0wSk7KBqfiWNA9Mio6bzvQCFdUabt3L97qGQNsL5uOKyrOgY8Q== X-Received: by 2002:a17:90a:de90:b0:219:44f2:8618 with SMTP id n16-20020a17090ade9000b0021944f28618mr1614555pjv.79.1669644614275; Mon, 28 Nov 2022 06:10:14 -0800 (PST) Received: from localhost.localdomain ([47.246.101.57]) by smtp.gmail.com with ESMTPSA id 13-20020a170902c24d00b0017f64ab80e5sm8842819plg.179.2022.11.28.06.10.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2022 06:10:13 -0800 (PST) From: Teng Long X-Google-Original-From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, peff@peff.net, tenglong.tl@alibaba-inc.com Subject: [PATCH v5 4/4] pack-bitmap.c: trace bitmap ignore logs when midx-bitmap is found Date: Mon, 28 Nov 2022 22:09:53 +0800 Message-Id: <28306b7e8d560f48d3546527c1f60f5126eeb8a1.1669644101.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.38.1.385.g28306b7e8d5 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff King When we find a midx bitmap, we do not bother checking for pack bitmaps, since we can use only one. But since we will warn of unused bitmaps via trace2, let's continue looking for pack bitmaps when tracing is enabled. Signed-off-by: Jeff King Signed-off-by: Teng Long --- pack-bitmap.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 3b6c2f804a..d2a42abf28 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -524,8 +524,6 @@ static int open_pack_bitmap(struct repository *r, struct packed_git *p; int ret = -1; - assert(!bitmap_git->map); - for (p = get_all_packs(r); p; p = p->next) { if (open_pack_bitmap_1(bitmap_git, p) == 0) { ret = 0; @@ -559,11 +557,20 @@ static int open_midx_bitmap(struct repository *r, static int open_bitmap(struct repository *r, struct bitmap_index *bitmap_git) { + int found; + assert(!bitmap_git->map); - if (!open_midx_bitmap(r, bitmap_git)) - return 0; - return open_pack_bitmap(r, bitmap_git); + found = !open_midx_bitmap(r, bitmap_git); + + /* + * these will all be skipped if we opened a midx bitmap; but run it + * anyway if tracing is enabled to report the duplicates + */ + if (!found || trace2_is_enabled()) + found |= !open_pack_bitmap(r, bitmap_git); + + return found ? 0 : -1; } struct bitmap_index *prepare_bitmap_git(struct repository *r)