From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 621B61B53E for ; Fri, 29 Jun 2018 17:31:35 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jun 2018 08:31:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,285,1526367600"; d="scan'208";a="53258838" Received: from bricha3-mobl.ger.corp.intel.com ([10.237.221.107]) by orsmga008.jf.intel.com with SMTP; 29 Jun 2018 08:31:29 -0700 Received: by (sSMTP sendmail emulation); Fri, 29 Jun 2018 16:31:28 +0100 Date: Fri, 29 Jun 2018 16:31:27 +0100 From: Bruce Richardson To: Medvedkin Vladimir Cc: dev@dpdk.org, thomas@monjalon.net, cristian.dumitrescu@intel.com Message-ID: <20180629153127.GA13896@bricha3-MOBL.ger.corp.intel.com> References: <1524780214-23196-1-git-send-email-medvedkinv@gmail.com> <1524780214-23196-4-git-send-email-medvedkinv@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1524780214-23196-4-git-send-email-medvedkinv@gmail.com> Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.10.0 (2018-05-17) Subject: Re: [dpdk-dev] [PATCH v4 3/4] Add autotests for RIB library 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: , X-List-Received-Date: Fri, 29 Jun 2018 15:31:37 -0000 On Fri, Apr 27, 2018 at 01:03:33AM +0300, Medvedkin Vladimir wrote: > Signed-off-by: Medvedkin Vladimir > --- > test/test/Makefile | 5 + > test/test/meson.build | 8 + > test/test/test_rib.c | 308 +++++++++++++++++++++++++++++++++++++++ > test/test/test_rib_generate_rt.c | 297 +++++++++++++++++++++++++++++++++++++ > test/test/test_rib_generate_rt.h | 38 +++++ > test/test/test_rib_lpm_comp.c | 189 ++++++++++++++++++++++++ > test/test/test_rib_perf.c | 145 ++++++++++++++++++ > 7 files changed, 990 insertions(+) > create mode 100644 test/test/test_rib.c > create mode 100644 test/test/test_rib_generate_rt.c > create mode 100644 test/test/test_rib_generate_rt.h > create mode 100644 test/test/test_rib_lpm_comp.c > create mode 100644 test/test/test_rib_perf.c > > diff --git a/test/test/test_rib_perf.c b/test/test/test_rib_perf.c > new file mode 100644 > index 0000000..42fbd1e > --- /dev/null > +++ b/test/test/test_rib_perf.c > @@ -0,0 +1,145 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2018 Vladimir Medvedkin > + */ > + > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "test.h" > +#include "test_xmmt_ops.h" > +#include "test_rib_generate_rt.h" > + > +#define TEST_RIB_ASSERT(cond) do { \ > + if (!(cond)) { \ > + printf("Error at line %d:\n", __LINE__); \ > + return -1; \ > + } \ > +} while (0) > + > +#define ITERATIONS (1 << 15) > +#define BATCH_SIZE (1 << 12) > +#define BULK_SIZE 32 > + > +#define NH_MSK(nh_sz) ((1ULL << ((1 << (3 + nh_sz)) - 1)) - 1) > + > +static int > +test_rib_perf(void) > +{ > + struct rte_rib *rib = NULL; > + struct rte_rib_conf conf; > + struct route_rule *rt; > + uint64_t begin, total_time; > + uint64_t next_hop_add; > + uint64_t default_nh = 0; > + int64_t count = 0; > + unsigned int i, j; > + int status = 0; > + int ret, nh_bits, nr_tbl8; > + uint32_t num_routes; > + > + conf.max_nodes = 3000000; > + conf.node_sz = sizeof(struct rte_rib_node); > + conf.type = RTE_RIB_DIR24_8; > + conf.fib_conf.dir24_8.def_nh = default_nh; > + conf.fib_conf.dir24_8.nh_sz = RTE_DIR24_8_8B; It's good that you are taking the worst-case to show the perf, but it means that the library comes out a bit slower than LPM in the autotest. How about running the same test cases for multiple data sizes, 8, 4, 2? > + > + rte_srand(rte_rdtsc()); > + > + nh_bits = RTE_MIN(((1 << (3 + conf.fib_conf.dir24_8.nh_sz)) - 1), 24); > + nr_tbl8 = RTE_MIN(((1 << nh_bits) - 1), 131071); > + conf.fib_conf.dir24_8.num_tbl8 = nr_tbl8; > + num_routes = 1200000; > + > + rt = rte_zmalloc("struct route_rule *", sizeof(struct route_rule) * > + num_routes, 0); > + TEST_RIB_ASSERT(rt != NULL); > + > + num_routes = generate_large_route_rule_table(num_routes, rt); > + TEST_RIB_ASSERT(num_routes != 0); > + > + printf("No. routes = %u\n", (unsigned int) num_routes); > + > + shuffle_rt(rt, num_routes); > + > + print_route_distribution(rt, (uint32_t) num_routes); > + > + rib = rte_rib_create(__func__, SOCKET_ID_ANY, &conf); > + TEST_RIB_ASSERT(rib != NULL); > + > + /* Measue add. */ > + begin = rte_rdtsc(); > + > + for (i = 0; i < num_routes; i++) { > + do { > + next_hop_add = rte_rand() & NH_MSK(conf.fib_conf.dir24_8.nh_sz); > + } while (next_hop_add == default_nh); > + > + ret = rte_rib_add(rib, rt[i].ip, rt[i].depth, next_hop_add); > + if ((ret == 0)) > + status++; > + } > + > + total_time = rte_rdtsc() - begin; > + > + printf("Unique added entries = %d\n", status); > + printf("Average RIB Add: %g cycles\n", > + (double)total_time / num_routes); > + > + /* Measure bulk Lookup */ > + total_time = 0; > + count = 0; > + for (i = 0; i < ITERATIONS; i++) { > + static uint32_t ip_batch[BATCH_SIZE]; > + uint64_t next_hops[BULK_SIZE]; > + > + /* Create array of random IP addresses */ > + for (j = 0; j < BATCH_SIZE; j++) > + ip_batch[j] = rte_rand(); > + > + /* Lookup per batch */ > + begin = rte_rdtsc(); > + for (j = 0; j < BATCH_SIZE; j += BULK_SIZE) > + rte_rib_fib_lookup_bulk(rib, &ip_batch[j], next_hops, > + BULK_SIZE); > + > + total_time += rte_rdtsc() - begin; > + for (j = 0; j < BULK_SIZE; j++) { > + if (next_hops[j] == default_nh) > + count++; > + } > + } > + printf("BULK RIB Lookup: %.1f cycles (fails = %.1f%%)\n", > + (double)total_time / ((double)ITERATIONS * BATCH_SIZE), > + (count * 100.0) / (double)(ITERATIONS * BATCH_SIZE)); > + > + /* Delete */ > + status = 0; > + begin = rte_rdtsc(); > + > + for (i = 0; i < num_routes; i++) { > + ret = rte_rib_delete(rib, rt[i].ip, rt[i].depth); > + if (ret == 0) > + status++; > + } > + > + total_time = rte_rdtsc() - begin; > + > + printf("Average RIB Delete: %g cycles\n", > + (double)total_time / num_routes); > + > + rte_rib_free(rib); > + rte_free(rt); > + > + return 0; > +} > + > +REGISTER_TEST_COMMAND(rib_perf_autotest, test_rib_perf); > -- > 1.8.3.1 >