From: Nikita Kozlov <nikita@elyzion.net>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [PATCH 4/4] test: change lpm perf test to use routes as resource
Date: Tue, 14 Jun 2016 15:03:30 +0200 [thread overview]
Message-ID: <1465909410-4668-5-git-send-email-nikita@elyzion.net> (raw)
In-Reply-To: <1465909410-4668-1-git-send-email-nikita@elyzion.net>
Change the lpm perf autotest to use the routes data from the resource data
stored in the binary rather than including it directly into the C file
as a C header. This speeds up compile and link time, without changing
the test results.
Signed-off-by: Nikita Kozlov <nikita@elyzion.net>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
app/test/test_lpm_perf.c | 83 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 76 insertions(+), 7 deletions(-)
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index 41da811..f72250f 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -34,16 +34,28 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
+#include <string.h>
#include <rte_cycles.h>
#include <rte_random.h>
#include <rte_branch_prediction.h>
#include <rte_lpm.h>
+#include <rte_ip.h>
+#include <rte_malloc.h>
#include "test.h"
-#include "test_lpm_routes.h"
+#include "resource.h"
#include "test_xmmt_ops.h"
+REGISTER_LINKED_RESOURCE(test_lpm_data)
+
+struct route_rule {
+ uint32_t ip;
+ uint8_t depth;
+};
+static struct route_rule *large_route_table;
+static unsigned int num_route_entries;
+
#define TEST_LPM_ASSERT(cond) do { \
if (!(cond)) { \
printf("Error at line %d: \n", __LINE__); \
@@ -80,6 +92,62 @@ print_route_distribution(const struct route_rule *table, uint32_t n)
}
static int
+load_large_route_table(void)
+{
+ const struct resource *r;
+ const char *lpm_data;
+
+ r = resource_find("test_lpm_data");
+ TEST_ASSERT_NOT_NULL(r, "No large lpm table data found");
+
+ /* the routing table size is going to be less than the size of the
+ * resource, since text extries are more verbose. Allocate this as
+ * the max size, and shrink the allocation later
+ */
+ large_route_table = rte_malloc(NULL, resource_size(r), 0);
+ if (large_route_table == NULL)
+ return -1;
+
+ /* parse the lpm table. All entries are of format:
+ * {IP-as-decimal-unsigned, depth}
+ * For example:
+ * {1234567U, 24},
+ * We use the "U" and "}" characters as format check characters,
+ * after parsing each number.
+ */
+ for (lpm_data = r->begin; lpm_data < r->end; lpm_data++) {
+ if (*lpm_data == '{') {
+ char *endptr;
+
+ lpm_data++;
+ large_route_table[num_route_entries].ip = \
+ strtoul(lpm_data, &endptr, 0);
+ if (*endptr != 'U') {
+ if (num_route_entries > 0)
+ printf("Failed parse of %.*s\n", 12, lpm_data);
+ continue;
+ }
+
+ lpm_data = endptr + 2; /* skip U and , */
+ large_route_table[num_route_entries].depth = \
+ strtoul(lpm_data, &endptr, 0);
+ if (*endptr != '}') {
+ if (num_route_entries > 0)
+ printf("Failed parse of %.*s\n",5, lpm_data);
+ continue;
+ }
+
+ num_route_entries++;
+ }
+ }
+
+ large_route_table = rte_realloc(large_route_table,
+ sizeof(large_route_table[0]) * num_route_entries, 0);
+ printf("Read %u route entries\n", num_route_entries);
+ return 0;
+}
+
+static int
test_lpm_perf(void)
{
struct rte_lpm *lpm = NULL;
@@ -97,9 +165,10 @@ test_lpm_perf(void)
rte_srand(rte_rdtsc());
- printf("No. routes = %u\n", (unsigned) NUM_ROUTE_ENTRIES);
+ TEST_ASSERT_SUCCESS(load_large_route_table(), "Error loading lpm table");
+ printf("No. routes = %u\n", (unsigned) num_route_entries);
- print_route_distribution(large_route_table, (uint32_t) NUM_ROUTE_ENTRIES);
+ print_route_distribution(large_route_table, (uint32_t) num_route_entries);
lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
TEST_LPM_ASSERT(lpm != NULL);
@@ -107,7 +176,7 @@ test_lpm_perf(void)
/* Measue add. */
begin = rte_rdtsc();
- for (i = 0; i < NUM_ROUTE_ENTRIES; i++) {
+ for (i = 0; i < num_route_entries; i++) {
if (rte_lpm_add(lpm, large_route_table[i].ip,
large_route_table[i].depth, next_hop_add) == 0)
status++;
@@ -136,7 +205,7 @@ test_lpm_perf(void)
(unsigned) cache_line_counter, (unsigned) cache_line_counter * 64);
printf("Average LPM Add: %g cycles\n",
- (double)total_time / NUM_ROUTE_ENTRIES);
+ (double)total_time / num_route_entries);
/* Measure single Lookup */
total_time = 0;
@@ -225,7 +294,7 @@ test_lpm_perf(void)
status = 0;
begin = rte_rdtsc();
- for (i = 0; i < NUM_ROUTE_ENTRIES; i++) {
+ for (i = 0; i < num_route_entries; i++) {
/* rte_lpm_delete(lpm, ip, depth) */
status += rte_lpm_delete(lpm, large_route_table[i].ip,
large_route_table[i].depth);
@@ -234,7 +303,7 @@ test_lpm_perf(void)
total_time += rte_rdtsc() - begin;
printf("Average LPM Delete: %g cycles\n",
- (double)total_time / NUM_ROUTE_ENTRIES);
+ (double)total_time / num_route_entries);
rte_lpm_delete_all(lpm);
rte_lpm_free(lpm);
--
2.8.1
next prev parent reply other threads:[~2016-06-14 13:03 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-06 12:51 [dpdk-dev] [RFC PATCH 0/4] Convert lpm data from header to resource Bruce Richardson
2016-05-06 12:51 ` [dpdk-dev] [RFC PATCH 1/4] test: add lpm routes as a linked resource Bruce Richardson
2016-05-06 12:51 ` [dpdk-dev] [RFC PATCH 2/4] test: make all lpm routes be of unsigned type Bruce Richardson
2016-05-06 12:51 ` [dpdk-dev] [RFC PATCH 3/4] test: change lpm test to use routes as resource Bruce Richardson
2016-05-06 13:02 ` Bruce Richardson
2016-05-06 12:51 ` [dpdk-dev] [RFC PATCH 4/4] test: change lpm routes file from header to data file Bruce Richardson
2016-05-06 13:20 ` [dpdk-dev] [RFC PATCH 0/4] Convert lpm data from header to resource Thomas Monjalon
2016-06-14 13:03 ` [dpdk-dev] [PATCH " Nikita Kozlov
2016-06-14 13:03 ` [dpdk-dev] [PATCH 1/4] test: make all lpm routes be of unsigned type Nikita Kozlov
2016-06-14 13:03 ` [dpdk-dev] [PATCH 2/4] test: change lpm routes file from header to data file Nikita Kozlov
2016-06-14 13:03 ` [dpdk-dev] [PATCH 3/4] test: change lpm test to use routes as resource Nikita Kozlov
2016-06-14 13:03 ` Nikita Kozlov [this message]
2016-06-14 14:25 ` [dpdk-dev] [PATCH 0/4] Convert lpm data from header to resource Thomas Monjalon
2016-07-14 16:06 ` [dpdk-dev] [PATCH v2 0/5] change lpm route table from code to data Bruce Richardson
2016-07-14 16:06 ` [dpdk-dev] [PATCH v2 1/5] test: fix unneeded routes table include from lpm test Bruce Richardson
2016-07-14 16:06 ` [dpdk-dev] [PATCH v2 2/5] test: make all lpm routes be of unsigned type Bruce Richardson
2016-07-14 16:06 ` [dpdk-dev] [PATCH v2 3/5] test: add lpm routes as a linked resource Bruce Richardson
2016-07-14 16:06 ` [dpdk-dev] [PATCH v2 4/5] test: change lpm test to use routes as resource Bruce Richardson
2016-07-14 16:06 ` [dpdk-dev] [PATCH v2 5/5] test: change lpm routes file from header to data file Bruce Richardson
2016-07-15 23:05 ` Thomas Monjalon
2016-07-16 9:46 ` Richardson, Bruce
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=1465909410-4668-5-git-send-email-nikita@elyzion.net \
--to=nikita@elyzion.net \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/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).