From patchwork Thu Jul 1 03:46:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12353555 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 5CBE5C11F6B for ; Thu, 1 Jul 2021 03:46:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26C5B61480 for ; Thu, 1 Jul 2021 03:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233679AbhGADsy (ORCPT ); Wed, 30 Jun 2021 23:48:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232836AbhGADsw (ORCPT ); Wed, 30 Jun 2021 23:48:52 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC686C0617A8 for ; Wed, 30 Jun 2021 20:46:20 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id j34so3446194wms.5 for ; Wed, 30 Jun 2021 20:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=UtksxVEuW8oPlg3lwNLFR4T2YJ+49CjWCzglLfAr+Zc=; b=OFrnRl2DskHsS/SdGZP5KGonHyEx4zLcstMhhY1FXUJNYSz0N0bZn+PxqdngkaeeJ5 TZc6Lt3cfRrakiseUS0xNfm4aiCRU3k0nTzuPPaFohuq1T3QGpu2L9XB5seRcJkTwuWk gLN84Otx0DIhfZXxW5t4XYe0rne9osQn+Xd0ycn9bI3KguWa0h01kYNptPBvMddAvPyj AG23nkLh8GtPRo40L8U/4/lcTpKIEHB1YffgbByLfcUh/5aY9jC48Dee9lHxZKyA5LsI KqEL+pWmpmyOIpueuk1bqaYvjLFgNXTch8U4Le0r2jzGhTZbv+qxmrDBDefA5OgWbmGp TUPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=UtksxVEuW8oPlg3lwNLFR4T2YJ+49CjWCzglLfAr+Zc=; b=MRNRnvR7O/AXkhv1Re8qsdFb3bmAzvvJ+eDXatupXzwfnZwKiPI2oyBoO8spUdjPIy MU0mSI8OS+eefr5JUJXhgbLmF1qMa5GSUaoCWT4+RmU82QKSQ6Rfdrf/AHKb9DPY9s7s YjgRSAFeL+bb2QT6tQh69Bjh9IBnb4b+aqPF7LD9+un9SehgRMiobthgxEmuqpg0UQXQ sIKJe+qfJlxdYw6J2Imx3aMKJLEmuB2KAVaKh6uCLOLMBipVJ64WUuNrLA38A+hHm14J rZip9Xv6E6KqzVWDgUwlrhRlkieC+Z8abIn6WOpECHNoXrx6c8FHlTG77Q9fZyXFpgJP O/lQ== X-Gm-Message-State: AOAM532RYqSXRvq/ViIT7cdkDTD8IuudBvS/6+T4m4BZEDoA4R9+Cl1f NbUP1dTZeAYx/y/Yfl0/LmIVmD7aWdc= X-Google-Smtp-Source: ABdhPJy2C5ATiTp7hCa0BVt5uJkpXbTdceW408twcp+oFHn4xqXfm+KosKQ0WKAu3lLR/Yf50FICSA== X-Received: by 2002:a7b:c042:: with SMTP id u2mr40894047wmc.127.1625111179392; Wed, 30 Jun 2021 20:46:19 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k16sm6921218wru.79.2021.06.30.20.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 20:46:19 -0700 (PDT) Message-Id: <5dca982c0b061ae8d6335d4f22b78811dced054a.1625111177.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 01 Jul 2021 03:46:11 +0000 Subject: [PATCH 1/7] merge-ort: resolve paths early when we have sufficient information Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren When there are no directories involved at a given path, and all three sides have a file at that path, and two of the three sides of history match, we can immediately resolve the merge of that path in collect_merge_info() and do not need to wait until process_entries(). This is actually a very minor improvement: half the time when I run it, I see an improvement; the other half a slowdown. It seems to be in the range of noise. However, this idea serves as the beginning of some bigger optimizations coming in the following patches. Signed-off-by: Elijah Newren --- merge-ort.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/merge-ort.c b/merge-ort.c index e3a5dfc7b31..6299b4f9413 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -1023,6 +1023,43 @@ static int collect_merge_info_callback(int n, return mask; } + /* + * If the sides match, and all three paths are present and are + * files, then we can take either as the resolution. We can't do + * this with trees, because there may be rename sources from the + * merge_base. + */ + if (sides_match && filemask == 0x07) { + /* use side1 (== side2) version as resolution */ + setup_path_info(opt, &pi, dirname, info->pathlen, fullpath, + names, names+1, side1_null, 0, + filemask, dirmask, 1); + return mask; + } + + /* + * If side1 matches mbase and all three paths are present and are + * files, then we can use side2 as the resolution. We cannot + * necessarily do so this for trees, because there may be rename + * destinations within side2. + */ + if (side1_matches_mbase && filemask == 0x07) { + /* use side2 version as resolution */ + setup_path_info(opt, &pi, dirname, info->pathlen, fullpath, + names, names+2, side2_null, 0, + filemask, dirmask, 1); + return mask; + } + + /* Similar to above but swapping sides 1 and 2 */ + if (side2_matches_mbase && filemask == 0x07) { + /* use side1 version as resolution */ + setup_path_info(opt, &pi, dirname, info->pathlen, fullpath, + names, names+1, side1_null, 0, + filemask, dirmask, 1); + return mask; + } + /* * Gather additional information used in rename detection. */ From patchwork Thu Jul 1 03:46:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12353551 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 3DB1EC11F69 for ; Thu, 1 Jul 2021 03:46:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1028C6147D for ; Thu, 1 Jul 2021 03:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233530AbhGADsx (ORCPT ); Wed, 30 Jun 2021 23:48:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232930AbhGADsw (ORCPT ); Wed, 30 Jun 2021 23:48:52 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62C41C0617AD for ; Wed, 30 Jun 2021 20:46:21 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id p8so6282738wrr.1 for ; Wed, 30 Jun 2021 20:46:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=jTYYZdm9bq7NPN5b67LXlVdIpBH+R0ThjCtl7RWxqOU=; b=Eise8by0JYnyKEnZLYOpo4QihEu+67Wqhh9e4vqRsxCDVj6tNAxVXDRiaEwBCm6Z9n dy7l7C69rPz1iK6lJs0fPmzHDsoYtw+bh+AwRzlgpdG/PDeUAUlw5wabF2Exd74lkU/0 VyUSSp6/jAnURn4EvenmkHAvB6+wZDYVyqgd98GMtOhXq1D+4sn0ogeTJdrnWH9XfJAh Hsdm0EqjCxGccF9NdDjeWSckWxJii1SDItEa70MDJjBk1qgHTBCLXcY84iFK8ZgUjpiW Y9sz1yVfTAAUlxz96aJwO6zqtqdxMEHEbYJ/L3Lij+fz9pCxXkqilvrQBleGyIFEE1jC qh8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=jTYYZdm9bq7NPN5b67LXlVdIpBH+R0ThjCtl7RWxqOU=; b=AWDWdiCgED2DSR3MxKDTl/9tSpCvlJfh8oAeRwpz6T/nzEwq8aTayFls+oPmGOGmLJ YbZzwxZHQGNpgTiWWn2/7l5dFl1jnZxqCTuy7CexJKm41UGVdc1nN677vxH+IrEM/ESI EcatSGz9laVWkTqWz5kZLoltNnucf4cnoVgF0T+uXfozgJIP1bWWH/liDsVjV9Euql92 RsHiiwBlYtRvE8wxTNCH8u2Oh+WvbBJ94uFJlQe9y9euo3rGDxwKpkF2NdpNOCQyFfYT UniSdwCiLfHSrMfuC1346sR7714AkZz7c5+Oeldb4Bv7mwwRulSrfNhipUYAbijJeL5X bzqw== X-Gm-Message-State: AOAM532NLOP87DFSWK71IUaxBLjQg+x9bJWIcB5QWZ/fdMU9w7fwHkYA AuvYcNYz9aw3T+HCPZIDPxzkjisHHcw= X-Google-Smtp-Source: ABdhPJzM5NSDPaMkJYvWJCPnY7kJGo7YGSJ+oEo31pWunBi7IepEQ8ySC3lcI/tPzRQrRTfMANU7HA== X-Received: by 2002:adf:9bd0:: with SMTP id e16mr43205254wrc.392.1625111179967; Wed, 30 Jun 2021 20:46:19 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k6sm21408139wms.8.2021.06.30.20.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 20:46:19 -0700 (PDT) Message-Id: <8aea3713902b7d006f527ccd76faf6f944529bdb.1625111177.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 01 Jul 2021 03:46:12 +0000 Subject: [PATCH 2/7] merge-ort: add some more explanations in collect_merge_info_callback() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren The previous patch possibly raises some questions about whether additional cases in collect_merge_info_callback() can be handled early. Add some explanations in the form of comments to help explain these better. While we're at it, add a few comments to denote what a few boolean '0' or '1' values stand for. Signed-off-by: Elijah Newren --- merge-ort.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index 6299b4f9413..843fa693145 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -1018,8 +1018,8 @@ static int collect_merge_info_callback(int n, if (side1_matches_mbase && side2_matches_mbase) { /* mbase, side1, & side2 all match; use mbase as resolution */ setup_path_info(opt, &pi, dirname, info->pathlen, fullpath, - names, names+0, mbase_null, 0, - filemask, dirmask, 1); + names, names+0, mbase_null, 0 /* df_conflict */, + filemask, dirmask, 1 /* resolved */); return mask; } @@ -1061,14 +1061,24 @@ static int collect_merge_info_callback(int n, } /* - * Gather additional information used in rename detection. + * Sometimes we can tell that a source path need not be included in + * rename detection -- namely, whenever either + * side1_matches_mbase && side2_null + * or + * side2_matches_mbase && side1_null + * However, we call collect_rename_info() even in those cases, + * because exact renames are cheap and would let us remove both a + * source and destination path. We'll cull the unneeded sources + * later. */ collect_rename_info(opt, names, dirname, fullpath, filemask, dirmask, match_mask); /* - * Record information about the path so we can resolve later in - * process_entries. + * None of the special cases above matched, so we have a + * provisional conflict. (Rename detection might allow us to + * unconflict some more cases, but that comes later so all we can + * do now is record the different non-null file hashes.) */ setup_path_info(opt, &pi, dirname, info->pathlen, fullpath, names, NULL, 0, df_conflict, filemask, dirmask, 0); From patchwork Thu Jul 1 03:46:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12353561 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 417C8C11F64 for ; Thu, 1 Jul 2021 03:46:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FFF86144F for ; Thu, 1 Jul 2021 03:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232976AbhGADs5 (ORCPT ); Wed, 30 Jun 2021 23:48:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233400AbhGADsx (ORCPT ); Wed, 30 Jun 2021 23:48:53 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16F4CC0617AE for ; Wed, 30 Jun 2021 20:46:22 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id j34so3446211wms.5 for ; Wed, 30 Jun 2021 20:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=pR0h5LFWhviNFphByFwqYkm2jiu1RUK/t+Oni4vKV4Y=; b=gFeS1pLzvRrN02xqEuB4/oKRicgcVw1Y7Vi5vJK55qGyZSqAANY8oXDZr/rOJ0pd0v +KmawxzAQstgIdrADUGidhCk35Eow4O0BUiLA5G+byBkFBctcWjZEpOquSFuNPXzbu6B br+XlZGcLfyA+Gu9Np66ZgO/kGJgLNSpwe8obcGe9UXZ9+5hOmadYXivElM2gWWCh1oQ dglgakn2TtLxmqPr32IBd4t5h9EplD2VeMHN4zXMuvgH5DTh8HZfH2+3LqSTxXeYjsAT GMSZ35MhHErlHVn1bbhpAn3B7QggviDHYDgJDgoUeXhuWaUPC1qnV7VVXCLwkMTjz4KT Y4Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=pR0h5LFWhviNFphByFwqYkm2jiu1RUK/t+Oni4vKV4Y=; b=tIkPiAVV8zi5GBRHPnleq9Ryagkp8d7cFvXg7JFMTnAxmK1vBhuUsuafeYkN7ez4dD XsmZKB6vAbUbh84aRmCQyN2k617Qk22+cDDaIGewjDdLYIQTOOwQ3D0lMZ/qsPfDknS5 pT2vSiRTFjSFdqIZo82ZK5+sGmtt04yV+JbL2VbRkgkvO5mX0+5b7K0sVAyZFzj1Dqdg OQnR/4wLFSxur6aATjJGmtPQY5bzpbzAXY6It8PGT9OAFAHEf86vd1B+dGOyHu0kA6e8 g9h7Nwo35HQJ9pXwMlFFJ/zjxdCyq7oNd+mCwGq3rYUISfnAshmv1e7rhy4baZvL/px3 46CA== X-Gm-Message-State: AOAM533KmOEW0uN61wyzSCT7HeKYMv76Q6rhVyiwucrz4lEYIifnVCte XY/s3ei4zvd6KyMf4pbz9Fzj/xENuqw= X-Google-Smtp-Source: ABdhPJwsDzXh04DiKagtjpN/TBY5J7b3ISL/hn2asoJBcYpF57EPhL5+px/0hkXDiE+Iksh190LAVg== X-Received: by 2002:a05:600c:296:: with SMTP id 22mr7790983wmk.17.1625111180511; Wed, 30 Jun 2021 20:46:20 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s1sm8029216wmj.8.2021.06.30.20.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 20:46:20 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Thu, 01 Jul 2021 03:46:13 +0000 Subject: [PATCH 3/7] merge-ort: add data structures for allowable trivial directory resolves Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren As noted a few commits ago, we can resolve individual files early if all three sides of the merge have a file at the path and two of the three sides match. We would really like to do the same thing with directories, because being able to do a trivial directory resolve means we don't have to recurse into the directory, potentially saving us a huge amount of time in both collect_merge_info() and process_entries(). Unfortunately, resolving directories early would mean missing any renames whose source or destination is underneath that directory. If we somehow knew there weren't any renames under the directory in question, then we could resolve it early. Sadly, it is impossible to determine whether there are renames under the directory in question without recursing into it, and this has traditionally kept us from ever implementing such an optimization. In commit f89b4f2bee ("merge-ort: skip rename detection entirely if possible", 2021-03-11), we added an additional reason that rename detection could be skipped entirely -- namely, if no *relevant* sources were present. Without completing collect_merge_info_callback(), we do not yet know if there are no relevant sources. However, we do know that if the current directory on one side matches the merge base, then every source file within that directory will not be RELEVANT_CONTENT, and a few simple checks can often let us rule out RELEVANT_LOCATION as well. This suggests we can just defer recursing into such directories until the end of collect_merge_info. Since the deferred directories are known to not add any relevant sources due to the above properties, then if there are no relevant sources after we've traversed all paths other than the deferred ones, then we know there are not any relevant sources. Under those conditions, rename detection is unnecessary, and that means we can resolve the deferred directories without recursing into them. Note that the logic for skipping rename detection was also modified further in commit 76e253793c ("merge-ort, diffcore-rename: employ cached renames when possible", 2021-01-30); in particular rename detection can be skipped if we already have cached renames for each relevant source. We can take advantage of this information as well with our deferral of recursing into directories where one side matches the merge base. Add some data structures that we will use to do these deferrals, with some lengthy comments explaining their purpose. Signed-off-by: Elijah Newren --- merge-ort.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/merge-ort.c b/merge-ort.c index 843fa693145..3d3f00b3b45 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -119,6 +119,51 @@ struct rename_info { */ struct strintmap relevant_sources[3]; + /* + * possible_trivial_merges: directories we defer recursing into + * + * possible_trivial_merges is a map of directory names to + * dir_rename_mask. When we detect that a directory is unchanged on + * one side, we can sometimes resolve the directory without recursing + * into it. Renames are the only things that can prevent such an + * optimization. However, for rename sources: + * - If no parent directory needed directory rename detection, then + * no path under such a directory can be a relevant_source. + * and for rename destinations: + * - If no cached rename has a target path under the directory AND + * - If there are no unpaired relevant_sources elsewhere in the + * repository + * then we don't need any path under this directory for a rename + * destination. The only way to know the last item above is to defer + * handling such directories until the end of collect_merge_info(), + * in handle_deferred_entries(). + * + * For each we store dir_rename_mask, since that's the only bit of + * information we need, other than the path, to resume the recursive + * traversal. + */ + struct strintmap possible_trivial_merges[3]; + + /* + * trivial_merges_okay: if trivial directory merges are okay + * + * See possible_trivial_merges above. The "no unpaired + * relevant_sources elsewhere in the repository" is a single boolean + * per merge side, which we store here. Note that while 0 means no, + * 1 only means "maybe" rather than "yes"; we optimistically set it + * to 1 initially and only clear when we determine it is unsafe to + * do trivial directory merges. + */ + unsigned trivial_merges_okay[3]; + + /* + * target_dirs: ancestor directories of rename targets + * + * target_dirs contains all directory names that are an ancestor of + * any rename destination. + */ + struct strset target_dirs[3]; + /* * dir_rename_mask: * 0: optimization removing unmodified potential rename source okay @@ -490,6 +535,9 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti, strintmap_func(&renames->dirs_removed[i]); strmap_func(&renames->dir_renames[i], 0); strintmap_func(&renames->relevant_sources[i]); + strintmap_func(&renames->possible_trivial_merges[i]); + strset_func(&renames->target_dirs[i]); + renames->trivial_merges_okay[i] = 1; /* 1 == maybe */ if (!reinitialize) assert(renames->cached_pairs_valid_side == 0); if (i != renames->cached_pairs_valid_side) { @@ -4045,12 +4093,17 @@ static void merge_start(struct merge_options *opt, struct merge_result *result) strintmap_init_with_options(&renames->relevant_sources[i], -1 /* explicitly invalid */, NULL, 0); + strintmap_init_with_options(&renames->possible_trivial_merges[i], + 0, NULL, 0); + strset_init_with_options(&renames->target_dirs[i], + NULL, 1); strmap_init_with_options(&renames->cached_pairs[i], NULL, 1); strset_init_with_options(&renames->cached_irrelevant[i], NULL, 1); strset_init_with_options(&renames->cached_target_names[i], NULL, 0); + renames->trivial_merges_okay[i] = 1; /* 1 == maybe */ } /* From patchwork Thu Jul 1 03:46:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12353559 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 5670AC11F69 for ; Thu, 1 Jul 2021 03:46:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F79B61481 for ; Thu, 1 Jul 2021 03:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233779AbhGADs7 (ORCPT ); Wed, 30 Jun 2021 23:48:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbhGADsx (ORCPT ); Wed, 30 Jun 2021 23:48:53 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 487BAC0617AF for ; Wed, 30 Jun 2021 20:46:22 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id a13so6210723wrf.10 for ; Wed, 30 Jun 2021 20:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=35ri/oVrMbO6uA75NOizGkqjB2GcqWgsCqqYDqf0wbs=; b=D3sn0ZTNerBtfLcN1IpdbhmlwG50kiTnVOsRyWBycfBmXUxDKNLTpB7z33R2lCNHNO 5rts6U9EocYI/OACDSwLiYz9dxtzI02uO92bxQa6W3FkPZRf3jneTpGnmEeY7W9wNLwh kKuWWmFFiPcFxY6//KqQpNkyGI+i74PXeYQEFT/THK31Q6ihref+p8aiCS8spyIiyRnc RmC5ngEK6Zvh9QTOrcg884DrmahnLkIV41e7nIKtd0HFwruao3COGmyV/Hqtvhv5CBn5 tTIlVhv9X3jFf2f9ztwRmuTv9i5taa9Aw1J5uAkYOOV+FjpcL6FVOrR0uQkMISZTj7wO OSOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=35ri/oVrMbO6uA75NOizGkqjB2GcqWgsCqqYDqf0wbs=; b=BFaOBaxk6p1dJwJl/nS1LyxBshSpcuqWuzck5y+GGMfuStAVPCOnl1sL7DiplKGHv5 xXBw0yCLVyp3L15uPvBLLHTp1vyMnAlnaIZKMA83BhILhtBYJP88yte2j9fpb664vlpU vTpKX13KqidSREm9zAmICeEkFOAhgT3B5b0miO1QUHe08QNumOty5hISk1cBadNkQG2+ eYqDwoSWVCaVWXxzv8P6rV3yLkeWAFqgB9ZRyY6fYdCbq1z8vKUZQbGWvofIGxokkLTq +s3IPk0G5Uz2ug+pdI8NuJkfVBaNRG89bOyLLXmldXpjBJgKA78tPMZgCapTuvWSvkmG 1alA== X-Gm-Message-State: AOAM531KU0Kxh8JuKfuY0SCJFPORszTv6Se1+7VStNAYctMVGJ0UOzj8 XYJQIC7r2EIXe0TVipjt0O6fhvf1yq4= X-Google-Smtp-Source: ABdhPJw6XaRffA+hOyOTf/m1Veb/7W2WD4BVBQPMhxizwRaHd1vgwUqTfe95Da5Tzn/e6ddBfHTD2Q== X-Received: by 2002:adf:eb43:: with SMTP id u3mr1804079wrn.83.1625111181003; Wed, 30 Jun 2021 20:46:21 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x21sm4051486wmj.6.2021.06.30.20.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 20:46:20 -0700 (PDT) Message-Id: <7e28323b624ad2d8d12123783f00f5a8fbb248e8.1625111177.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 01 Jul 2021 03:46:14 +0000 Subject: [PATCH 4/7] merge-ort: add a handle_deferred_entries() helper function Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren In order to allow trivial directory resolution, we first need to be able to gather more information to determine if the optimization is safe. To enable that, we need a way of deferring the recursion into the directory until a later time. Naturally, deferring the entry into a subtree means that we need some function that will later recurse into the subdirectory exactly the same way that collect_merge_info_callback() would have done. Add a helper function that does this. For now this function is not used but a subsequent commit will change that. Future commits will also make the function sometimes resolve directories instead of traversing inside. Signed-off-by: Elijah Newren --- merge-ort.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/merge-ort.c b/merge-ort.c index 3d3f00b3b45..eb0e18d7546 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -1196,6 +1196,70 @@ static int collect_merge_info_callback(int n, return mask; } +MAYBE_UNUSED +static int handle_deferred_entries(struct merge_options *opt, + struct traverse_info *info) +{ + struct rename_info *renames = &opt->priv->renames; + struct hashmap_iter iter; + struct strmap_entry *entry; + int side, ret = 0; + + for (side = MERGE_SIDE1; side <= MERGE_SIDE2; side++) { + renames->trivial_merges_okay[side] = 0; + strintmap_for_each_entry(&renames->possible_trivial_merges[side], + &iter, entry) { + const char *path = entry->key; + unsigned dir_rename_mask = (intptr_t)entry->value; + struct conflict_info *ci; + unsigned dirmask; + struct tree_desc t[3]; + void *buf[3] = {NULL,}; + int i; + + ci = strmap_get(&opt->priv->paths, path); + VERIFY_CI(ci); + dirmask = ci->dirmask; + + info->name = path; + info->namelen = strlen(path); + info->pathlen = info->namelen + 1; + + for (i = 0; i < 3; i++, dirmask >>= 1) { + if (i == 1 && ci->match_mask == 3) + t[1] = t[0]; + else if (i == 2 && ci->match_mask == 5) + t[2] = t[0]; + else if (i == 2 && ci->match_mask == 6) + t[2] = t[1]; + else { + const struct object_id *oid = NULL; + if (dirmask & 1) + oid = &ci->stages[i].oid; + buf[i] = fill_tree_descriptor(opt->repo, + t+i, oid); + } + } + + ci->match_mask &= ci->filemask; + opt->priv->current_dir_name = path; + renames->dir_rename_mask = dir_rename_mask; + if (renames->dir_rename_mask == 0 || + renames->dir_rename_mask == 0x07) + ret = traverse_trees(NULL, 3, t, info); + else + ret = traverse_trees_wrapper(NULL, 3, t, info); + + for (i = MERGE_BASE; i <= MERGE_SIDE2; i++) + free(buf[i]); + + if (ret < 0) + return ret; + } + } + return ret; +} + static int collect_merge_info(struct merge_options *opt, struct tree *merge_base, struct tree *side1, From patchwork Thu Jul 1 03:46:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12353557 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 5A6DCC11F67 for ; Thu, 1 Jul 2021 03:46:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33E5A6148E for ; Thu, 1 Jul 2021 03:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233754AbhGADsy (ORCPT ); Wed, 30 Jun 2021 23:48:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232976AbhGADsw (ORCPT ); Wed, 30 Jun 2021 23:48:52 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB956C0613A2 for ; Wed, 30 Jun 2021 20:46:22 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id l8so6190377wry.13 for ; Wed, 30 Jun 2021 20:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=IH+wXJBQVGwRASbH9nLVutMF1YTBqHdkkh0Trwn5GRI=; b=cJ3qtlQUIda5EMjpycBMLYTAIFsXia54r7MEIWOFCGG5L7n8Cp4KehhMgvFZtAw+i3 n695+6/T9PfkdMSK7wVvtQPBLvMupVe/4m+Q4q2OO7gZep981Zt6sNZa/apKjz/+c574 HWXzpe/uDxs365dDz/AWJMIgGW6neE19HiUofZcy68j5T+EzM5Sz7Rn0wnRE3LPrC1X8 Ia1C6dkTZ5XfHDA69ZRUDfXOnTvKKc6VOs4qKt3W/kIG9LbwjRL749HT2S47Xut6p7xF c+82MFjixh/MOSqFqvmRFC21qJbDw8B/ieFdgCh5Za4FITLZq4HLJU4A7eUgI6NYjV/n h/fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=IH+wXJBQVGwRASbH9nLVutMF1YTBqHdkkh0Trwn5GRI=; b=Mn9ngHfnpAtcCZvdHksfWRf2SLYKkRRkdejg00vzeVhWIweDZYdRL1Xpd2ey4PoDqg dfASBHxiAY/xAOdYzptzDrfK+ZcFfCBLHYHdn3ubxdt8/cPKfiIWZgrMZBXn2GCihqYG TklZK0cpfhMCPk9LY86iVqEGF3PIK2MqvpwweZhYN8QxNB1N7geTqBf0W6wkamBQrkH3 4Yxtdarhd91IDGkvcsHiihLdFHr3E5kWeN1RyZaxz/mA5VAQE75/WgUdh9MV8bp+SIGM NYylHqQQKjF4R0S3jn5trFp/19Z0N7EsE9xfqWLrNeDV1l0SVOn7dybpwsYshA80vAwW CpZQ== X-Gm-Message-State: AOAM532jcMAl15wnMECWXUCO3r/grR4m/YPqbZxsbQy3ynM54cCaswWz 4+CfYpGwsIhdt5pPwShyJkuLQ/CrBF0= X-Google-Smtp-Source: ABdhPJweBUNEXi5BzNPNmtJTF9HreFrEbUtXIcv0OK1lWnltWFP93gnuOxAmZPAiuqxJjcubRLmjRg== X-Received: by 2002:adf:f482:: with SMTP id l2mr24755412wro.276.1625111181464; Wed, 30 Jun 2021 20:46:21 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s62sm8182876wms.13.2021.06.30.20.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 20:46:21 -0700 (PDT) Message-Id: <317553eadb68ce162b5ebea24045a9ca75342e91.1625111177.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 01 Jul 2021 03:46:15 +0000 Subject: [PATCH 5/7] merge-ort: defer recursing into directories when merge base is matched Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren When one side of history matches the merge base (including when the merge base has no entry for the given directory), have collect_merge_info_callback() defer recursing into the directory. To ensure those entries are eventually handled, add a call to handled_deferred_entries() in collect_merge_info() after traverse_trees() returns. Note that the condition in collect_merge_info_callback() may look more complicated than necessary at first glance; renames->trivial_merges_okay[side] is always true until handle_deferred_entries() is called, and possible_trivial_merges[side] is always empty right now (and in the future won't be filled until handle_deferred_entries() is called). However, when handle_deferred_entries() calls traverse_trees() for the relevant deferred directories, those traverse_trees() calls will once again end up in collect_merge_info_callback() for all the entries under those subdirectories. The extra conditions are there for such deferred cases and will be used more as we do more with those variables. Signed-off-by: Elijah Newren --- merge-ort.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index eb0e18d7546..bf0712d18a0 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -1141,8 +1141,35 @@ static int collect_merge_info_callback(int n, struct tree_desc t[3]; void *buf[3] = {NULL, NULL, NULL}; const char *original_dir_name; - int i, ret; + int i, ret, side; + /* + * Check for whether we can avoid recursing due to one side + * matching the merge base. The side that does NOT match is + * the one that might have a rename destination we need. + */ + assert(!side1_matches_mbase || !side2_matches_mbase); + side = side1_matches_mbase ? MERGE_SIDE2 : + side2_matches_mbase ? MERGE_SIDE1 : MERGE_BASE; + if (filemask == 0 && (dirmask == 2 || dirmask == 4)) { + /* + * Also defer recursing into new directories; set up a + * few variables to let us do so. + */ + ci->match_mask = (7 - dirmask); + side = dirmask / 2; + } + if (renames->dir_rename_mask != 0x07 && + (side != MERGE_BASE) && + renames->trivial_merges_okay[side] && + !strset_contains(&renames->target_dirs[side], pi.string)) { + strintmap_set(&renames->possible_trivial_merges[side], + pi.string, renames->dir_rename_mask); + renames->dir_rename_mask = prev_dir_rename_mask; + return mask; + } + + /* We need to recurse */ ci->match_mask &= filemask; newinfo = *info; newinfo.prev = info; @@ -1196,7 +1223,6 @@ static int collect_merge_info_callback(int n, return mask; } -MAYBE_UNUSED static int handle_deferred_entries(struct merge_options *opt, struct traverse_info *info) { @@ -1285,6 +1311,8 @@ static int collect_merge_info(struct merge_options *opt, trace2_region_enter("merge", "traverse_trees", opt->repo); ret = traverse_trees(NULL, 3, t, &info); + if (ret == 0) + ret = handle_deferred_entries(opt, &info); trace2_region_leave("merge", "traverse_trees", opt->repo); return ret; From patchwork Thu Jul 1 03:46:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12353563 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 699C6C11F67 for ; Thu, 1 Jul 2021 03:46:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B2186144D for ; Thu, 1 Jul 2021 03:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233832AbhGADs7 (ORCPT ); Wed, 30 Jun 2021 23:48:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233689AbhGADsy (ORCPT ); Wed, 30 Jun 2021 23:48:54 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 642F8C061756 for ; Wed, 30 Jun 2021 20:46:23 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id g8-20020a1c9d080000b02901f13dd1672aso3467859wme.0 for ; Wed, 30 Jun 2021 20:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=D/PkCpEbGyhmPUstaGyLqY15IvUcrT8iiGfUOWLjl1M=; b=V+lElWpIGTH/ZVG0aePn/NhjUrVwdcGGnnEtdgMc5crdzbilGrLbhVv4E/lA94Tnrg auWcbP8a6tH2oZDgqQxw6Uh+OP7oYUVmZr27OAbwMg49jHnJq2edV2qF9Sk/ju/CBaWG OA14uhmCRZQ74f+fZP2hP5gBuNSx0b2mfxXeQp+kUE+Sl5RuLybz4nBwQ6Gr2UdWMv+1 GF9sHBtMpQuJ+C9rBsP/W2pt2YgQqnjJnHm3pJcU2Z3iutMb0RLzAs6SDEY/iVydeR6P H9KvYUCwclqzAfNOC0JAbRDRNB2SvhOiwo6caTuGw37Rsf0zXAiiij5K6DuitegTu4RD 2eNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=D/PkCpEbGyhmPUstaGyLqY15IvUcrT8iiGfUOWLjl1M=; b=WlPXUK+gPCEfC3XESMmqpoaR++NvmogKnCFzFTmpUCCgX4WT6YQNxlBDKe2nRZEMx3 H71qkEQjRHzNDYBLp1o5VWNT5VELq+BPcS9YdWvOAJxP0EWxktqfbypVPDn1x64XldqE +f6RVGHMOOeIBfVO7VTuyMQGC6zKFk9RlydAkrEu3wWa3FBk9RnutWfozwdotRjX7XPb h2A+f0NYLA6jSpACjhlHsafTFBcsnu02k0qe5YjzDWnP+p8FrJcxfIMtmQiHU8cBGJVU XuinpB29G0uLJaVvx4vDtHCEwcCKD2j9+PVlF1IAjfpOBO64SeYns3WeNI8XrkaCLsPO SdPQ== X-Gm-Message-State: AOAM532yQYf/MGpiQOkS4nNEYq1BuPqv3rRUsusummNYJ9M4zToWv4cT s1MpNAGOQMaVaCWBiXVfB1os+b1z3Vc= X-Google-Smtp-Source: ABdhPJzcC2wNrCkm0gcX7TpBG6VjD2jusWq6Nz71642zwyhAXS8GDtNe7tRl6nalNUXj8jgWU3+tSg== X-Received: by 2002:a05:600c:4111:: with SMTP id j17mr824987wmi.187.1625111182018; Wed, 30 Jun 2021 20:46:22 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l9sm8049636wrp.14.2021.06.30.20.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 20:46:21 -0700 (PDT) Message-Id: <3409a6cd631deb361d3ecb94491c0c297c52fb53.1625111177.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 01 Jul 2021 03:46:16 +0000 Subject: [PATCH 6/7] merge-ort: avoid recursing into directories when we don't need to MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren This combines the work of the last several patches, and implements the conditions when we don't need to recurse into directories. It's perhaps easiest to see the logic by separating the fact that a directory might have both rename sources and rename destinations: * rename sources: only files present in the merge base can serve as rename sources, and only when one side deletes that file. When the tree on one side matches the merge base, that means every file within the subtree matches the merge base. This means that the skip-irrelevant-rename-detection optimization from before kicks in and we don't need any of these files as rename sources. * rename destinations: the tree that does not match the merge base might have newly added and hence unmatched destination files. This is what usually prevents us from doing trivial directory resolutions in the merge machinery. However, the fact that we have deferred recursing into this directory until the end means we know whether there are any unmatched relevant potential rename sources elsewhere in this merge. If there are no unmatched such relevant sources anywhere, then there is no need to look for unmatched potential rename destinations to match them with. This informs our algorithm: * Search through relevant_sources; if we have entries, they better all be reflected in cached_pairs or cached_irrelevant, otherwise they represent an unmatched potential rename source (causing the optimization to be disallowed). * For any relevant_source represented in cached_pairs, we do need to to make sure to get the destination for each source, meaning we need to recurse into any ancestor directories of those destinations. * Once we've recursed into all the rename destinations for any relevant_sources in cached_pairs, we can then do the trivial directory resolution for the remaining directories. For the testcases mentioned in commit 557ac0350d ("merge-ort: begin performance work; instrument with trace2_region_* calls", 2020-10-28), this change improves the performance as follows: Before After no-renames: 5.235 s ± 0.042 s 205.1 ms ± 3.8 ms mega-renames: 9.419 s ± 0.107 s 1.564 s ± 0.010 s just-one-mega: 480.1 ms ± 3.9 ms 479.5 ms ± 3.9 ms Signed-off-by: Elijah Newren --- merge-ort.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 3 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index bf0712d18a0..c9cf7a158c8 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -1223,6 +1223,18 @@ static int collect_merge_info_callback(int n, return mask; } +static void resolve_trivial_directory_merge(struct conflict_info *ci, int side) +{ + VERIFY_CI(ci); + assert((side == 1 && ci->match_mask == 5) || + (side == 2 && ci->match_mask == 3)); + oidcpy(&ci->merged.result.oid, &ci->stages[side].oid); + ci->merged.result.mode = ci->stages[side].mode; + ci->merged.is_null = is_null_oid(&ci->stages[side].oid); + ci->match_mask = 0; + ci->merged.clean = 1; /* (ci->filemask == 0); */ +} + static int handle_deferred_entries(struct merge_options *opt, struct traverse_info *info) { @@ -1232,9 +1244,71 @@ static int handle_deferred_entries(struct merge_options *opt, int side, ret = 0; for (side = MERGE_SIDE1; side <= MERGE_SIDE2; side++) { - renames->trivial_merges_okay[side] = 0; - strintmap_for_each_entry(&renames->possible_trivial_merges[side], - &iter, entry) { + unsigned optimization_okay = 1; + struct strintmap copy; + + /* Loop over the set of paths we need to know rename info for */ + strset_for_each_entry(&renames->relevant_sources[side], + &iter, entry) { + char *rename_target, *dir, *dir_marker; + struct strmap_entry *e; + + /* + * if we don't know delete/rename info for this path, + * then we need to recurse into all trees to get all + * adds to make sure we have it. + */ + if (strset_contains(&renames->cached_irrelevant[side], + entry->key)) + continue; + e = strmap_get_entry(&renames->cached_pairs[side], + entry->key); + if (!e) { + optimization_okay = 0; + break; + } + + /* If this is a delete, we have enough info already */ + rename_target = e->value; + if (!rename_target) + continue; + + /* If we already walked the rename target, we're good */ + if (strmap_contains(&opt->priv->paths, rename_target)) + continue; + + /* + * Otherwise, we need to get a list of directories that + * will need to be recursed into to get this + * rename_target. + */ + dir = xstrdup(rename_target); + while ((dir_marker = strrchr(dir, '/'))) { + *dir_marker = '\0'; + if (strset_contains(&renames->target_dirs[side], + dir)) + break; + strset_add(&renames->target_dirs[side], dir); + } + free(dir); + } + renames->trivial_merges_okay[side] = optimization_okay; + /* + * We need to recurse into any directories in + * possible_trivial_merges[side] found in target_dirs[side]. + * But when we recurse, we may need to queue up some of the + * subdirectories for possible_trivial_merges[side]. Since + * we can't safely iterate through a hashmap while also adding + * entries, move the entries into 'copy', iterate over 'copy', + * and then we'll also iterate anything added into + * possible_trivial_merges[side] once this loop is done. + */ + copy = renames->possible_trivial_merges[side]; + strintmap_init_with_options(&renames->possible_trivial_merges[side], + 0, + NULL, + 0); + strintmap_for_each_entry(©, &iter, entry) { const char *path = entry->key; unsigned dir_rename_mask = (intptr_t)entry->value; struct conflict_info *ci; @@ -1247,6 +1321,13 @@ static int handle_deferred_entries(struct merge_options *opt, VERIFY_CI(ci); dirmask = ci->dirmask; + if (optimization_okay && + !strset_contains(&renames->target_dirs[side], + path)) { + resolve_trivial_directory_merge(ci, side); + continue; + } + info->name = path; info->namelen = strlen(path); info->pathlen = info->namelen + 1; @@ -1282,6 +1363,20 @@ static int handle_deferred_entries(struct merge_options *opt, if (ret < 0) return ret; } + strintmap_clear(©); + strintmap_for_each_entry(&renames->possible_trivial_merges[side], + &iter, entry) { + const char *path = entry->key; + struct conflict_info *ci; + + ci = strmap_get(&opt->priv->paths, path); + VERIFY_CI(ci); + + assert(renames->trivial_merges_okay[side] && + !strset_contains(&renames->target_dirs[side], + path)); + resolve_trivial_directory_merge(ci, side); + } } return ret; } From patchwork Thu Jul 1 03:46:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12353565 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 74F11C11F6A for ; Thu, 1 Jul 2021 03:46:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5801461493 for ; Thu, 1 Jul 2021 03:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233861AbhGADtA (ORCPT ); Wed, 30 Jun 2021 23:49:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233771AbhGADsz (ORCPT ); Wed, 30 Jun 2021 23:48:55 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11BA8C0617A8 for ; Wed, 30 Jun 2021 20:46:24 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id o33-20020a05600c5121b02901e360c98c08so5833664wms.5 for ; Wed, 30 Jun 2021 20:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=8owKd+QN6Q1jmB0H3fYNaDJz2IawsJrprwEm7Ted5EM=; b=IZZpXnv7wnZK3kjp4pq1yfx7pr+mjLFxviB2/hbPwfuFb9oUPBknBbHutwikYrM66a mRwIlGJRxuOOT2o4DnOWR4zU5UtIw894p6+rSqBgv/kULbJHBI78F2tnSyHFjBVuMS+B J3UO42jWcF7gKUQL4GmGDQOOHRVUCI3lvzIVBm1ldAqCtiuzJiFFmv0B50CS+tllHtQY AAXrq7acXDFm2Ky37Xjlj0UouDUkZ8YTMSwOEF4vDkz8y6hYjXGDdk4bsgHGjEAdB3QO oatClRTCaK4iKnZCKtj2x1noxvrKGxFiUtcWeNwWWHCOw7WwD4fHSyvlCZNKjGqgtdDg S0XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=8owKd+QN6Q1jmB0H3fYNaDJz2IawsJrprwEm7Ted5EM=; b=lib3V/n8tJHmj4Cnz047//IDSwWTZCtWJJ7dxhNmpvIQLoxrdtn5hduz03G5bQjySy V+EY03wHrm9oKxXz80uQ1LWlSTm8ROhliIVsBMI9TsDL1gLl0Vkow1LYqFzlUhCSoyxk 5uznPwUNN6Vo7G94w3kc8QOpPWQ23BwcVPN9ghSqlDuDLKVaEbB4FRFPFmImX6vRjiuL jCViRNLxcG/NU0Nk8dMf7Bemf9FiJutjTZYkt/Az+CTx26SW9Zoi+J13P13+BoPW78A2 IHpfAtvacY8GBXOHRPU01/mJFUG/Y87xgIxpXMr9vc4CQmuvsuGx7y6dyNYoEgTWeBau P7Uw== X-Gm-Message-State: AOAM5335zDkimiOIdLCdUm9JnOsjROU+QbIxeRErcPSqRfThPJrbSy+e NgBICINTteJ2kgEJrV7VnTV3AUtnTLI= X-Google-Smtp-Source: ABdhPJxDwFHZGoBYqL9ImD2I06hPGqu/gR17n07f4rkAY8GqUwigmbqvfSLDHU7WuTwx4xfv8Y174Q== X-Received: by 2002:a1c:4b08:: with SMTP id y8mr1262345wma.80.1625111182597; Wed, 30 Jun 2021 20:46:22 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k5sm23613999wmk.11.2021.06.30.20.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 20:46:22 -0700 (PDT) Message-Id: <76bc73262c4d01db12b2c0fa401b7ccad2988e1c.1625111177.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 01 Jul 2021 03:46:17 +0000 Subject: [PATCH 7/7] merge-ort: restart merge with cached renames to reduce process entry cost MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren The merge algorithm mostly consists of the following three functions: collect_merge_info() detect_and_process_renames() process_entries() Prior to the trivial directory resolution optimization of the last half dozen commits, process_entries() was consistently the slowest, followed by collect_merge_info(), then detect_and_process_renames(). When the trivial directory resolution applies, it often dramatically decreases the amount of time spent in the two slower functions. Looking at the performance results in the previous commit, the trivial directory resolution optimization helps amazingly well when there are no relevant renames. It also helps really well when reapplying a long series of linear commits (such as in a rebase or cherry-pick), since the relevant renames may well be cached from the first reapplied commit. But when there are any relevant renames that are not cached (represented by the just-one-mega testcase), then the optimization does not help at all. Often, I noticed that when the optimization does not apply, it is because there are a handful of relevant sources -- maybe even only one. It felt frustrating to need to recurse into potentially hundreds or even thousands of directories just for a single rename, but it was needed for correctness. However, staring at this list of functions and noticing that process_entries() is the most expensive and knowing I could avoid it if I had cached renames suggested a simple idea: change collect_merge_info() detect_and_process_renames() process_entries() into collect_merge_info() detect_and_process_renames() collect_merge_info() detect_and_process_renames() process_entries() This may seem odd and look like more work. However, note that although we run collect_merge_info() twice, the second time we get to employ trivial directory resolves, which makes it much faster, so the increased time in collect_merge_info() is small. While we run detect_and_process_renames() again, all renames are cached so it's nearly a no-op (we don't call into diffcore_rename_extended() but we do have a little bit of data structure checking and fixing up). And the big payoff comes from the fact that process_entries(), will be much faster due to having far fewer entries to process. This restarting only makes sense if we can save recursing into enough directories to make it worth our while. Introduce a simple heuristic to guide this. Note that this heuristic uses a "wanted_factor" that I have virtually no actual real world data for, just some back-of-the-envelope quasi-scientific calculations that I included in some comments and then plucked a simple round number out of thin air. It could be that tweaking this number to make it either higher or lower improves the optimization. (There's slightly more here; when I first introduced this optimization, I used a factor of 10, because I was completely confident it was big enough to not cause slowdowns in special cases. I was certain it was higher than needed. Several months later, I added the rough calculations which make me think the optimal number is close to 2; but instead of pushing to the limit, I just bumped it to 3 to reduce the risk that there are special cases where this optimization can result in slowing down the code a little. If the ratio of path counts is below 3, we probably will only see minor performance improvements at best anyway.) Also, note that while the diffstat looks kind of long (nearly 100 lines), more than half of it is in two comments explaining how things work. For the testcases mentioned in commit 557ac0350d ("merge-ort: begin performance work; instrument with trace2_region_* calls", 2020-10-28), this change improves the performance as follows: Before After no-renames: 205.1 ms ± 3.8 ms 204.2 ms ± 3.0 ms mega-renames: 1.564 s ± 0.010 s 1.076 s ± 0.015 s just-one-mega: 479.5 ms ± 3.9 ms 364.1 ms ± 7.0 ms Signed-off-by: Elijah Newren --- merge-ort.c | 106 ++++++++++++++++++++++++++-- t/t6423-merge-rename-directories.sh | 2 +- 2 files changed, 101 insertions(+), 7 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index c9cf7a158c8..51274f40059 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -209,6 +209,7 @@ struct rename_info { * MERGE_SIDE2: cached data from side2 can be reused * MERGE_SIDE1: cached data from side1 can be reused * 0: no cached data can be reused + * -1: See redo_after_renames; both sides can be reused. */ int cached_pairs_valid_side; @@ -254,6 +255,28 @@ struct rename_info { */ struct strset cached_irrelevant[3]; + /* + * redo_after_renames: optimization flag for "restarting" the merge + * + * Sometimes it pays to detect renames, cache them, and then + * restart the merge operation from the beginning. The reason for + * this is that when we know where all the renames are, we know + * whether a certain directory has any paths under it affected -- + * and if a directory is not affected then it permits us to do + * trivial tree merging in more cases. Doing trivial tree merging + * prevents the need to run process_entry() on every path + * underneath trees that can be trivially merged, and + * process_entry() is more expensive than collect_merge_info() -- + * plus, the second collect_merge_info() will be much faster since + * it doesn't have to recurse into the relevant trees. + * + * Values for this flag: + * 0 = don't bother, not worth it (or conditions not yet checked) + * 1 = conditions for optimization met, optimization worthwhile + * 2 = we already did it (don't restart merge yet again) + */ + unsigned redo_after_renames; + /* * needed_limit: value needed for inexact rename detection to run * @@ -540,7 +563,8 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti, renames->trivial_merges_okay[i] = 1; /* 1 == maybe */ if (!reinitialize) assert(renames->cached_pairs_valid_side == 0); - if (i != renames->cached_pairs_valid_side) { + if (i != renames->cached_pairs_valid_side && + -1 != renames->cached_pairs_valid_side) { strset_func(&renames->cached_target_names[i]); strmap_func(&renames->cached_pairs[i], 1); strset_func(&renames->cached_irrelevant[i]); @@ -1242,7 +1266,9 @@ static int handle_deferred_entries(struct merge_options *opt, struct hashmap_iter iter; struct strmap_entry *entry; int side, ret = 0; + int path_count_before, path_count_after = 0; + path_count_before = strmap_get_size(&opt->priv->paths); for (side = MERGE_SIDE1; side <= MERGE_SIDE2; side++) { unsigned optimization_okay = 1; struct strintmap copy; @@ -1377,7 +1403,51 @@ static int handle_deferred_entries(struct merge_options *opt, path)); resolve_trivial_directory_merge(ci, side); } + if (!optimization_okay || path_count_after) + path_count_after = strmap_get_size(&opt->priv->paths); } + if (path_count_after) { + /* + * Not sure were the right cut-off is for the optimization + * to redo collect_merge_info after we've cached the + * regular renames is. Basically, collect_merge_info(), + * detect_regular_renames(), and process_entries() are + * similar costs and all big tent poles. Caching the + * result of detect_regular_renames() means that redoing + * that one function will cost us virtually 0 extra, so it + * depends on the other two functions, which are both O(N) + * cost in the number of paths. Thus, it makes sense that + * if we can cut the number of paths in half, then redoing + * collect_merge_info() at half cost in order to get + * process_entries() at half cost should be about equal + * cost. If we can cut by more than half, then we would + * win. The fact that process_entries() is about 10%-20% + * more expensive than collect_merge_info() suggests we + * could make the factor be less than two. The fact that + * even when we have renames cached, we still have to + * traverse down to the individual (relevant) renames, + * which suggests we should perhaps use a bigger factor. + * + * The exact number isn't critical, since the code will + * work even if we get the factor wrong -- it just might be + * slightly slower if we're a bit off. For now, just error + * on the side of a bigger fudge. For the linux kernel + * testcases I was looking at with massive renames, the + * ratio came in around 50 to 250, which clearly would + * trigger this optimization and provided some *very* nice + * speedups. + */ + int wanted_factor = 3; + + /* We should only redo collect_merge_info one time */ + assert(renames->redo_after_renames == 0); + + if (path_count_after / path_count_before > wanted_factor) { + renames->redo_after_renames = 1; + renames->cached_pairs_valid_side = -1; + } + } else if (renames->redo_after_renames == 2) + renames->redo_after_renames = 0; return ret; } @@ -2820,8 +2890,8 @@ static int compare_pairs(const void *a_, const void *b_) } /* Call diffcore_rename() to update deleted/added pairs into rename pairs */ -static void detect_regular_renames(struct merge_options *opt, - unsigned side_index) +static int detect_regular_renames(struct merge_options *opt, + unsigned side_index) { struct diff_options diff_opts; struct rename_info *renames = &opt->priv->renames; @@ -2834,7 +2904,7 @@ static void detect_regular_renames(struct merge_options *opt, * side had directory renames. */ resolve_diffpair_statuses(&renames->pairs[side_index]); - return; + return 0; } partial_clear_dir_rename_count(&renames->dir_rename_count[side_index]); @@ -2869,6 +2939,18 @@ static void detect_regular_renames(struct merge_options *opt, diff_queued_diff.nr = 0; diff_queued_diff.queue = NULL; diff_flush(&diff_opts); + + if (renames->redo_after_renames) { + int i; + struct diff_filepair *p; + + renames->redo_after_renames = 2; + for (i = 0; i < renames->pairs[side_index].nr; ++i) { + p = renames->pairs[side_index].queue[i]; + possibly_cache_new_pair(renames, p, side_index, NULL); + } + } + return 1; } /* @@ -2958,14 +3040,19 @@ static int detect_and_process_renames(struct merge_options *opt, struct diff_queue_struct combined; struct rename_info *renames = &opt->priv->renames; int need_dir_renames, s, clean = 1; + unsigned detection_run = 0; memset(&combined, 0, sizeof(combined)); if (!possible_renames(renames)) goto cleanup; trace2_region_enter("merge", "regular renames", opt->repo); - detect_regular_renames(opt, MERGE_SIDE1); - detect_regular_renames(opt, MERGE_SIDE2); + detection_run |= detect_regular_renames(opt, MERGE_SIDE1); + detection_run |= detect_regular_renames(opt, MERGE_SIDE2); + if (renames->redo_after_renames && detection_run) { + trace2_region_leave("merge", "regular renames", opt->repo); + goto cleanup; + } use_cached_pairs(opt, &renames->cached_pairs[1], &renames->pairs[1]); use_cached_pairs(opt, &renames->cached_pairs[2], &renames->pairs[2]); trace2_region_leave("merge", "regular renames", opt->repo); @@ -4380,6 +4467,7 @@ static void merge_ort_nonrecursive_internal(struct merge_options *opt, opt->subtree_shift); } +redo: trace2_region_enter("merge", "collect_merge_info", opt->repo); if (collect_merge_info(opt, merge_base, side1, side2) != 0) { /* @@ -4399,6 +4487,12 @@ static void merge_ort_nonrecursive_internal(struct merge_options *opt, result->clean = detect_and_process_renames(opt, merge_base, side1, side2); trace2_region_leave("merge", "renames", opt->repo); + if (opt->priv->renames.redo_after_renames == 2) { + trace2_region_enter("merge", "reset_maps", opt->repo); + clear_or_reinit_internal_opts(opt->priv, 1); + trace2_region_leave("merge", "reset_maps", opt->repo); + goto redo; + } trace2_region_enter("merge", "process_entries", opt->repo); process_entries(opt, &working_tree_oid); diff --git a/t/t6423-merge-rename-directories.sh b/t/t6423-merge-rename-directories.sh index e834b7e6efe..d8919d276a1 100755 --- a/t/t6423-merge-rename-directories.sh +++ b/t/t6423-merge-rename-directories.sh @@ -4797,7 +4797,7 @@ test_setup_12f () { ) } -test_expect_merge_algorithm failure failure '12f: Trivial directory resolve, caching, all kinds of fun' ' +test_expect_merge_algorithm failure success '12f: Trivial directory resolve, caching, all kinds of fun' ' test_setup_12f && ( cd 12f &&