From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: david.marchand@redhat.com, Yipeng Wang <yipeng1.wang@intel.com>,
	Sameh Gobriel <sameh.gobriel@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Subject: [PATCH 2/2] test/hash: reduce time of functional R/W test
Date: Thu, 30 Oct 2025 18:50:12 +0100	[thread overview]
Message-ID: <20251030175329.4041960-3-thomas@monjalon.net> (raw)
In-Reply-To: <20251030175329.4041960-1-thomas@monjalon.net>
When running on limited platforms like GitHub Actions,
the functional unit test "hash_readwrite_func_autotest"
will hit a timeout, especially when running with UBSan:
46/102 DPDK:fast-tests / hash_readwrite_func_autotest  TIMEOUT  30.01s
killed by signal 15 SIGTERM
Similarly to what was done in the
commit fd368e1982bc ("test/hash: test more corner cases"),
some constants are decreased.
In order to keep the performance test as it was,
a multiplier is kept for performance test case only.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 app/test/test_hash_readwrite.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/app/test/test_hash_readwrite.c b/app/test/test_hash_readwrite.c
index 22ccd6df6a..4d140439e4 100644
--- a/app/test/test_hash_readwrite.c
+++ b/app/test/test_hash_readwrite.c
@@ -18,9 +18,11 @@
 
 #define RTE_RWTEST_FAIL 0
 
-#define TOTAL_ENTRY (5*1024*1024)
-#define TOTAL_INSERT (4.5*1024*1024)
-#define TOTAL_INSERT_EXT (5*1024*1024)
+#define TOTAL_ENTRY           (5*1024) /* must be multiplied for perf test */
+#define TOTAL_INSERT_FUNC   (4.5*1024)
+#define TOTAL_INSERT_FUNC_EXT (5*1024)
+#define PERF_MULTIPLIER  1024
+#define TOTAL_INSERT (TOTAL_INSERT_FUNC * PERF_MULTIPLIER) /* only for perf */
 
 #define NUM_TEST 3
 unsigned int core_cnt[NUM_TEST] = {2, 4, 8};
@@ -136,16 +138,15 @@ test_hash_readwrite_worker(__rte_unused void *arg)
 }
 
 static int
-init_params(int use_ext, int use_htm, int rw_lf, int use_jhash)
+init_params(int use_ext, int use_htm, int rw_lf, int use_jhash, bool perf)
 {
 	unsigned int i;
-
 	uint32_t *keys = NULL;
 	uint8_t *found = NULL;
 	struct rte_hash *handle;
 
 	struct rte_hash_parameters hash_params = {
-		.entries = TOTAL_ENTRY,
+		.entries = TOTAL_ENTRY * (perf ? PERF_MULTIPLIER : 1),
 		.key_len = sizeof(uint32_t),
 		.hash_func_init_val = 0,
 		.socket_id = rte_socket_id(),
@@ -182,14 +183,13 @@ init_params(int use_ext, int use_htm, int rw_lf, int use_jhash)
 	}
 
 	tbl_rw_test_param.h = handle;
-	keys = rte_malloc(NULL, sizeof(uint32_t) * TOTAL_ENTRY, 0);
-
+	keys = rte_malloc(NULL, sizeof(uint32_t) * hash_params.entries, 0);
 	if (keys == NULL) {
 		printf("RTE_MALLOC failed\n");
 		goto err;
 	}
 
-	found = rte_zmalloc(NULL, sizeof(uint8_t) * TOTAL_ENTRY, 0);
+	found = rte_zmalloc(NULL, sizeof(uint8_t) * hash_params.entries, 0);
 	if (found == NULL) {
 		printf("RTE_ZMALLOC failed\n");
 		goto err;
@@ -198,7 +198,7 @@ init_params(int use_ext, int use_htm, int rw_lf, int use_jhash)
 	tbl_rw_test_param.keys = keys;
 	tbl_rw_test_param.found = found;
 
-	for (i = 0; i < TOTAL_ENTRY; i++)
+	for (i = 0; i < hash_params.entries; i++)
 		keys[i] = i;
 
 	return 0;
@@ -227,13 +227,13 @@ test_hash_readwrite_functional(int use_htm, int use_rw_lf, int use_ext)
 	rte_atomic_store_explicit(&gcycles, 0, rte_memory_order_relaxed);
 	rte_atomic_store_explicit(&ginsertions, 0, rte_memory_order_relaxed);
 
-	if (init_params(use_ext, use_htm, use_rw_lf, use_jhash) != 0)
+	if (init_params(use_ext, use_htm, use_rw_lf, use_jhash, false) != 0)
 		goto err;
 
 	if (use_ext)
-		tot_insert = TOTAL_INSERT_EXT;
+		tot_insert = TOTAL_INSERT_FUNC_EXT;
 	else
-		tot_insert = TOTAL_INSERT;
+		tot_insert = TOTAL_INSERT_FUNC;
 
 	tbl_rw_test_param.num_insert =
 		tot_insert / worker_cnt;
@@ -390,7 +390,7 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm,
 	rte_atomic_store_explicit(&gread_cycles, 0, rte_memory_order_relaxed);
 	rte_atomic_store_explicit(&gwrite_cycles, 0, rte_memory_order_relaxed);
 
-	if (init_params(0, use_htm, 0, use_jhash) != 0)
+	if (init_params(0, use_htm, 0, use_jhash, true) != 0)
 		goto err;
 
 	/*
@@ -548,7 +548,7 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm,
 		rte_eal_mp_wait_lcore();
 
 		iter = 0;
-		memset(tbl_rw_test_param.found, 0, TOTAL_ENTRY);
+		memset(tbl_rw_test_param.found, 0, TOTAL_ENTRY * PERF_MULTIPLIER);
 		while (rte_hash_iterate(tbl_rw_test_param.h,
 				&next_key, &next_data, &iter) >= 0) {
 			/* Search for the key in the list of keys added .*/
-- 
2.51.0
     prev parent reply	other threads:[~2025-10-30 17:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-30 17:50 [PATCH 0/2] fix hash unit test for CI Thomas Monjalon
2025-10-30 17:50 ` [PATCH 1/2] test/hash: check memory allocation Thomas Monjalon
2025-10-30 17:50 ` Thomas Monjalon [this message]
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=20251030175329.4041960-3-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=sameh.gobriel@intel.com \
    --cc=vladimir.medvedkin@intel.com \
    --cc=yipeng1.wang@intel.com \
    /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).