DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
To: dev@dpdk.org
Cc: konstantin.ananyev@intel.com, yipeng1.wang@intel.com,
	sameh.gobriel@intel.com, bruce.richardson@intel.com
Subject: [dpdk-dev] [PATCH v4 4/4] test: add kv perf tests
Date: Fri,  8 May 2020 20:58:53 +0100	[thread overview]
Message-ID: <ca57e24b5a3fcba5beac144a04f24f60117c22e0.1588967563.git.vladimir.medvedkin@intel.com> (raw)
In-Reply-To: <cover.1588967562.git.vladimir.medvedkin@intel.com>
In-Reply-To: <cover.1588967562.git.vladimir.medvedkin@intel.com>

Add performance tests for rte_kv_hash

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 app/test/test_hash_perf.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 111 insertions(+)

diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c
index 76cdac5..3d4c13d 100644
--- a/app/test/test_hash_perf.c
+++ b/app/test/test_hash_perf.c
@@ -12,8 +12,10 @@
 #include <rte_hash_crc.h>
 #include <rte_jhash.h>
 #include <rte_fbk_hash.h>
+#include <rte_kv_hash.h>
 #include <rte_random.h>
 #include <rte_string_fns.h>
+#include <rte_hash_crc.h>
 
 #include "test.h"
 
@@ -29,6 +31,8 @@
 #define NUM_SHUFFLES 10
 #define BURST_SIZE 16
 
+#define CRC_INIT_VAL	0xdeadbeef
+
 enum operations {
 	ADD = 0,
 	LOOKUP,
@@ -719,6 +723,110 @@ fbk_hash_perf_test(void)
 	return 0;
 }
 
+static uint32_t *
+shuf_arr(uint32_t *arr, int n, int l)
+{
+	int i, j;
+	uint32_t tmp;
+	uint32_t *ret_arr;
+
+	ret_arr = rte_zmalloc(NULL, l * sizeof(uint32_t), 0);
+	for (i = 0; i < n; i++) {
+		j = rte_rand() % n;
+		tmp = arr[j];
+		arr[j] = arr[i];
+		arr[i] = tmp;
+	}
+	for (i = 0; i < l; i++)
+		ret_arr[i] = arr[i % n];
+
+	return ret_arr;
+}
+
+static int
+kv_hash_perf_test(void)
+{
+	struct rte_kv_hash_params params = {
+		.name = "kv_hash_test",
+		.entries = ENTRIES * 2,
+		.socket_id = rte_socket_id(),
+		.type = RTE_KV_HASH_K32V64,
+	};
+	struct rte_kv_hash_table *handle = NULL;
+	uint32_t *keys;
+	uint32_t *lookup_keys;
+	uint64_t lookup_time = 0;
+	uint64_t begin;
+	uint64_t end;
+	unsigned int added = 0;
+	uint32_t key, hash_sig;
+	uint16_t val;
+	unsigned int i, j, k;
+	int found, ret = 0;
+	uint32_t hashes[64];
+	uint64_t vals[64];
+
+	handle = rte_kv_hash_create(&params);
+	if (handle == NULL) {
+		printf("Error creating table\n");
+		return -1;
+	}
+
+	keys = rte_zmalloc(NULL, ENTRIES * sizeof(*keys), 0);
+	if (keys == NULL) {
+		printf("fbk hash: memory allocation for key store failed\n");
+		return -1;
+	}
+
+	/* Generate random keys and values. */
+	for (i = 0; i < ENTRIES; i++) {
+		key = (uint32_t)rte_rand();
+		val = rte_rand();
+		hash_sig = rte_hash_crc_4byte(key, CRC_INIT_VAL);
+
+		if (rte_kv_hash_add(handle, &key, hash_sig, &val,
+				&found) == 0) {
+			keys[added] = key;
+			added++;
+		}
+	}
+
+	lookup_keys = shuf_arr(keys, added, TEST_SIZE);
+
+	lookup_time = 0;
+	for (i = 0; i < TEST_ITERATIONS; i++) {
+
+		begin = rte_rdtsc();
+		/* Do lookups */
+
+		for (j = 0; j < TEST_SIZE; j += 64) {
+			for (k = 0; k < 64; k++) {
+				hashes[k] =
+					rte_hash_crc_4byte(lookup_keys[j + k],
+						CRC_INIT_VAL);
+			}
+
+			ret += rte_kv_hash_bulk_lookup(handle,
+				&lookup_keys[j], hashes, vals, 64);
+		}
+
+		end = rte_rdtsc();
+		lookup_time += (double)(end - begin);
+	}
+
+	printf("\n\n *** KV Hash function performance test results ***\n");
+	if (ret != 0)
+		printf("Number of ticks per bulk lookup = %g\n",
+			(double)lookup_time /
+			((double)TEST_ITERATIONS * (double)TEST_SIZE));
+
+	rte_free(keys);
+	rte_free(lookup_keys);
+	rte_kv_hash_free(handle);
+
+	return 0;
+}
+
 static int
 test_hash_perf(void)
 {
@@ -746,6 +854,9 @@ test_hash_perf(void)
 	if (fbk_hash_perf_test() < 0)
 		return -1;
 
+	if (kv_hash_perf_test() < 0)
+		return -1;
+
 	return 0;
 }
 
