From patchwork Mon Mar 1 12:20:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12109599 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 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 C6CC0C433DB for ; Mon, 1 Mar 2021 12:22:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D92F64E31 for ; Mon, 1 Mar 2021 12:22:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234295AbhCAMWT (ORCPT ); Mon, 1 Mar 2021 07:22:19 -0500 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:46577 "EHLO wout5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233527AbhCAMWT (ORCPT ); Mon, 1 Mar 2021 07:22:19 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id B22169C2; Mon, 1 Mar 2021 07:21:00 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 01 Mar 2021 07:21:00 -0500 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=fm3; bh=7hvKXCeuliUe+Sz4hQ0vOhe4psM aAE1nTB2iz4pkpa8=; b=Hz7+Qm6R1FnmaBmK374a1BzqNb3tUtPQRxeodjM9Vbz YEjObkwlv0+YWUTVWeRCoOpERRUKWoPai+oTMaZtWjXBa2rdIXTrr94OaJmzmRP/ BIkTYryqOG7kOT7W0yHn8Ld0z/fSob4eLUo8sF0j+AxQrPPevWea9k0tp75RpFzM L6Ee0oXa+K+s+XQmBBNu3p+0fhA7wcEXhFv2d/AQAm2JXENW1HRndUzPh0rKa8uo 2niU8HxVLeCf+lplmkfHHjTCBw36GXycwiNSgaRV3th6RQFiw3U35VpqDQ4wDplC Q5LwSNoENs6kfGWmGSey8aced2x1NPetUtAhEFcKBiA== 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=fm2; bh=7hvKXC euliUe+Sz4hQ0vOhe4psMaAE1nTB2iz4pkpa8=; b=wqNj/+qNHZWZ9fc6f4/djq Tym7y8v/TPUE4pzEwj2H4t2PQ9vs6HprSwASihu7z4Ggw632TVHn7BHAmti1/tVL hQIt4H3eUzaPTFzV00BD5jYcdpoMl8WrkmZ/VLrSgNZZt7SQvbnN4JAHa2zxBzCR 5GRigXjrOpxtHR+D+FZz2SDD1p00wpablw6bnDoa0oZH6JSEpt9/cY35wGc0d/33 wBfm2aBxVi5v95TjEE0gRL1S1dW0QbMjGR0nQtLzgf+c0ErWbl4c2kXymAioz+fD w1SQDZJzfRKzvSOupRME49OniB+2Hy+kAXV13yJp33N+jY0lw4949o1kluuBFR8A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrleekgdefjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhrihgt khcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnh epheeghfdtfeeuffehkefgffduleffjedthfdvjeektdfhhedvlefgtefgvdettdfhnecu kfhppeejjedrudeluddrvdejrddufedvnecuvehluhhsthgvrhfuihiivgepudenucfrrg hrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Received: from vm-mail.pks.im (x4dbf1b84.dyn.telefonica.de [77.191.27.132]) by mail.messagingengine.com (Postfix) with ESMTPA id E2C03240057; Mon, 1 Mar 2021 07:20:59 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 5c9e9b97 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 1 Mar 2021 12:20:58 +0000 (UTC) Date: Mon, 1 Mar 2021 13:20:56 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Christian Couder Subject: [PATCH 6/7] pack-bitmap: implement combined filter 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 the user has multiple objects filters specified, then this is internally represented by having a "combined" filter. These combined filters aren't yet supported by bitmap indices and can thus not be accelerated. Fix this by implementing support for these combined filters. The implementation is quite trivial: when there's a combined filter, we simply recurse into `filter_bitmap()` for all of the sub-filters. Signed-off-by: Patrick Steinhardt --- pack-bitmap.c | 40 +++++++++++++++++++++++++++--- t/t6113-rev-list-bitmap-filters.sh | 7 ++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 196d38c91d..e33805e076 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -925,6 +925,29 @@ static void filter_bitmap_object_type(struct bitmap_index *bitmap_git, } } +static int filter_supported(struct list_objects_filter_options *filter) +{ + int i; + + switch (filter->choice) { + case LOFC_BLOB_NONE: + case LOFC_BLOB_LIMIT: + case LOFC_OBJECT_TYPE: + return 1; + case LOFC_TREE_DEPTH: + if (filter->tree_exclude_depth == 0) + return 1; + return 0; + case LOFC_COMBINE: + for (i = 0; i < filter->sub_nr; i++) + if (!filter_supported(&filter->sub[i])) + return 0; + return 1; + default: + return 0; + } +} + static int filter_bitmap(struct bitmap_index *bitmap_git, struct object_list *tip_objects, struct bitmap *to_filter, @@ -932,6 +955,8 @@ static int filter_bitmap(struct bitmap_index *bitmap_git, { if (!filter || filter->choice == LOFC_DISABLED) return 0; + if (!filter_supported(filter)) + return -1; if (filter->choice == LOFC_BLOB_NONE) { if (bitmap_git) @@ -948,8 +973,7 @@ static int filter_bitmap(struct bitmap_index *bitmap_git, return 0; } - if (filter->choice == LOFC_TREE_DEPTH && - filter->tree_exclude_depth == 0) { + if (filter->choice == LOFC_TREE_DEPTH) { if (bitmap_git) filter_bitmap_tree_depth(bitmap_git, tip_objects, to_filter, @@ -965,8 +989,16 @@ static int filter_bitmap(struct bitmap_index *bitmap_git, return 0; } - /* filter choice not handled */ - return -1; + if (filter->choice == LOFC_COMBINE) { + int i; + for (i = 0; i < filter->sub_nr; i++) { + filter_bitmap(bitmap_git, tip_objects, to_filter, + &filter->sub[i]); + } + return 0; + } + + BUG("unsupported filter choice"); } static int can_filter_bitmap(struct list_objects_filter_options *filter) diff --git a/t/t6113-rev-list-bitmap-filters.sh b/t/t6113-rev-list-bitmap-filters.sh index fb66735ac8..cb9db7df6f 100755 --- a/t/t6113-rev-list-bitmap-filters.sh +++ b/t/t6113-rev-list-bitmap-filters.sh @@ -98,4 +98,11 @@ test_expect_success 'object:type filter' ' test_bitmap_traversal expect actual ' +test_expect_success 'combine filter' ' + git rev-list --objects --filter=blob:limit=1000 --filter=object:type=blob tag >expect && + git rev-list --use-bitmap-index \ + --objects --filter=blob:limit=1000 --filter=object:type=blob tag >actual && + test_bitmap_traversal expect actual +' + test_done