From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1682CA0352; Fri, 8 May 2020 21:59:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0B43A1DA75; Fri, 8 May 2020 21:59:08 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id E73511DA3F for ; Fri, 8 May 2020 21:59:03 +0200 (CEST) IronPort-SDR: T18bwIimZQMe9pmlF2T+GQgrXI7wt0pTO6N4yMT9IF4u6reqYdFg2I/YKn8uB3DR2O9qspCcDg DKcFgGf861vQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2020 12:59:03 -0700 IronPort-SDR: UCm/PZjVKwfO6LgAVU8H7KcyZrUwxQFpPdyNBGKzWWPOOpm0Sp0ecQ69Cg8m31KkhPeThUjpqV AomA1gRQtmIA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,368,1583222400"; d="scan'208";a="285584905" Received: from silpixa00400072.ir.intel.com ([10.237.222.213]) by fmsmga004.fm.intel.com with ESMTP; 08 May 2020 12:59:02 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com Date: Fri, 8 May 2020 20:58:53 +0100 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 4/4] test: add kv perf tests X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add performance tests for rte_kv_hash Signed-off-by: Vladimir Medvedkin --- 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 #include #include +#include #include #include +#include #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(¶ms); + 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