From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 900D81F8C6 for ; Fri, 16 Jul 2021 05:22:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234120AbhGPFZh (ORCPT ); Fri, 16 Jul 2021 01:25:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231348AbhGPFZh (ORCPT ); Fri, 16 Jul 2021 01:25:37 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9D8CC061760 for ; Thu, 15 Jul 2021 22:22:41 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id a13so10559980wrf.10 for ; Thu, 15 Jul 2021 22:22:41 -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=Tvap5UuoFt0PJh5Piuyobj9+Va+QXMIoraP1kuiJ0p8nP03zXOZlvZRGOYyGDPXTZx Hb9nOkkAlnQueyYOFaOReOx6hEl940IOU09eSH7Cf6spTfZcMXkR4ehWBOn2Egeb44In Xw8Y0d2vG2Ctykcmco1l3NyHXS7J2l/PGjeA3g8ScH+561HYyodYyzchcM8jIgcjuLzN pMDetLg4fdpdUI+hjceiu0pbSeIjflG6hv4i0S9sOeJcfrziLRIJYXBlCzCZL0jcHqnG iQLuXc1Odz4JESbSMwDFzJrbprZ3lHLDrw2K4SxAyN2K/TsmwW07XHPvCRqEe4P64SYE 0Geg== 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=h5vgRtZLF1sL06xLGrunug08O4ZlCBuLmk3kqvgSNHB+Y5SwZnwcgPe9WYXe2PaMyb T7PWPboN8t+c7jhncHmAJhruvcx6HWd/1wE4j232Vcp7VSvUvpU5gZF9mayjSwSiwexo /g3HWx9Y5G5F6Nav/Ag+y98LpsYeqmADJR4OnqsBIzOtC4tCBQ1eGCWXCmgJETOinqCU 48BN+IWwEVaLeqekP5nLSqHqrl3jIxHqm8/Fausm4bIyETKlfTvY3zdeYOnsUBFKPVnq AFvQF7iJVA7xImnMj2Yr441lhEgEabigWvYINExMYAng+0wVSoCxDGGt+TE03jxcTIW8 9iBA== X-Gm-Message-State: AOAM532luFvW3G/OiWZrUtgW35ai/FYz0yVPOYSZOadIypn1gge+yT0y 0GiO+5aJxy613ac40yKkrpDT3zwirvc= X-Google-Smtp-Source: ABdhPJzbU+K9R0FWCNbSM7Az9tn4vUYLRuxpazaZiU/QVgYY0g2CKfWlByGrtVwCUeJ70hNpXF2BWg== X-Received: by 2002:a5d:640d:: with SMTP id z13mr10067865wru.24.1626412960117; Thu, 15 Jul 2021 22:22:40 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q19sm9672732wmq.38.2021.07.15.22.22.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 22:22:39 -0700 (PDT) Message-Id: <5dca982c0b061ae8d6335d4f22b78811dced054a.1626412958.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Fri, 16 Jul 2021 05:22:31 +0000 Subject: [PATCH v3 1/7] merge-ort: resolve paths early when we have sufficient information Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , =?UTF-8?Q?=C3=86var_Arnfj=C3=B6r=C3=B0?= Bjarmason , Elijah Newren , Bagas Sanjaya , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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. */ -- gitgitgadget