From: Muhammed Dilshad A <dilsheddilu123@gmail.com>
To: git@vger.kernel.org
Cc: ps@pks.im, Muhammed Dilshad A <dilsheddilu123@gmail.com>
Subject: [PATCH v2 3/3] t: retire the sorting benchmark and mergesort helper
Date: Wed, 7 Oct 2026 19:20:25 +0530 [thread overview]
Message-ID: <b540e3a3d2c30bccaaa0d8dca3428a77c1d2ea76.1791365181.git.dilsheddilu123@gmail.com> (raw)
In-Reply-To: <cover.1791365181.git.dilsheddilu123@gmail.com>
p0071 compared sorting implementations during mergesort development.
Retire it as suggested during the unit-test conversion. A new benchmark
can be added if later optimization work needs performance measurements.
The benchmark was the last caller of the sort-only mergesort helper.
Removing it allows us to delete the helper and its build and command
registrations as well.
Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Muhammed Dilshad A <dilsheddilu123@gmail.com>
---
Makefile | 1 -
t/helper/meson.build | 1 -
t/helper/test-mergesort.c | 67 ---------------------------------------
t/helper/test-tool.c | 1 -
t/helper/test-tool.h | 1 -
t/meson.build | 1 -
t/perf/p0071-sort.sh | 52 ------------------------------
7 files changed, 124 deletions(-)
delete mode 100644 t/helper/test-mergesort.c
delete mode 100755 t/perf/p0071-sort.sh
diff --git a/Makefile b/Makefile
index cac535ba19..4b35808b2e 100644
--- a/Makefile
+++ b/Makefile
@@ -835,7 +835,6 @@ TEST_BUILTINS_OBJS += test-hexdump.o
TEST_BUILTINS_OBJS += test-json-writer.o
TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
TEST_BUILTINS_OBJS += test-match-trees.o
-TEST_BUILTINS_OBJS += test-mergesort.o
TEST_BUILTINS_OBJS += test-mktemp.o
TEST_BUILTINS_OBJS += test-name-hash.o
TEST_BUILTINS_OBJS += test-online-cpus.o
diff --git a/t/helper/meson.build b/t/helper/meson.build
index 3235f10ab8..e94e6f10fb 100644
--- a/t/helper/meson.build
+++ b/t/helper/meson.build
@@ -32,7 +32,6 @@ test_tool_sources = [
'test-json-writer.c',
'test-lazy-init-name-hash.c',
'test-match-trees.c',
- 'test-mergesort.c',
'test-mktemp.c',
'test-name-hash.c',
'test-online-cpus.c',
diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c
deleted file mode 100644
index e8b8de239b..0000000000
--- a/t/helper/test-mergesort.c
+++ /dev/null
@@ -1,67 +0,0 @@
-#include "test-tool.h"
-#include "mem-pool.h"
-#include "mergesort.h"
-#include "strbuf.h"
-
-struct line {
- char *text;
- struct line *next;
-};
-
-DEFINE_LIST_SORT(static, sort_lines, struct line, next);
-
-static int compare_strings(const struct line *x, const struct line *y)
-{
- return strcmp(x->text, y->text);
-}
-
-static int sort_stdin(void)
-{
- struct line *lines;
- struct line **tail = &lines;
- struct strbuf sb = STRBUF_INIT;
- struct mem_pool lines_pool;
- char *p;
-
- strbuf_read(&sb, 0, 0);
-
- /*
- * Split by newline, but don't create an item
- * for the empty string after the last separator.
- */
- if (sb.len && sb.buf[sb.len - 1] == '\n')
- strbuf_setlen(&sb, sb.len - 1);
-
- mem_pool_init(&lines_pool, 0);
- p = sb.buf;
- for (;;) {
- char *eol = strchr(p, '\n');
- struct line *line = mem_pool_alloc(&lines_pool, sizeof(*line));
- line->text = p;
- *tail = line;
- tail = &line->next;
- if (!eol)
- break;
- *eol = '\0';
- p = eol + 1;
- }
- *tail = NULL;
-
- sort_lines(&lines, compare_strings);
-
- while (lines) {
- puts(lines->text);
- lines = lines->next;
- }
- mem_pool_discard(&lines_pool, 0);
- strbuf_release(&sb);
- return 0;
-}
-
-int cmd__mergesort(int argc, const char **argv)
-{
- if (argc == 2 && !strcmp(argv[1], "sort"))
- return sort_stdin();
- fprintf(stderr, "usage: test-tool mergesort sort\n");
- return 129;
-}
diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
index b71a22b43b..2e80dc7ab8 100644
--- a/t/helper/test-tool.c
+++ b/t/helper/test-tool.c
@@ -42,7 +42,6 @@ static struct test_cmd cmds[] = {
{ "json-writer", cmd__json_writer },
{ "lazy-init-name-hash", cmd__lazy_init_name_hash },
{ "match-trees", cmd__match_trees },
- { "mergesort", cmd__mergesort },
{ "mktemp", cmd__mktemp },
{ "name-hash", cmd__name_hash },
{ "online-cpus", cmd__online_cpus },
diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
index f2885b33d5..9442c61ffd 100644
--- a/t/helper/test-tool.h
+++ b/t/helper/test-tool.h
@@ -35,7 +35,6 @@ int cmd__hexdump(int argc, const char **argv);
int cmd__json_writer(int argc, const char **argv);
int cmd__lazy_init_name_hash(int argc, const char **argv);
int cmd__match_trees(int argc, const char **argv);
-int cmd__mergesort(int argc, const char **argv);
int cmd__mktemp(int argc, const char **argv);
int cmd__name_hash(int argc, const char **argv);
int cmd__online_cpus(int argc, const char **argv);
diff --git a/t/meson.build b/t/meson.build
index 2752321e0d..07436b63f4 100644
--- a/t/meson.build
+++ b/t/meson.build
@@ -1146,7 +1146,6 @@ benchmarks = [
'perf/p0006-read-tree-checkout.sh',
'perf/p0007-write-cache.sh',
'perf/p0008-odb-fsync.sh',
- 'perf/p0071-sort.sh',
'perf/p0090-cache-tree.sh',
'perf/p0100-globbing.sh',
'perf/p1006-cat-file.sh',
diff --git a/t/perf/p0071-sort.sh b/t/perf/p0071-sort.sh
deleted file mode 100755
index ae4ddac864..0000000000
--- a/t/perf/p0071-sort.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/sh
-
-test_description='Basic sort performance tests'
-. ./perf-lib.sh
-
-test_perf_default_repo
-
-test_expect_success 'setup' '
- git ls-files --stage "*.[ch]" "*.sh" |
- cut -f2 -d" " |
- git cat-file --batch >unsorted
-'
-
-test_perf 'sort(1) unsorted' '
- sort <unsorted >sorted
-'
-
-test_expect_success 'reverse' '
- sort -r <unsorted >reversed
-'
-
-for file in sorted reversed
-do
- test_perf "sort(1) $file" "
- sort <$file >actual
- "
-done
-
-for file in unsorted sorted reversed
-do
-
- test_perf "string_list_sort() $file" "
- test-tool string-list sort <$file >actual
- "
-
- test_expect_success "string_list_sort() $file sorts like sort(1)" "
- test_cmp_bin sorted actual
- "
-done
-
-for file in unsorted sorted reversed
-do
- test_perf "DEFINE_LIST_SORT $file" "
- test-tool mergesort sort <$file >actual
- "
-
- test_expect_success "DEFINE_LIST_SORT $file sorts like sort(1)" "
- test_cmp_bin sorted actual
- "
-done
-
-test_done
--
2.55.0
next prev parent reply other threads:[~2026-10-07 13:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 3:42 [PATCH] test-mergesort: plug memory leaks in sort_stdin() Muhammed Dilshad A
2026-10-07 6:13 ` Patrick Steinhardt
2026-10-07 17:27 ` Junio C Hamano
2026-10-07 13:50 ` [PATCH v2 0/3] mergesort: move tests to Clar and retire the helper Muhammed Dilshad A
2026-10-07 13:50 ` [PATCH v2 1/3] test-mergesort: plug memory leaks in sort_stdin() Muhammed Dilshad A
2026-10-07 13:50 ` [PATCH v2 2/3] mergesort: move sorting tests to the unit-test framework Muhammed Dilshad A
2026-10-09 11:52 ` Patrick Steinhardt
2026-10-09 13:55 ` Muhammed Dilshad A
2026-10-07 13:50 ` Muhammed Dilshad A [this message]
2026-10-09 11:52 ` [PATCH v2 0/3] mergesort: move tests to Clar and retire the helper Patrick Steinhardt
2026-10-09 13:56 ` Muhammed Dilshad A
2026-10-09 15:08 ` [PATCH v3 0/4] mergesort: move tests to Clar and remove " Muhammed Dilshad A
2026-10-09 15:08 ` [PATCH v3 1/4] mergesort: move sorting tests to Clar Muhammed Dilshad A
2026-10-09 15:08 ` [PATCH v3 2/4] mergesort: simplify the unit tests Muhammed Dilshad A
2026-10-09 15:08 ` [PATCH v3 3/4] mergesort: cover empty and small lists Muhammed Dilshad A
2026-10-09 15:08 ` [PATCH v3 4/4] t: retire the sorting benchmark and mergesort helper Muhammed Dilshad A
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=b540e3a3d2c30bccaaa0d8dca3428a77c1d2ea76.1791365181.git.dilsheddilu123@gmail.com \
--to=dilsheddilu123@gmail.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/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