From: Chandra Pratap <chandrapratap3519@gmail.com>
To: git@vger.kernel.org
Cc: Chandra Pratap <chandrapratap3519@gmail.com>,
Patrick Steinhardt <ps@pks.im>,
Christian Couder <chriscool@tuxfamily.org>
Subject: [PATCH v6 5/6] t-reftable-stack: add test for non-default compaction factor
Date: Sun, 8 Sep 2024 09:36:00 +0530 [thread overview]
Message-ID: <20240908041632.4948-6-chandrapratap3519@gmail.com> (raw)
In-Reply-To: <20240908041632.4948-1-chandrapratap3519@gmail.com>
In a recent codebase update (commit ae8e378430, merge branch
'ps/reftable-write-options', 2024/05/13) the geometric factor used
in auto-compaction of reftable tables was made configurable. Add
a test to verify the functionality introduced by this update.
Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
---
t/unit-tests/t-reftable-stack.c | 41 +++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/t/unit-tests/t-reftable-stack.c b/t/unit-tests/t-reftable-stack.c
index 4f2ef1a8cc..4acf07ab0c 100644
--- a/t/unit-tests/t-reftable-stack.c
+++ b/t/unit-tests/t-reftable-stack.c
@@ -831,12 +831,12 @@ static void t_empty_add(void)
reftable_stack_destroy(st2);
}
-static int fastlog2(uint64_t sz)
+static int fastlogN(uint64_t sz, uint64_t N)
{
int l = 0;
if (sz == 0)
return 0;
- for (; sz; sz /= 2)
+ for (; sz; sz /= N)
l++;
return l - 1;
}
@@ -869,11 +869,43 @@ static void t_reftable_stack_auto_compaction(void)
err = reftable_stack_auto_compact(st);
check(!err);
- check(i < 3 || st->merged->readers_len < 2 * fastlog2(i));
+ check(i < 2 || st->merged->readers_len < 2 * fastlogN(i, 2));
}
check_int(reftable_stack_compaction_stats(st)->entries_written, <,
- (uint64_t)(N * fastlog2(N)));
+ (uint64_t)(N * fastlogN(N, 2)));
+
+ reftable_stack_destroy(st);
+ clear_dir(dir);
+}
+
+static void t_reftable_stack_auto_compaction_factor(void)
+{
+ struct reftable_write_options opts = {
+ .auto_compaction_factor = 5,
+ };
+ struct reftable_stack *st = NULL;
+ char *dir = get_tmp_dir(__LINE__);
+ int err;
+ size_t N = 100;
+
+ err = reftable_new_stack(&st, dir, &opts);
+ check(!err);
+
+ for (size_t i = 0; i < N; i++) {
+ char name[20];
+ struct reftable_ref_record ref = {
+ .refname = name,
+ .update_index = reftable_stack_next_update_index(st),
+ .value_type = REFTABLE_REF_VAL1,
+ };
+ xsnprintf(name, sizeof(name), "branch%04"PRIuMAX, (uintmax_t)i);
+
+ err = reftable_stack_add(st, &write_test_ref, &ref);
+ check(!err);
+
+ check(i < 5 || st->merged->readers_len < 5 * fastlogN(i, 5));
+ }
reftable_stack_destroy(st);
clear_dir(dir);
@@ -1186,6 +1218,7 @@ int cmd_main(int argc UNUSED, const char *argv[] UNUSED)
TEST(t_reftable_stack_add_one(), "add a single ref record to stack");
TEST(t_reftable_stack_add_performs_auto_compaction(), "addition to stack triggers auto-compaction");
TEST(t_reftable_stack_auto_compaction(), "stack must form geometric sequence after compaction");
+ TEST(t_reftable_stack_auto_compaction_factor(), "auto-compaction with non-default geometric factor");
TEST(t_reftable_stack_auto_compaction_fails_gracefully(), "failure on auto-compaction");
TEST(t_reftable_stack_auto_compaction_with_locked_tables(), "auto compaction with locked tables");
TEST(t_reftable_stack_compaction_concurrent(), "compaction with concurrent stack");
--
2.45.GIT
next prev parent reply other threads:[~2024-09-08 4:18 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-06 14:13 [GSoC][PATCH 0/6] t: port reftable/stack_test.c to the unit testing framework Chandra Pratap
2024-08-06 14:13 ` [PATCH 1/6] t: move " Chandra Pratap
2024-08-06 14:13 ` [PATCH 2/6] t: harmonize t-reftable-stack.c with coding guidelines Chandra Pratap
2024-08-06 18:20 ` Eric Sunshine
2024-08-07 5:23 ` Patrick Steinhardt
2024-08-06 14:13 ` [PATCH 3/6] t-reftable-stack: use Git's tempfile API instead of mkstemp() Chandra Pratap
2024-08-06 20:47 ` Junio C Hamano
2024-08-07 5:23 ` Patrick Steinhardt
2024-08-06 14:13 ` [PATCH 4/6] t-reftable-stack: use reftable_ref_record_equal() to compare ref records Chandra Pratap
2024-08-07 5:23 ` Patrick Steinhardt
2024-08-07 14:42 ` Chandra Pratap
2024-08-08 4:07 ` Patrick Steinhardt
2024-08-06 14:13 ` [PATCH 5/6] t-reftable-stack: add test for non-default compaction factor Chandra Pratap
2024-08-06 14:13 ` [PATCH 6/6] t-reftable-stack: add test for stack iterators Chandra Pratap
2024-08-07 5:23 ` Patrick Steinhardt
2024-08-06 20:38 ` [GSoC][PATCH 0/6] t: port reftable/stack_test.c to the unit testing framework Junio C Hamano
2024-08-07 13:01 ` Chandra Pratap
2024-08-23 11:48 ` [GSoC][PATCH v2 " Chandra Pratap
2024-08-23 11:48 ` [PATCH v2 1/6] t: move " Chandra Pratap
2024-08-23 11:48 ` [PATCH v2 2/6] t: harmonize t-reftable-stack.c with coding guidelines Chandra Pratap
2024-08-26 6:39 ` Patrick Steinhardt
2024-08-23 11:48 ` [PATCH v2 3/6] t-reftable-stack: use Git's tempfile API instead of mkstemp() Chandra Pratap
2024-08-23 11:48 ` [PATCH v2 4/6] t-reftable-stack: use reftable_ref_record_equal() to compare ref records Chandra Pratap
2024-08-23 11:48 ` [PATCH v2 5/6] t-reftable-stack: add test for non-default compaction factor Chandra Pratap
2024-08-23 11:48 ` [PATCH v2 6/6] t-reftable-stack: add test for stack iterators Chandra Pratap
2024-08-26 6:39 ` Patrick Steinhardt
2024-08-26 17:29 ` [GSoC][PATCH v3 0/6] t: port reftable/stack_test.c to the unit testing framework Chandra Pratap
2024-08-26 17:29 ` [PATCH v3 1/6] t: move " Chandra Pratap
2024-08-26 17:29 ` [PATCH v3 2/6] t: harmonize t-reftable-stack.c with coding guidelines Chandra Pratap
2024-08-26 17:29 ` [PATCH v3 3/6] t-reftable-stack: use Git's tempfile API instead of mkstemp() Chandra Pratap
2024-08-26 17:29 ` [PATCH v3 4/6] t-reftable-stack: use reftable_ref_record_equal() to compare ref records Chandra Pratap
2024-08-26 17:29 ` [PATCH v3 5/6] t-reftable-stack: add test for non-default compaction factor Chandra Pratap
2024-08-26 17:29 ` [PATCH v3 6/6] t-reftable-stack: add test for stack iterators Chandra Pratap
2024-08-26 17:48 ` [GSoC][PATCH v3 0/6] t: port reftable/stack_test.c to the unit testing framework Junio C Hamano
2024-08-26 18:34 ` Chandra Pratap
2024-08-26 19:07 ` Junio C Hamano
2024-08-26 19:26 ` Junio C Hamano
2024-09-04 14:38 ` [GSoC][PATCH v4 " Chandra Pratap
2024-09-04 14:38 ` [PATCH v4 1/6] t: move " Chandra Pratap
2024-09-04 17:17 ` Junio C Hamano
2024-09-05 7:15 ` Patrick Steinhardt
2024-09-05 14:45 ` Chandra Pratap
2024-09-05 15:00 ` Patrick Steinhardt
2024-09-05 18:42 ` Junio C Hamano
2024-09-06 6:02 ` Patrick Steinhardt
2024-09-04 14:38 ` [PATCH v4 2/6] t: harmonize t-reftable-stack.c with coding guidelines Chandra Pratap
2024-09-04 14:38 ` [PATCH v4 3/6] t-reftable-stack: use Git's tempfile API instead of mkstemp() Chandra Pratap
2024-09-05 7:14 ` Patrick Steinhardt
2024-09-04 14:38 ` [PATCH v4 4/6] t-reftable-stack: use reftable_ref_record_equal() to compare ref records Chandra Pratap
2024-09-05 7:15 ` Patrick Steinhardt
2024-09-04 14:38 ` [PATCH v4 5/6] t-reftable-stack: add test for non-default compaction factor Chandra Pratap
2024-09-04 14:38 ` [PATCH v4 6/6] t-reftable-stack: add test for stack iterators Chandra Pratap
2024-09-05 7:15 ` Patrick Steinhardt
2024-09-06 11:29 ` [GSoC][PATCH v5 0/7] t: port reftable/stack_test.c to the unit testing framework Chandra Pratap
2024-09-06 11:29 ` [PATCH v5 1/7] t: move " Chandra Pratap
2024-09-06 11:29 ` [PATCH v5 2/7] t: harmonize t-reftable-stack.c with coding guidelines Chandra Pratap
2024-09-06 11:29 ` [PATCH v5 3/7] t-reftable-stack: use Git's tempfile API instead of mkstemp() Chandra Pratap
2024-09-06 11:29 ` [PATCH v5 4/7] t-reftable-stack: use reftable_ref_record_equal() to compare ref records Chandra Pratap
2024-09-06 11:29 ` [PATCH v5 5/7] t-reftable-stack: add test for non-default compaction factor Chandra Pratap
2024-09-06 11:29 ` [PATCH v5 6/7] t-reftable-stack: add test for stack iterators Chandra Pratap
2024-09-06 11:29 ` [PATCH v5 7/7] t: clean up leftover reftable test cruft Chandra Pratap
2024-09-06 16:38 ` [GSoC][PATCH v5 0/7] t: port reftable/stack_test.c to the unit testing framework Junio C Hamano
2024-09-06 23:57 ` Junio C Hamano
2024-09-08 4:05 ` [GSoC][PATCH v6 0/6] " Chandra Pratap
2024-09-08 4:05 ` [PATCH v6 1/6] t: move " Chandra Pratap
2024-09-08 4:05 ` [PATCH v6 2/6] t: harmonize t-reftable-stack.c with coding guidelines Chandra Pratap
2024-09-08 4:05 ` [PATCH v6 3/6] t-reftable-stack: use Git's tempfile API instead of mkstemp() Chandra Pratap
2024-09-08 4:05 ` [PATCH v6 4/6] t-reftable-stack: use reftable_ref_record_equal() to compare ref records Chandra Pratap
2024-09-09 11:42 ` Patrick Steinhardt
2024-09-08 4:06 ` Chandra Pratap [this message]
2024-09-08 4:06 ` [PATCH v6 6/6] t-reftable-stack: add test for stack iterators Chandra Pratap
2024-09-09 11:42 ` [GSoC][PATCH v6 0/6] t: port reftable/stack_test.c to the unit testing framework Patrick Steinhardt
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=20240908041632.4948-6-chandrapratap3519@gmail.com \
--to=chandrapratap3519@gmail.com \
--cc=chriscool@tuxfamily.org \
--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;
as well as URLs for NNTP newsgroup(s).