aboutsummaryrefslogtreecommitdiffstats
path: root/merge-ort.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2021-07-30 11:47:42 +0000
committerJunio C Hamano <gitster@pobox.com>2021-07-30 09:01:19 -0700
commitf239fff4c183b231134115bc3b38b4f8e3982d3e (patch)
tree60cdd7cd6f221cec2efa0130c280f6858c66b28b /merge-ort.c
parenta8791ef6492bf702ba70352009cbd28fb581c6e2 (diff)
downloadgit-f239fff4c183b231134115bc3b38b4f8e3982d3e.tar.gz
merge-ort: store filepairs and filespecs in our mem_pool
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: 198.1 ms ± 2.6 ms 198.5 ms ± 3.4 ms mega-renames: 715.8 ms ± 4.0 ms 679.1 ms ± 5.6 ms just-one-mega: 276.8 ms ± 4.2 ms 271.9 ms ± 2.8 ms Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-ort.c')
-rw-r--r--merge-ort.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/merge-ort.c b/merge-ort.c
index e79830f918..f4f0a3d57f 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -690,7 +690,6 @@ static void path_msg(struct merge_options *opt,
strbuf_addch(sb, '\n');
}
-MAYBE_UNUSED
static struct diff_filespec *pool_alloc_filespec(struct mem_pool *pool,
const char *path)
{
@@ -712,7 +711,6 @@ static struct diff_filespec *pool_alloc_filespec(struct mem_pool *pool,
return spec;
}
-MAYBE_UNUSED
static struct diff_filepair *pool_diff_queue(struct mem_pool *pool,
struct diff_queue_struct *queue,
struct diff_filespec *one,
@@ -930,6 +928,7 @@ static void add_pair(struct merge_options *opt,
unsigned dir_rename_mask)
{
struct diff_filespec *one, *two;
+ struct mem_pool *pool = opt->priv->pool;
struct rename_info *renames = &opt->priv->renames;
int names_idx = is_add ? side : 0;
@@ -980,11 +979,11 @@ static void add_pair(struct merge_options *opt,
return;
}
- one = alloc_filespec(pathname);
- two = alloc_filespec(pathname);
+ one = pool_alloc_filespec(pool, pathname);
+ two = pool_alloc_filespec(pool, pathname);
fill_filespec(is_add ? two : one,
&names[names_idx].oid, 1, names[names_idx].mode);
- diff_queue(&renames->pairs[side], one, two);
+ pool_diff_queue(pool, &renames->pairs[side], one, two);
}
static void collect_rename_info(struct merge_options *opt,
@@ -2893,6 +2892,7 @@ static void use_cached_pairs(struct merge_options *opt,
{
struct hashmap_iter iter;
struct strmap_entry *entry;
+ struct mem_pool *pool = opt->priv->pool;
/*
* Add to side_pairs all entries from renames->cached_pairs[side_index].
@@ -2906,9 +2906,9 @@ static void use_cached_pairs(struct merge_options *opt,
new_name = old_name;
/* We don't care about oid/mode, only filenames and status */
- one = alloc_filespec(old_name);
- two = alloc_filespec(new_name);
- diff_queue(pairs, one, two);
+ one = pool_alloc_filespec(pool, old_name);
+ two = pool_alloc_filespec(pool, new_name);
+ pool_diff_queue(pool, pairs, one, two);
pairs->queue[pairs->nr-1]->status = entry->value ? 'R' : 'D';
}
}
@@ -3016,6 +3016,7 @@ static int detect_regular_renames(struct merge_options *opt,
diff_queued_diff = renames->pairs[side_index];
trace2_region_enter("diff", "diffcore_rename", opt->repo);
diffcore_rename_extended(&diff_opts,
+ opt->priv->pool,
&renames->relevant_sources[side_index],
&renames->dirs_removed[side_index],
&renames->dir_rename_count[side_index],
@@ -3066,7 +3067,7 @@ static int collect_renames(struct merge_options *opt,
if (p->status != 'A' && p->status != 'R') {
possibly_cache_new_pair(renames, p, side_index, NULL);
- diff_free_filepair(p);
+ pool_diff_free_filepair(opt->priv->pool, p);
continue;
}
@@ -3079,7 +3080,7 @@ static int collect_renames(struct merge_options *opt,
possibly_cache_new_pair(renames, p, side_index, new_path);
if (p->status != 'R' && !new_path) {
- diff_free_filepair(p);
+ pool_diff_free_filepair(opt->priv->pool, p);
continue;
}
@@ -3197,7 +3198,7 @@ cleanup:
side_pairs = &renames->pairs[s];
for (i = 0; i < side_pairs->nr; ++i) {
struct diff_filepair *p = side_pairs->queue[i];
- diff_free_filepair(p);
+ pool_diff_free_filepair(opt->priv->pool, p);
}
}
@@ -3210,7 +3211,8 @@ simple_cleanup:
if (combined.nr) {
int i;
for (i = 0; i < combined.nr; i++)
- diff_free_filepair(combined.queue[i]);
+ pool_diff_free_filepair(opt->priv->pool,
+ combined.queue[i]);
free(combined.queue);
}