-- 
2.7.4


  parent reply	other threads:[~2020-05-08 19:59 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-16 13:38 [dpdk-dev] [PATCH 0/3] add new Double Word Key hash table Vladimir Medvedkin
2020-03-16 13:38 ` [dpdk-dev] [PATCH 1/3] hash: add dwk hash library Vladimir Medvedkin
2020-03-16 13:38 ` [dpdk-dev] [PATCH 2/3] test: add dwk hash autotests Vladimir Medvedkin
2020-03-16 13:38 ` [dpdk-dev] [PATCH 3/3] test: add dwk perf tests Vladimir Medvedkin
2020-03-16 14:39 ` [dpdk-dev] [PATCH 0/3] add new Double Word Key hash table Morten Brørup
2020-03-16 18:27   ` Medvedkin, Vladimir
2020-03-16 19:32     ` Stephen Hemminger
2020-03-17 19:52       ` Wang, Yipeng1
2020-03-26 17:28         ` Medvedkin, Vladimir
2020-03-31 19:55           ` Thomas Monjalon
2020-03-31 21:17             ` Honnappa Nagarahalli
2020-04-01 18:37               ` Medvedkin, Vladimir
2020-04-01 18:28             ` Medvedkin, Vladimir
2020-03-16 19:33     ` Morten Brørup
2020-04-08 18:19 ` [dpdk-dev] [PATCH v2 0/4] add new k32v64 " Vladimir Medvedkin
2020-04-15 18:17   ` [dpdk-dev] [PATCH v3 " Vladimir Medvedkin
2020-04-15 18:51     ` Mattias Rönnblom
2020-04-16 10:18       ` Medvedkin, Vladimir
2020-04-16 11:40         ` Mattias Rönnblom
2020-04-17  0:21           ` Wang, Yipeng1
2020-04-23 16:19             ` Ananyev, Konstantin
2020-05-08 20:08             ` Medvedkin, Vladimir
2020-04-16  9:39     ` Thomas Monjalon
2020-04-16 14:02       ` Medvedkin, Vladimir
2020-04-16 14:38         ` Thomas Monjalon
2020-05-08 19:58     ` [dpdk-dev] [PATCH v4 0/4] add new kv " Vladimir Medvedkin
2020-06-16 16:37       ` Thomas Monjalon
2021-03-24 21:28       ` Thomas Monjalon
2021-03-25 12:03         ` Medvedkin, Vladimir
2023-06-12 16:11           ` Stephen Hemminger
2020-05-08 19:58     ` [dpdk-dev] [PATCH v4 1/4] hash: add kv hash library Vladimir Medvedkin
2020-06-23 15:44       ` Ananyev, Konstantin
2020-06-23 23:06         ` Ananyev, Konstantin
2020-06-25 19:56           ` Medvedkin, Vladimir
2020-06-25 19:49         ` Medvedkin, Vladimir
2020-06-24  1:19       ` Wang, Yipeng1
2020-06-25 20:26         ` Medvedkin, Vladimir
2020-06-25  4:27       ` Honnappa Nagarahalli
2020-05-08 19:58     ` [dpdk-dev] [PATCH v4 2/4] hash: add documentation for " Vladimir Medvedkin
2020-05-08 19:58     ` [dpdk-dev] [PATCH v4 3/4] test: add kv hash autotests Vladimir Medvedkin
2020-05-08 19:58     ` Vladimir Medvedkin [this message]
2020-04-15 18:17   ` [dpdk-dev] [PATCH v3 1/4] hash: add k32v64 hash library Vladimir Medvedkin
2020-04-15 18:59     ` Mattias Rönnblom
2020-04-16 10:23       ` Medvedkin, Vladimir
2020-04-23 13:31     ` Ananyev, Konstantin
2020-05-08 20:14       ` Medvedkin, Vladimir
2020-04-29 21:29     ` Honnappa Nagarahalli
2020-05-08 20:38       ` Medvedkin, Vladimir
2020-04-15 18:17   ` [dpdk-dev] [PATCH v3 2/4] hash: add documentation for " Vladimir Medvedkin
2020-04-15 18:17   ` [dpdk-dev] [PATCH v3 3/4] test: add k32v64 hash autotests Vladimir Medvedkin
2020-04-15 18:17   ` [dpdk-dev] [PATCH v3 4/4] test: add k32v64 perf tests Vladimir Medvedkin
2020-04-08 18:19 ` [dpdk-dev] [PATCH v2 1/4] hash: add k32v64 hash library Vladimir Medvedkin
2020-04-08 23:23   ` Ananyev, Konstantin
2020-04-08 18:19 ` [dpdk-dev] [PATCH v2 2/4] hash: add documentation for " Vladimir Medvedkin
2020-04-08 18:19 ` [dpdk-dev] [PATCH v2 3/4] test: add k32v64 hash autotests Vladimir Medvedkin
2020-04-08 18:19 ` [dpdk-dev] [PATCH v2 4/4] test: add k32v64 perf tests Vladimir Medvedkin

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=ca57e24b5a3fcba5beac144a04f24f60117c22e0.1588967563.git.vladimir.medvedkin@intel.com \
    --to=vladimir.medvedkin@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.com \
    --cc=sameh.gobriel@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).