From: "Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Phillip Wood <phillip.wood@dunelm.org.uk>,
Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: [PATCH 2/3] xdiff: avoid unnecessary memory allocations
Date: Wed, 17 Nov 2021 11:20:24 +0000 [thread overview]
Message-ID: <eef46c71840d7f36b503a92b899c95632c023351.1637148025.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1079.git.1637148025.gitgitgadget@gmail.com>
From: Phillip Wood <phillip.wood@dunelm.org.uk>
rindex and ha are only used by xdl_cleanup_records() which is not
called by the histogram or patience algorithms. The perf test results
show a small reduction in run time but that is probably within the
noise.
Test HEAD^ HEAD
-----------------------------------------------------------------------------
4000.1: log -3000 (baseline) 0.19(0.17+0.02) 0.19(0.12+0.07) +0.0%
4000.2: log --raw -3000 (tree-only) 0.98(0.78+0.20) 0.98(0.81+0.16) +0.0%
4000.3: log -p -3000 (Myers) 4.81(4.15+0.64) 4.81(4.23+0.56) +0.0%
4000.4: log -p -3000 --histogram 5.87(5.19+0.66) 5.83(5.11+0.70) -0.7%
4000.5: log -p -3000 --patience 5.35(4.60+0.73) 5.31(4.61+0.69) -0.7%
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
xdiff/xprepare.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/xdiff/xprepare.c b/xdiff/xprepare.c
index 7fae0727a02..4527a4a07c4 100644
--- a/xdiff/xprepare.c
+++ b/xdiff/xprepare.c
@@ -213,10 +213,13 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
goto abort;
memset(rchg, 0, (nrec + 2) * sizeof(char));
- if (!(rindex = (long *) xdl_malloc((nrec + 1) * sizeof(long))))
- goto abort;
- if (!(ha = (unsigned long *) xdl_malloc((nrec + 1) * sizeof(unsigned long))))
- goto abort;
+ if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
+ (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF)) {
+ if (!(rindex = xdl_malloc((nrec + 1) * sizeof(*rindex))))
+ goto abort;
+ if (!(ha = xdl_malloc((nrec + 1) * sizeof(*ha))))
+ goto abort;
+ }
xdf->nrec = nrec;
xdf->recs = recs;
--
gitgitgadget
next prev parent reply other threads:[~2021-11-17 11:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-17 11:20 [PATCH 0/3] xdiff: speedup histogram diff Phillip Wood via GitGitGadget
2021-11-17 11:20 ` [PATCH 1/3] diff histogram: intern strings Phillip Wood via GitGitGadget
2021-11-17 15:55 ` Derrick Stolee
2021-11-17 16:46 ` Jeff King
2021-11-17 16:52 ` Phillip Wood
2021-11-18 15:35 ` Johannes Schindelin
2021-11-18 15:42 ` Jeff King
2021-11-19 10:05 ` Phillip Wood
2021-11-19 14:45 ` Jeff King
2021-11-19 21:22 ` Ævar Arnfjörð Bjarmason
2021-11-19 22:19 ` Jeff King
2021-11-19 15:49 ` Johannes Schindelin
2021-11-17 11:20 ` Phillip Wood via GitGitGadget [this message]
2021-11-17 11:20 ` [PATCH 3/3] xdiff: simplify comparison Phillip Wood via GitGitGadget
2021-11-18 15:40 ` [PATCH 0/3] xdiff: speedup histogram diff Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eef46c71840d7f36b503a92b899c95632c023351.1637148025.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).