DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/test: remove large lpm test head file
@ 2016-09-26  9:37 Wei Dai
  2016-09-26  9:56 ` Thomas Monjalon
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Wei Dai @ 2016-09-26  9:37 UTC (permalink / raw)
  To: dev, bruce.richardson, wei.dai

remove the large file app/test/test_lpm_routes.h and add codes to
auto-generate similar large route rule talbe which keeps same depth
and IP class distribution as previous one in test_lpm_routes.h .
With the rule table auto-generated at run time, the performance
of looking up keep similar to that from pervious constant talbe.

Signed-off-by: Wei Dai <wei.dai@intel.com>
---
 app/test/test_lpm.c        |       2 +-
 app/test/test_lpm_perf.c   |     268 +-
 app/test/test_lpm_routes.h | 1076861 -----------------------------------------
 3 files changed, 266 insertions(+), 1076865 deletions(-)
 delete mode 100644 app/test/test_lpm_routes.h

diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c
index b6ad2eb..0952f52 100644
--- a/app/test/test_lpm.c
+++ b/app/test/test_lpm.c
@@ -35,10 +35,10 @@
 #include <stdint.h>
 #include <stdlib.h>
 
+#include <rte_ip.h>
 #include <rte_lpm.h>
 
 #include "test.h"
-#include "test_lpm_routes.h"
 #include "test_xmmt_ops.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index 58eb415..5582ef4 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -34,14 +34,15 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
+#include <math.h>
 
 #include <rte_cycles.h>
 #include <rte_random.h>
 #include <rte_branch_prediction.h>
 #include <rte_lpm.h>
+#include <rte_ip.h>
 
 #include "test.h"
-#include "test_lpm_routes.h"
 #include "test_xmmt_ops.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -55,6 +56,265 @@
 #define BATCH_SIZE (1 << 12)
 #define BULK_SIZE 32
 
+#define MAX_RULE_NUM (1200000)
+
+struct route_rule {
+	uint32_t ip;
+	uint8_t depth;
+};
+
+struct route_rule large_route_table[MAX_RULE_NUM];
+
+static uint32_t num_route_entries;  /* NUM_ROUTE_ENTRIES */
+#define NUM_ROUTE_ENTRIES num_route_entries
+
+struct route_rule_count {
+	uint32_t total;
+	uint32_t a[RTE_LPM_MAX_DEPTH];
+	uint32_t b[RTE_LPM_MAX_DEPTH];
+	uint32_t c[RTE_LPM_MAX_DEPTH];
+	uint32_t left;
+	uint32_t abc[3*RTE_LPM_MAX_DEPTH];
+};
+
+static struct route_rule_count rule_count = {
+	.a = {
+		    0, /* depth =  1 */
+		    0, /* depth =  2 */
+		    1, /* depth =  3 */
+		    0, /* depth =  4 */
+		    2, /* depth =  5 */
+		    1, /* depth =  6 */
+		    3, /* depth =  7 */
+		  185, /* depth =  8 */
+		   26, /* depth =  9 */
+		   16, /* depth = 10 */
+		   39, /* depth = 11 */
+		  144, /* depth = 12 */
+		  233, /* depth = 13 */
+		  528, /* depth = 14 */
+		  866, /* depth = 15 */
+		 3856, /* depth = 16 */
+		 3268, /* depth = 17 */
+		 5662, /* depth = 18 */
+		17301, /* depth = 19 */
+		22226, /* depth = 20 */
+		11147, /* depth = 21 */
+		16746, /* depth = 22 */
+		17120, /* depth = 23 */
+		77578, /* depth = 24 */
+		  401, /* depth = 25 */
+		  656, /* depth = 26 */
+		 1107, /* depth = 27 */
+		 1121, /* depth = 28 */
+		 2316, /* depth = 29 */
+		  717, /* depth = 30 */
+		   10, /* depth = 31 */
+		   66  /* depth = 32 */
+	},
+	.b = {
+		    0, /* depth =  1 */
+		    0, /* depth =  2 */
+		    0, /* depth =  3 */
+		    0, /* depth =  4 */
+		    1, /* depth =  5 */
+		    1, /* depth =  6 */
+		    1, /* depth =  7 */
+		    3, /* depth =  8 */
+		    3, /* depth =  9 */
+		   30, /* depth = 10 */
+		   25, /* depth = 11 */
+		  168, /* depth = 12 */
+		  305, /* depth = 13 */
+		  569, /* depth = 14 */
+		 1129, /* depth = 15 */
+		50800, /* depth = 16 */
+		 1645, /* depth = 17 */
+		 1820, /* depth = 18 */
+		 3506, /* depth = 19 */
+		 3258, /* depth = 20 */
+		 3424, /* depth = 21 */
+		 4971, /* depth = 22 */
+		 6885, /* depth = 23 */
+		39771, /* depth = 24 */
+		  424, /* depth = 25 */
+		  170, /* depth = 26 */
+		  433, /* depth = 27 */
+		   92, /* depth = 28 */
+		  366, /* depth = 29 */
+		  377, /* depth = 30 */
+		    2, /* depth = 31 */
+		  200  /* depth = 32 */
+	},
+	.c = {
+		     0, /* depth =  1 */
+		     0, /* depth =  2 */
+		     0, /* depth =  3 */
+		     0, /* depth =  4 */
+		     0, /* depth =  5 */
+		     0, /* depth =  6 */
+		     0, /* depth =  7 */
+		    12, /* depth =  8 */
+		     8, /* depth =  9 */
+		     9, /* depth = 10 */
+		    33, /* depth = 11 */
+		    69, /* depth = 12 */
+		   237, /* depth = 13 */
+		  1007, /* depth = 14 */
+		  1717, /* depth = 15 */
+		 14663, /* depth = 16 */
+		  8070, /* depth = 17 */
+		 16185, /* depth = 18 */
+		 48261, /* depth = 19 */
+		 36870, /* depth = 20 */
+		 33960, /* depth = 21 */
+		 50638, /* depth = 22 */
+		 61422, /* depth = 23 */
+		466549, /* depth = 24 */
+		  1829, /* depth = 25 */
+		  4824, /* depth = 26 */
+		  4927, /* depth = 27 */
+		  5914, /* depth = 28 */
+		 10254, /* depth = 29 */
+		  4905, /* depth = 30 */
+		     1, /* depth = 31 */
+		   716  /* depth = 32 */
+	}
+};
+
+static void init_rule_count(void)
+{
+	uint32_t depth;
+	uint32_t count;
+
+	rule_count.left = 0;
+	count = 0;
+
+	for (depth = 1; depth <= RTE_LPM_MAX_DEPTH; depth++) {
+		count += rule_count.a[depth-1];
+		if (rule_count.a[depth-1])
+			rule_count.abc[rule_count.left++] = depth;
+	}
+
+	for (depth = 1; depth <= RTE_LPM_MAX_DEPTH; depth++) {
+		count += rule_count.b[depth-1];
+		if (rule_count.b[depth-1])
+			rule_count.abc[rule_count.left++] = 256 + depth;
+	}
+
+	for (depth = 1; depth <= RTE_LPM_MAX_DEPTH; depth++) {
+		count += rule_count.c[depth-1];
+		if (rule_count.c[depth-1])
+			rule_count.abc[rule_count.left++] = 512 + depth;
+	}
+	rule_count.total = count;
+}
+
+static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
+{
+#define IP_HEAD_MASK_A  0x00000000  /* 0xxx */
+#define IP_HEAD_MASK_B  0x80000000  /* 10xx */
+#define IP_HEAD_MASK_C  0xC0000000  /* 110x */
+#define IP_HEAD_BIT_NUM_A 1
+#define IP_HEAD_BIT_NUM_B 2
+#define IP_HEAD_BIT_NUM_C 3
+
+	uint32_t depth_1;
+	uint32_t class_depth;
+	uint32_t range;
+	uint32_t mask;
+	uint32_t step;
+	uint32_t start;
+	uint32_t fixed_bit_num;
+	uint32_t ip_head_mask;
+	uint32_t rule_num;
+	uint32_t k;
+	struct route_rule *ptr_rule;
+
+	depth_1 = depth - 1;
+
+	if (ip_class == 0) { /* IP Address class A */
+		fixed_bit_num = IP_HEAD_BIT_NUM_A;
+		ip_head_mask = IP_HEAD_MASK_A;
+		rule_num = rule_count.a[depth_1];
+	} else if (ip_class == 1) { /* IP Address class B */
+		fixed_bit_num = IP_HEAD_BIT_NUM_B;
+		ip_head_mask = IP_HEAD_MASK_B;
+		rule_num = rule_count.b[depth_1];
+	} else { /* IP Address class C */
+		fixed_bit_num = IP_HEAD_BIT_NUM_C;
+		ip_head_mask = IP_HEAD_MASK_C;
+		rule_num = rule_count.c[depth_1];
+	}
+
+	class_depth = depth - fixed_bit_num;
+	range = 1 << class_depth;
+	mask = range - 1;
+	if (range <= rule_num)
+		step = 1;
+	else
+		step = round((double)range / rule_num);
+
+	start = lrand48() & mask;
+	ptr_rule = &large_route_table[num_route_entries];
+	for (k = 0; k < rule_num; k++) {
+		ptr_rule->ip = (start << (RTE_LPM_MAX_DEPTH - depth))
+			| ip_head_mask;
+		ptr_rule->depth = depth;
+		ptr_rule++;
+		start = (start + step) & mask;
+	}
+	num_route_entries += rule_num;
+}
+
+static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
+{
+	uint32_t pos;
+	int try_count = 0;
+	struct route_rule tmp;
+
+	do {
+		pos = lrand48();
+		try_count++;
+	} while ((try_count < 10) && (pos > num_route_entries));
+
+	if ((pos > num_route_entries) || (pos >= MAX_RULE_NUM))
+		pos = num_route_entries >> 1;
+
+	tmp = large_route_table[pos];
+	large_route_table[pos].ip = ip;
+	large_route_table[pos].depth = depth;
+	if (num_route_entries < MAX_RULE_NUM)
+		large_route_table[num_route_entries++] = tmp;
+}
+
+static void generate_large_route_rule_table(void)
+{
+	uint32_t idx;
+	uint32_t ip_class;
+	uint8_t  depth;
+
+	memset(large_route_table, 0, sizeof(large_route_table));
+	init_rule_count();
+
+	idx = 0;
+	do {
+		depth = (rule_count.abc[idx] & 0xFF);
+		ip_class = rule_count.abc[idx] >> 8;
+
+		generate_random_rule_prefix(ip_class, depth);
+
+		rule_count.left--;
+		idx++;
+	} while (rule_count.left > 0);
+
+	insert_rule_in_random_pos(IPv4(0, 0, 0, 0), 8);
+	insert_rule_in_random_pos(IPv4(10, 2, 23, 147), 32);
+	insert_rule_in_random_pos(IPv4(192, 168, 100, 10), 24);
+	insert_rule_in_random_pos(IPv4(192, 168, 25, 100), 24);
+	insert_rule_in_random_pos(IPv4(192, 168, 129, 124), 32);
+}
+
 static void
 print_route_distribution(const struct route_rule *table, uint32_t n)
 {
@@ -85,8 +345,8 @@ test_lpm_perf(void)
 	struct rte_lpm *lpm = NULL;
 	struct rte_lpm_config config;
 
-	config.max_rules = 1000000;
-	config.number_tbl8s = 256;
+	config.max_rules = 2000000;
+	config.number_tbl8s = 2048;
 	config.flags = 0;
 	uint64_t begin, total_time, lpm_used_entries = 0;
 	unsigned i, j;
@@ -97,6 +357,8 @@ test_lpm_perf(void)
 
 	rte_srand(rte_rdtsc());
 
+	generate_large_route_rule_table();
+
 	printf("No. routes = %u\n", (unsigned) NUM_ROUTE_ENTRIES);
 
 	print_route_distribution(large_route_table, (uint32_t) NUM_ROUTE_ENTRIES);
diff --git a/app/test/test_lpm_routes.h b/app/test/test_lpm_routes.h
deleted file mode 100644
index 023b0f9..0000000
-- 
2.7.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH] app/test: remove large lpm test head file
  2016-09-26  9:37 [dpdk-dev] [PATCH] app/test: remove large lpm test head file Wei Dai
@ 2016-09-26  9:56 ` Thomas Monjalon
  2016-09-26 13:07   ` Dai, Wei
  2016-09-26 10:06 ` Bruce Richardson
  2016-09-27 17:38 ` [dpdk-dev] [PATCH v2] " Wei Dai
  2 siblings, 1 reply; 9+ messages in thread
From: Thomas Monjalon @ 2016-09-26  9:56 UTC (permalink / raw)
  To: Wei Dai; +Cc: dev, bruce.richardson

2016-09-26 17:37, Wei Dai:
> remove the large file app/test/test_lpm_routes.h and add codes to
> auto-generate similar large route rule talbe which keeps same depth
> and IP class distribution as previous one in test_lpm_routes.h .
> With the rule table auto-generated at run time, the performance
> of looking up keep similar to that from pervious constant talbe.
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>
> ---
>  app/test/test_lpm.c        |       2 +-
>  app/test/test_lpm_perf.c   |     268 +-
>  app/test/test_lpm_routes.h | 1076861 -----------------------------------------
>  3 files changed, 266 insertions(+), 1076865 deletions(-)
>  delete mode 100644 app/test/test_lpm_routes.h

Whaouh! Good news :)
This file is 21 MB. It should help to reduce the size of a tarball.
Are you working also on the IPv6 flavour? (7 MB to save)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH] app/test: remove large lpm test head file
  2016-09-26  9:37 [dpdk-dev] [PATCH] app/test: remove large lpm test head file Wei Dai
  2016-09-26  9:56 ` Thomas Monjalon
@ 2016-09-26 10:06 ` Bruce Richardson
  2016-09-26 13:49   ` Dai, Wei
  2016-09-27 17:38 ` [dpdk-dev] [PATCH v2] " Wei Dai
  2 siblings, 1 reply; 9+ messages in thread
From: Bruce Richardson @ 2016-09-26 10:06 UTC (permalink / raw)
  To: Wei Dai; +Cc: dev

On Mon, Sep 26, 2016 at 05:37:05PM +0800, Wei Dai wrote:
> remove the large file app/test/test_lpm_routes.h and add codes to
> auto-generate similar large route rule talbe which keeps same depth
> and IP class distribution as previous one in test_lpm_routes.h .
> With the rule table auto-generated at run time, the performance
> of looking up keep similar to that from pervious constant talbe.
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>
> ---
>  app/test/test_lpm.c        |       2 +-
>  app/test/test_lpm_perf.c   |     268 +-
>  app/test/test_lpm_routes.h | 1076861 -----------------------------------------
>  3 files changed, 266 insertions(+), 1076865 deletions(-)
>  delete mode 100644 app/test/test_lpm_routes.h
> 
> diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c
> index b6ad2eb..0952f52 100644
> --- a/app/test/test_lpm.c
> +++ b/app/test/test_lpm.c
> @@ -35,10 +35,10 @@
>  #include <stdint.h>
>  #include <stdlib.h>
>  
> +#include <rte_ip.h>
>  #include <rte_lpm.h>
>  
>  #include "test.h"
> -#include "test_lpm_routes.h"
>  #include "test_xmmt_ops.h"
>  
>  #define TEST_LPM_ASSERT(cond) do {                                            \
> diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
> index 58eb415..5582ef4 100644
> --- a/app/test/test_lpm_perf.c
> +++ b/app/test/test_lpm_perf.c
> @@ -34,14 +34,15 @@
>  #include <stdio.h>
>  #include <stdint.h>
>  #include <stdlib.h>
> +#include <math.h>
>  
>  #include <rte_cycles.h>
>  #include <rte_random.h>
>  #include <rte_branch_prediction.h>
>  #include <rte_lpm.h>
> +#include <rte_ip.h>
>  
>  #include "test.h"
> -#include "test_lpm_routes.h"
>  #include "test_xmmt_ops.h"
>  
>  #define TEST_LPM_ASSERT(cond) do {                                            \
> @@ -55,6 +56,265 @@
>  #define BATCH_SIZE (1 << 12)
>  #define BULK_SIZE 32
>  
> +#define MAX_RULE_NUM (1200000)
> +
> +struct route_rule {
> +	uint32_t ip;
> +	uint8_t depth;
> +};
> +
> +struct route_rule large_route_table[MAX_RULE_NUM];
> +
> +static uint32_t num_route_entries;  /* NUM_ROUTE_ENTRIES */
> +#define NUM_ROUTE_ENTRIES num_route_entries
> +
> +struct route_rule_count {
> +	uint32_t total;
> +	uint32_t a[RTE_LPM_MAX_DEPTH];
> +	uint32_t b[RTE_LPM_MAX_DEPTH];
> +	uint32_t c[RTE_LPM_MAX_DEPTH];
> +	uint32_t left;
> +	uint32_t abc[3*RTE_LPM_MAX_DEPTH];

Can you provide some comments explaining how you are generating the rules
to test with. For example, explain why have you split the sets of rules
into three, a, b, and c, and how you use each of those three sets. Perhaps
also provide a comment alongside each member of the structure above.

<snip>
> +static void init_rule_count(void)
> +{
> +	uint32_t depth;
> +	uint32_t count;
> +
> +	rule_count.left = 0;
> +	count = 0;
> +
> +	for (depth = 1; depth <= RTE_LPM_MAX_DEPTH; depth++) {
> +		count += rule_count.a[depth-1];
> +		if (rule_count.a[depth-1])
> +			rule_count.abc[rule_count.left++] = depth;
> +	}
> +
> +	for (depth = 1; depth <= RTE_LPM_MAX_DEPTH; depth++) {
> +		count += rule_count.b[depth-1];
> +		if (rule_count.b[depth-1])
> +			rule_count.abc[rule_count.left++] = 256 + depth;
> +	}
> +
> +	for (depth = 1; depth <= RTE_LPM_MAX_DEPTH; depth++) {
> +		count += rule_count.c[depth-1];
> +		if (rule_count.c[depth-1])
> +			rule_count.abc[rule_count.left++] = 512 + depth;
> +	}
> +	rule_count.total = count;
> +}

Again, this needs a comment explaining what this function is doing, and
how/why it is doing so.

> +
> +static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
> +{
> +#define IP_HEAD_MASK_A  0x00000000  /* 0xxx */
> +#define IP_HEAD_MASK_B  0x80000000  /* 10xx */
> +#define IP_HEAD_MASK_C  0xC0000000  /* 110x */
> +#define IP_HEAD_BIT_NUM_A 1
> +#define IP_HEAD_BIT_NUM_B 2
> +#define IP_HEAD_BIT_NUM_C 3
> +
> +	uint32_t depth_1;
> +	uint32_t class_depth;
> +	uint32_t range;
> +	uint32_t mask;
> +	uint32_t step;
> +	uint32_t start;
> +	uint32_t fixed_bit_num;
> +	uint32_t ip_head_mask;
> +	uint32_t rule_num;
> +	uint32_t k;
> +	struct route_rule *ptr_rule;
> +
> +	depth_1 = depth - 1;
> +
> +	if (ip_class == 0) { /* IP Address class A */
> +		fixed_bit_num = IP_HEAD_BIT_NUM_A;
> +		ip_head_mask = IP_HEAD_MASK_A;
> +		rule_num = rule_count.a[depth_1];
> +	} else if (ip_class == 1) { /* IP Address class B */
> +		fixed_bit_num = IP_HEAD_BIT_NUM_B;
> +		ip_head_mask = IP_HEAD_MASK_B;
> +		rule_num = rule_count.b[depth_1];
> +	} else { /* IP Address class C */
> +		fixed_bit_num = IP_HEAD_BIT_NUM_C;
> +		ip_head_mask = IP_HEAD_MASK_C;
> +		rule_num = rule_count.c[depth_1];
> +	}
> +
> +	class_depth = depth - fixed_bit_num;
> +	range = 1 << class_depth;
> +	mask = range - 1;
> +	if (range <= rule_num)
> +		step = 1;
> +	else
> +		step = round((double)range / rule_num);
> +
> +	start = lrand48() & mask;
> +	ptr_rule = &large_route_table[num_route_entries];
> +	for (k = 0; k < rule_num; k++) {
> +		ptr_rule->ip = (start << (RTE_LPM_MAX_DEPTH - depth))
> +			| ip_head_mask;
> +		ptr_rule->depth = depth;
> +		ptr_rule++;
> +		start = (start + step) & mask;
> +	}
> +	num_route_entries += rule_num;
> +}

Again, comment explaining function, please.

> +
> +static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
> +{
> +	uint32_t pos;
> +	int try_count = 0;
> +	struct route_rule tmp;
> +
> +	do {
> +		pos = lrand48();
> +		try_count++;
> +	} while ((try_count < 10) && (pos > num_route_entries));
> +
> +	if ((pos > num_route_entries) || (pos >= MAX_RULE_NUM))
> +		pos = num_route_entries >> 1;
> +
> +	tmp = large_route_table[pos];
> +	large_route_table[pos].ip = ip;
> +	large_route_table[pos].depth = depth;
> +	if (num_route_entries < MAX_RULE_NUM)
> +		large_route_table[num_route_entries++] = tmp;
> +}
> +
> +static void generate_large_route_rule_table(void)
> +{
> +	uint32_t idx;
> +	uint32_t ip_class;
> +	uint8_t  depth;
> +
> +	memset(large_route_table, 0, sizeof(large_route_table));
> +	init_rule_count();
> +
> +	idx = 0;
> +	do {
> +		depth = (rule_count.abc[idx] & 0xFF);
> +		ip_class = rule_count.abc[idx] >> 8;
> +
> +		generate_random_rule_prefix(ip_class, depth);
> +
> +		rule_count.left--;
> +		idx++;
> +	} while (rule_count.left > 0);
> +
> +	insert_rule_in_random_pos(IPv4(0, 0, 0, 0), 8);
> +	insert_rule_in_random_pos(IPv4(10, 2, 23, 147), 32);
> +	insert_rule_in_random_pos(IPv4(192, 168, 100, 10), 24);
> +	insert_rule_in_random_pos(IPv4(192, 168, 25, 100), 24);
> +	insert_rule_in_random_pos(IPv4(192, 168, 129, 124), 32);

Why are you inserting 5 rules at random positions at the end? Explanatory
comment needed, thanks.


When running the code with the new auto-generated table, the rule add time
is 5x longer than that with the original test. Have you investigated what
causes this, and is there something that can be done to work around it?

Regards,
/Bruce

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH] app/test: remove large lpm test head file
  2016-09-26  9:56 ` Thomas Monjalon
@ 2016-09-26 13:07   ` Dai, Wei
  0 siblings, 0 replies; 9+ messages in thread
From: Dai, Wei @ 2016-09-26 13:07 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Richardson, Bruce

> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Monday, September 26, 2016 5:56 PM
> To: Dai, Wei <wei.dai@intel.com>
> Cc: dev@dpdk.org; Richardson, Bruce <bruce.richardson@intel.com>
> Subject: Re: [dpdk-dev] [PATCH] app/test: remove large lpm test head file
> 
> 2016-09-26 17:37, Wei Dai:
> > remove the large file app/test/test_lpm_routes.h and add codes to
> > auto-generate similar large route rule talbe which keeps same depth
> > and IP class distribution as previous one in test_lpm_routes.h .
> > With the rule table auto-generated at run time, the performance of
> > looking up keep similar to that from pervious constant talbe.
> >
> > Signed-off-by: Wei Dai <wei.dai@intel.com>
> > ---
> >  app/test/test_lpm.c        |       2 +-
> >  app/test/test_lpm_perf.c   |     268 +-
> >  app/test/test_lpm_routes.h | 1076861
> > -----------------------------------------
> >  3 files changed, 266 insertions(+), 1076865 deletions(-)  delete mode
> > 100644 app/test/test_lpm_routes.h
> 
> Whaouh! Good news :)
> This file is 21 MB. It should help to reduce the size of a tarball.
> Are you working also on the IPv6 flavour? (7 MB to save)

Yes, I am designing an algorithm to auto-generate LPM IPv6 test route rule and test input data.

As the number of next table to be checked during a looking-up varies much more and depends on
the pre-injected rule sets, to keep the similar performance for looking-up is more difficult than IPv4.

Regards
/Wei 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH] app/test: remove large lpm test head file
  2016-09-26 10:06 ` Bruce Richardson
@ 2016-09-26 13:49   ` Dai, Wei
  0 siblings, 0 replies; 9+ messages in thread
From: Dai, Wei @ 2016-09-26 13:49 UTC (permalink / raw)
  To: Richardson, Bruce; +Cc: dev

Hi, Bruce

How about your test result for this patch ?
Especially on performance of rule looking-up ?
There are also some replies for your comments as below.

Thanks
/ Wei 

> -----Original Message-----
> From: Richardson, Bruce
> Sent: Monday, September 26, 2016 6:07 PM
> To: Dai, Wei <wei.dai@intel.com>
> Cc: dev@dpdk.org
> Subject: Re: [PATCH] app/test: remove large lpm test head file
> 
> On Mon, Sep 26, 2016 at 05:37:05PM +0800, Wei Dai wrote:
> > remove the large file app/test/test_lpm_routes.h and add codes to
> > auto-generate similar large route rule talbe which keeps same depth
> > and IP class distribution as previous one in test_lpm_routes.h .
> > With the rule table auto-generated at run time, the performance of
> > looking up keep similar to that from pervious constant talbe.
> >
> > Signed-off-by: Wei Dai <wei.dai@intel.com>
> > ---
> >  app/test/test_lpm.c        |       2 +-
> >  app/test/test_lpm_perf.c   |     268 +-
> >  app/test/test_lpm_routes.h | 1076861
> > -----------------------------------------
> >  3 files changed, 266 insertions(+), 1076865 deletions(-)  delete mode
> > 100644 app/test/test_lpm_routes.h
> >
> > diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c index
> > b6ad2eb..0952f52 100644
> > --- a/app/test/test_lpm.c
> > +++ b/app/test/test_lpm.c
> > @@ -35,10 +35,10 @@
> >  #include <stdint.h>
> >  #include <stdlib.h>
> >
> > +#include <rte_ip.h>
> >  #include <rte_lpm.h>
> >
> >  #include "test.h"
> > -#include "test_lpm_routes.h"
> >  #include "test_xmmt_ops.h"
> >
> >  #define TEST_LPM_ASSERT(cond) do
> {                                            \
> > diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c index
> > 58eb415..5582ef4 100644
> > --- a/app/test/test_lpm_perf.c
> > +++ b/app/test/test_lpm_perf.c
> > @@ -34,14 +34,15 @@
> >  #include <stdio.h>
> >  #include <stdint.h>
> >  #include <stdlib.h>
> > +#include <math.h>
> >
> >  #include <rte_cycles.h>
> >  #include <rte_random.h>
> >  #include <rte_branch_prediction.h>
> >  #include <rte_lpm.h>
> > +#include <rte_ip.h>
> >
> >  #include "test.h"
> > -#include "test_lpm_routes.h"
> >  #include "test_xmmt_ops.h"
> >
> >  #define TEST_LPM_ASSERT(cond) do
> {                                            \
> > @@ -55,6 +56,265 @@
> >  #define BATCH_SIZE (1 << 12)
> >  #define BULK_SIZE 32
> >
> > +#define MAX_RULE_NUM (1200000)
> > +
> > +struct route_rule {
> > +	uint32_t ip;
> > +	uint8_t depth;
> > +};
> > +
> > +struct route_rule large_route_table[MAX_RULE_NUM];
> > +
> > +static uint32_t num_route_entries;  /* NUM_ROUTE_ENTRIES */ #define
> > +NUM_ROUTE_ENTRIES num_route_entries
> > +
> > +struct route_rule_count {
> > +	uint32_t total;
> > +	uint32_t a[RTE_LPM_MAX_DEPTH];
> > +	uint32_t b[RTE_LPM_MAX_DEPTH];
> > +	uint32_t c[RTE_LPM_MAX_DEPTH];
> > +	uint32_t left;
> > +	uint32_t abc[3*RTE_LPM_MAX_DEPTH];
> 
> Can you provide some comments explaining how you are generating the rules
> to test with. For example, explain why have you split the sets of rules into three,
> a, b, and c, and how you use each of those three sets. Perhaps also provide a
> comment alongside each member of the structure above.

a/b/c means IP address class. These class doesn't count IP address for local network.
Because the previous large route rule table was just dumped from a real router and
as to match similar performance, I design to keep similar depth and IP address coverage 
as previous constant table. All the numbers of each depth of each IP class are just
got from previous constant table. 

> 
> <snip>
> > +static void init_rule_count(void)
> > +{
> > +	uint32_t depth;
> > +	uint32_t count;
> > +
> > +	rule_count.left = 0;
> > +	count = 0;
> > +
> > +	for (depth = 1; depth <= RTE_LPM_MAX_DEPTH; depth++) {
> > +		count += rule_count.a[depth-1];
> > +		if (rule_count.a[depth-1])
> > +			rule_count.abc[rule_count.left++] = depth;
> > +	}
> > +
> > +	for (depth = 1; depth <= RTE_LPM_MAX_DEPTH; depth++) {
> > +		count += rule_count.b[depth-1];
> > +		if (rule_count.b[depth-1])
> > +			rule_count.abc[rule_count.left++] = 256 + depth;
> > +	}
> > +
> > +	for (depth = 1; depth <= RTE_LPM_MAX_DEPTH; depth++) {
> > +		count += rule_count.c[depth-1];
> > +		if (rule_count.c[depth-1])
> > +			rule_count.abc[rule_count.left++] = 512 + depth;
> > +	}
> > +	rule_count.total = count;
> > +}
> 
> Again, this needs a comment explaining what this function is doing, and
> how/why it is doing so.
I will give more comments to explain it in v2 patch.
By the way, rule_count.abc[ ] is for quicker generation of rules.

> 
> > +
> > +static void generate_random_rule_prefix(uint32_t ip_class, uint8_t
> > +depth) { #define IP_HEAD_MASK_A  0x00000000  /* 0xxx */ #define
> > +IP_HEAD_MASK_B  0x80000000  /* 10xx */ #define IP_HEAD_MASK_C
> > +0xC0000000  /* 110x */ #define IP_HEAD_BIT_NUM_A 1 #define
> > +IP_HEAD_BIT_NUM_B 2 #define IP_HEAD_BIT_NUM_C 3
> > +
> > +	uint32_t depth_1;
> > +	uint32_t class_depth;
> > +	uint32_t range;
> > +	uint32_t mask;
> > +	uint32_t step;
> > +	uint32_t start;
> > +	uint32_t fixed_bit_num;
> > +	uint32_t ip_head_mask;
> > +	uint32_t rule_num;
> > +	uint32_t k;
> > +	struct route_rule *ptr_rule;
> > +
> > +	depth_1 = depth - 1;
> > +
> > +	if (ip_class == 0) { /* IP Address class A */
> > +		fixed_bit_num = IP_HEAD_BIT_NUM_A;
> > +		ip_head_mask = IP_HEAD_MASK_A;
> > +		rule_num = rule_count.a[depth_1];
> > +	} else if (ip_class == 1) { /* IP Address class B */
> > +		fixed_bit_num = IP_HEAD_BIT_NUM_B;
> > +		ip_head_mask = IP_HEAD_MASK_B;
> > +		rule_num = rule_count.b[depth_1];
> > +	} else { /* IP Address class C */
> > +		fixed_bit_num = IP_HEAD_BIT_NUM_C;
> > +		ip_head_mask = IP_HEAD_MASK_C;
> > +		rule_num = rule_count.c[depth_1];
> > +	}
> > +
> > +	class_depth = depth - fixed_bit_num;
> > +	range = 1 << class_depth;
> > +	mask = range - 1;
> > +	if (range <= rule_num)
> > +		step = 1;
> > +	else
> > +		step = round((double)range / rule_num);
> > +
> > +	start = lrand48() & mask;
> > +	ptr_rule = &large_route_table[num_route_entries];
> > +	for (k = 0; k < rule_num; k++) {
> > +		ptr_rule->ip = (start << (RTE_LPM_MAX_DEPTH - depth))
> > +			| ip_head_mask;
> > +		ptr_rule->depth = depth;
> > +		ptr_rule++;
> > +		start = (start + step) & mask;
> > +	}
> > +	num_route_entries += rule_num;
> > +}
> 
> Again, comment explaining function, please.
V2 patch will give more annotations.
> 
> > +
> > +static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth) {
> > +	uint32_t pos;
> > +	int try_count = 0;
> > +	struct route_rule tmp;
> > +
> > +	do {
> > +		pos = lrand48();
> > +		try_count++;
> > +	} while ((try_count < 10) && (pos > num_route_entries));
> > +
> > +	if ((pos > num_route_entries) || (pos >= MAX_RULE_NUM))
> > +		pos = num_route_entries >> 1;
> > +
> > +	tmp = large_route_table[pos];
> > +	large_route_table[pos].ip = ip;
> > +	large_route_table[pos].depth = depth;
> > +	if (num_route_entries < MAX_RULE_NUM)
> > +		large_route_table[num_route_entries++] = tmp; }
> > +
> > +static void generate_large_route_rule_table(void)
> > +{
> > +	uint32_t idx;
> > +	uint32_t ip_class;
> > +	uint8_t  depth;
> > +
> > +	memset(large_route_table, 0, sizeof(large_route_table));
> > +	init_rule_count();
> > +
> > +	idx = 0;
> > +	do {
> > +		depth = (rule_count.abc[idx] & 0xFF);
> > +		ip_class = rule_count.abc[idx] >> 8;
> > +
> > +		generate_random_rule_prefix(ip_class, depth);
> > +
> > +		rule_count.left--;
> > +		idx++;
> > +	} while (rule_count.left > 0);
> > +
> > +	insert_rule_in_random_pos(IPv4(0, 0, 0, 0), 8);
> > +	insert_rule_in_random_pos(IPv4(10, 2, 23, 147), 32);
> > +	insert_rule_in_random_pos(IPv4(192, 168, 100, 10), 24);
> > +	insert_rule_in_random_pos(IPv4(192, 168, 25, 100), 24);
> > +	insert_rule_in_random_pos(IPv4(192, 168, 129, 124), 32);
> 
> Why are you inserting 5 rules at random positions at the end? Explanatory
> comment needed, thanks.
This just keeps the same local IP address class and depth as previous constant table.
Place these local IP address in random position in the rule set rather than the end of it
or adjacent 5 lines.

> 
> 
> When running the code with the new auto-generated table, the rule add time is
> 5x longer than that with the original test. Have you investigated what causes
> this, and is there something that can be done to work around it?

I have designed a debug platform to trace each loop and each branch passed through during rule adding,
In previous constant large rule table, there are many (about ~78%) reappearance of same prefix 
(same IP prefix + same depth). But auto-generated rule table has much lower reappearance. 
This much affect compute quantity in rule adding.
To work around it, I assume that we may update the algorithm to keep same reappearance rate in each depth
and each IP address class. 
It will be much more complicated one and need much more efforts to tune it.
As the performance of looking-up from current auto-generated rule sets is similar as previous one, 
I have not gone on to pursuit much better performance of rule adding/deleting.

> 
> Regards,
> /Bruce

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH v2] app/test: remove large lpm test head file
  2016-09-26  9:37 [dpdk-dev] [PATCH] app/test: remove large lpm test head file Wei Dai
  2016-09-26  9:56 ` Thomas Monjalon
  2016-09-26 10:06 ` Bruce Richardson
@ 2016-09-27 17:38 ` Wei Dai
  2016-09-28  8:41   ` Bruce Richardson
  2016-10-13 13:28   ` Thomas Monjalon
  2 siblings, 2 replies; 9+ messages in thread
From: Wei Dai @ 2016-09-27 17:38 UTC (permalink / raw)
  To: dev, bruce.richardson, wei.dai

remove the large file app/test/test_lpm_routes.h and add codes to
auto-generate similar large route rule talbe which keeps same depth
and IP class distribution as previous one in test_lpm_routes.h .
With the rule table auto-generated at run time, the performance
of looking up keep similar to that from pervious constant talbe.

Signed-off-by: Wei Dai <wei.dai@intel.com>
---
 app/test/test_lpm.c        |       2 +-
 app/test/test_lpm_perf.c   |     273 +-
 app/test/test_lpm_routes.h | 1076861 -----------------------------------------
 3 files changed, 271 insertions(+), 1076865 deletions(-)
 delete mode 100644 app/test/test_lpm_routes.h

diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c
index b6ad2eb..0952f52 100644
--- a/app/test/test_lpm.c
+++ b/app/test/test_lpm.c
@@ -35,10 +35,10 @@
 #include <stdint.h>
 #include <stdlib.h>
 
+#include <rte_ip.h>
 #include <rte_lpm.h>
 
 #include "test.h"
-#include "test_lpm_routes.h"
 #include "test_xmmt_ops.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index 58eb415..2912df9 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -34,14 +34,15 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
+#include <math.h>
 
 #include <rte_cycles.h>
 #include <rte_random.h>
 #include <rte_branch_prediction.h>
+#include <rte_ip.h>
 #include <rte_lpm.h>
 
 #include "test.h"
-#include "test_lpm_routes.h"
 #include "test_xmmt_ops.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -55,6 +56,270 @@
 #define BATCH_SIZE (1 << 12)
 #define BULK_SIZE 32
 
+#define MAX_RULE_NUM (1200000)
+
+struct route_rule {
+	uint32_t ip;
+	uint8_t depth;
+};
+
+struct route_rule large_route_table[MAX_RULE_NUM];
+
+static uint32_t num_route_entries;
+#define NUM_ROUTE_ENTRIES num_route_entries
+
+enum {
+	IP_CLASS_A,
+	IP_CLASS_B,
+	IP_CLASS_C
+};
+
+/* struct route_rule_count defines the total number of rules in following a/b/c
+ * each item in a[]/b[]/c[] is the number of common IP address class A/B/C, not
+ * including the ones for private local network.
+ */
+struct route_rule_count {
+	uint32_t a[RTE_LPM_MAX_DEPTH];
+	uint32_t b[RTE_LPM_MAX_DEPTH];
+	uint32_t c[RTE_LPM_MAX_DEPTH];
+};
+
+/* All following numbers of each depth of each common IP class are just
+ * got from previous large constant table in app/test/test_lpm_routes.h .
+ * In order to match simliar performance, they keep same depth and IP
+ * address coverage as previous constant table. These numbers don't
+ * include any private local IP address. As previous large const rule
+ * table was just dumped from a real router, there are no any IP address
+ * in class C or D.
+ */
+static struct route_rule_count rule_count = {
+	.a = { /* IP class A in which the most significant bit is 0 */
+		    0, /* depth =  1 */
+		    0, /* depth =  2 */
+		    1, /* depth =  3 */
+		    0, /* depth =  4 */
+		    2, /* depth =  5 */
+		    1, /* depth =  6 */
+		    3, /* depth =  7 */
+		  185, /* depth =  8 */
+		   26, /* depth =  9 */
+		   16, /* depth = 10 */
+		   39, /* depth = 11 */
+		  144, /* depth = 12 */
+		  233, /* depth = 13 */
+		  528, /* depth = 14 */
+		  866, /* depth = 15 */
+		 3856, /* depth = 16 */
+		 3268, /* depth = 17 */
+		 5662, /* depth = 18 */
+		17301, /* depth = 19 */
+		22226, /* depth = 20 */
+		11147, /* depth = 21 */
+		16746, /* depth = 22 */
+		17120, /* depth = 23 */
+		77578, /* depth = 24 */
+		  401, /* depth = 25 */
+		  656, /* depth = 26 */
+		 1107, /* depth = 27 */
+		 1121, /* depth = 28 */
+		 2316, /* depth = 29 */
+		  717, /* depth = 30 */
+		   10, /* depth = 31 */
+		   66  /* depth = 32 */
+	},
+	.b = { /* IP class A in which the most 2 significant bits are 10 */
+		    0, /* depth =  1 */
+		    0, /* depth =  2 */
+		    0, /* depth =  3 */
+		    0, /* depth =  4 */
+		    1, /* depth =  5 */
+		    1, /* depth =  6 */
+		    1, /* depth =  7 */
+		    3, /* depth =  8 */
+		    3, /* depth =  9 */
+		   30, /* depth = 10 */
+		   25, /* depth = 11 */
+		  168, /* depth = 12 */
+		  305, /* depth = 13 */
+		  569, /* depth = 14 */
+		 1129, /* depth = 15 */
+		50800, /* depth = 16 */
+		 1645, /* depth = 17 */
+		 1820, /* depth = 18 */
+		 3506, /* depth = 19 */
+		 3258, /* depth = 20 */
+		 3424, /* depth = 21 */
+		 4971, /* depth = 22 */
+		 6885, /* depth = 23 */
+		39771, /* depth = 24 */
+		  424, /* depth = 25 */
+		  170, /* depth = 26 */
+		  433, /* depth = 27 */
+		   92, /* depth = 28 */
+		  366, /* depth = 29 */
+		  377, /* depth = 30 */
+		    2, /* depth = 31 */
+		  200  /* depth = 32 */
+	},
+	.c = { /* IP class A in which the most 3 significant bits are 110 */
+		     0, /* depth =  1 */
+		     0, /* depth =  2 */
+		     0, /* depth =  3 */
+		     0, /* depth =  4 */
+		     0, /* depth =  5 */
+		     0, /* depth =  6 */
+		     0, /* depth =  7 */
+		    12, /* depth =  8 */
+		     8, /* depth =  9 */
+		     9, /* depth = 10 */
+		    33, /* depth = 11 */
+		    69, /* depth = 12 */
+		   237, /* depth = 13 */
+		  1007, /* depth = 14 */
+		  1717, /* depth = 15 */
+		 14663, /* depth = 16 */
+		  8070, /* depth = 17 */
+		 16185, /* depth = 18 */
+		 48261, /* depth = 19 */
+		 36870, /* depth = 20 */
+		 33960, /* depth = 21 */
+		 50638, /* depth = 22 */
+		 61422, /* depth = 23 */
+		466549, /* depth = 24 */
+		  1829, /* depth = 25 */
+		  4824, /* depth = 26 */
+		  4927, /* depth = 27 */
+		  5914, /* depth = 28 */
+		 10254, /* depth = 29 */
+		  4905, /* depth = 30 */
+		     1, /* depth = 31 */
+		   716  /* depth = 32 */
+	}
+};
+
+static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
+{
+/* IP address class A, the most significant bit is 0 */
+#define IP_HEAD_MASK_A			0x00000000
+#define IP_HEAD_BIT_NUM_A		1
+
+/* IP address class B, the most significant 2 bits are 10 */
+#define IP_HEAD_MASK_B			0x80000000
+#define IP_HEAD_BIT_NUM_B		2
+
+/* IP address class C, the most significant 3 bits are 110 */
+#define IP_HEAD_MASK_C			0xC0000000
+#define IP_HEAD_BIT_NUM_C		3
+
+	uint32_t class_depth;
+	uint32_t range;
+	uint32_t mask;
+	uint32_t step;
+	uint32_t start;
+	uint32_t fixed_bit_num;
+	uint32_t ip_head_mask;
+	uint32_t rule_num;
+	uint32_t k;
+	struct route_rule *ptr_rule;
+
+	if (ip_class == IP_CLASS_A) {        /* IP Address class A */
+		fixed_bit_num = IP_HEAD_BIT_NUM_A;
+		ip_head_mask = IP_HEAD_MASK_A;
+		rule_num = rule_count.a[depth - 1];
+	} else if (ip_class == IP_CLASS_B) { /* IP Address class B */
+		fixed_bit_num = IP_HEAD_BIT_NUM_B;
+		ip_head_mask = IP_HEAD_MASK_B;
+		rule_num = rule_count.b[depth - 1];
+	} else {                             /* IP Address class C */
+		fixed_bit_num = IP_HEAD_BIT_NUM_C;
+		ip_head_mask = IP_HEAD_MASK_C;
+		rule_num = rule_count.c[depth - 1];
+	}
+
+	if (rule_num == 0)
+		return;
+
+	/* the number of rest bits which don't include the most significant
+	 * fixed bits for this IP address class
+	 */
+	class_depth = depth - fixed_bit_num;
+
+	/* range is the maximum number of rules for this depth and
+	 * this IP address class
+	 */
+	range = 1 << class_depth;
+
+	/* only mask the most depth significant generated bits
+	 * except fixed bits for IP address class
+	 */
+	mask = range - 1;
+
+	/* Widen coverage of IP address in generated rules */
+	if (range <= rule_num)
+		step = 1;
+	else
+		step = round((double)range / rule_num);
+
+	/* Only generate rest bits except the most significant
+	 * fixed bits for IP address class
+	 */
+	start = lrand48() & mask;
+	ptr_rule = &large_route_table[num_route_entries];
+	for (k = 0; k < rule_num; k++) {
+		ptr_rule->ip = (start << (RTE_LPM_MAX_DEPTH - depth))
+			| ip_head_mask;
+		ptr_rule->depth = depth;
+		ptr_rule++;
+		start = (start + step) & mask;
+	}
+	num_route_entries += rule_num;
+}
+
+static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
+{
+	uint32_t pos;
+	int try_count = 0;
+	struct route_rule tmp;
+
+	do {
+		pos = lrand48();
+		try_count++;
+	} while ((try_count < 10) && (pos > num_route_entries));
+
+	if ((pos > num_route_entries) || (pos >= MAX_RULE_NUM))
+		pos = num_route_entries >> 1;
+
+	tmp = large_route_table[pos];
+	large_route_table[pos].ip = ip;
+	large_route_table[pos].depth = depth;
+	if (num_route_entries < MAX_RULE_NUM)
+		large_route_table[num_route_entries++] = tmp;
+}
+
+static void generate_large_route_rule_table(void)
+{
+	uint32_t ip_class;
+	uint8_t  depth;
+
+	memset(large_route_table, 0, sizeof(large_route_table));
+
+	for (ip_class = IP_CLASS_A; ip_class <= IP_CLASS_C; ip_class++) {
+		for (depth = 1; depth <= RTE_LPM_MAX_DEPTH; depth++) {
+			generate_random_rule_prefix(ip_class, depth);
+		}
+	}
+
+	/* Add following rules to keep same as previous large constant table,
+	 * they are 4 rules with private local IP address and 1 all-zeros prefix
+	 * with depth = 8.
+	 */
+	insert_rule_in_random_pos(IPv4(0, 0, 0, 0), 8);
+	insert_rule_in_random_pos(IPv4(10, 2, 23, 147), 32);
+	insert_rule_in_random_pos(IPv4(192, 168, 100, 10), 24);
+	insert_rule_in_random_pos(IPv4(192, 168, 25, 100), 24);
+	insert_rule_in_random_pos(IPv4(192, 168, 129, 124), 32);
+}
+
 static void
 print_route_distribution(const struct route_rule *table, uint32_t n)
 {
@@ -85,8 +350,8 @@ test_lpm_perf(void)
 	struct rte_lpm *lpm = NULL;
 	struct rte_lpm_config config;
 
-	config.max_rules = 1000000;
-	config.number_tbl8s = 256;
+	config.max_rules = 2000000;
+	config.number_tbl8s = 2048;
 	config.flags = 0;
 	uint64_t begin, total_time, lpm_used_entries = 0;
 	unsigned i, j;
@@ -97,6 +362,8 @@ test_lpm_perf(void)
 
 	rte_srand(rte_rdtsc());
 
+	generate_large_route_rule_table();
+
 	printf("No. routes = %u\n", (unsigned) NUM_ROUTE_ENTRIES);
 
 	print_route_distribution(large_route_table, (uint32_t) NUM_ROUTE_ENTRIES);
diff --git a/app/test/test_lpm_routes.h b/app/test/test_lpm_routes.h
deleted file mode 100644
index 023b0f9..0000000
-- 
2.7.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH v2] app/test: remove large lpm test head file
  2016-09-27 17:38 ` [dpdk-dev] [PATCH v2] " Wei Dai
@ 2016-09-28  8:41   ` Bruce Richardson
  2016-09-28 15:19     ` Dai, Wei
  2016-10-13 13:28   ` Thomas Monjalon
  1 sibling, 1 reply; 9+ messages in thread
From: Bruce Richardson @ 2016-09-28  8:41 UTC (permalink / raw)
  To: Wei Dai; +Cc: dev

On Wed, Sep 28, 2016 at 01:38:27AM +0800, Wei Dai wrote:
> remove the large file app/test/test_lpm_routes.h and add codes to
> auto-generate similar large route rule talbe which keeps same depth
> and IP class distribution as previous one in test_lpm_routes.h .
> With the rule table auto-generated at run time, the performance
> of looking up keep similar to that from pervious constant talbe.
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>
> ---

Can you perhaps indicate what has changed between v1 and v2, it helps those of
us looking to review the patch. [The best way to do so is to place details of
diffs in each version underneath the cut line "---".]

Regards,
/Bruce

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH v2] app/test: remove large lpm test head file
  2016-09-28  8:41   ` Bruce Richardson
@ 2016-09-28 15:19     ` Dai, Wei
  0 siblings, 0 replies; 9+ messages in thread
From: Dai, Wei @ 2016-09-28 15:19 UTC (permalink / raw)
  To: Richardson, Bruce; +Cc: dev

> -----Original Message-----
> From: Richardson, Bruce
> Sent: Wednesday, September 28, 2016 4:42 PM
> To: Dai, Wei <wei.dai@intel.com>
> Cc: dev@dpdk.org
> Subject: Re: [PATCH v2] app/test: remove large lpm test head file
> 
> On Wed, Sep 28, 2016 at 01:38:27AM +0800, Wei Dai wrote:
> > remove the large file app/test/test_lpm_routes.h and add codes to
> > auto-generate similar large route rule talbe which keeps same depth
> > and IP class distribution as previous one in test_lpm_routes.h .
> > With the rule table auto-generated at run time, the performance of
> > looking up keep similar to that from pervious constant talbe.
> >
> > Signed-off-by: Wei Dai <wei.dai@intel.com>
> > ---
> 
> Can you perhaps indicate what has changed between v1 and v2, it helps those
> of us looking to review the patch. [The best way to do so is to place details of
> diffs in each version underneath the cut line "---".]

---
Changes between v2 and v1 include:
1. add more annotations to explain why and how the data structures and algorithm
  are designed.
2. simplify the implementation of same algorithm by removing fields total, left, abc[ ] 
  in struct route_rule_count. 

> 
> Regards,
> /Bruce

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH v2] app/test: remove large lpm test head file
  2016-09-27 17:38 ` [dpdk-dev] [PATCH v2] " Wei Dai
  2016-09-28  8:41   ` Bruce Richardson
@ 2016-10-13 13:28   ` Thomas Monjalon
  1 sibling, 0 replies; 9+ messages in thread
From: Thomas Monjalon @ 2016-10-13 13:28 UTC (permalink / raw)
  To: Wei Dai; +Cc: dev, bruce.richardson

2016-09-28 01:38, Wei Dai:
> remove the large file app/test/test_lpm_routes.h and add codes to
> auto-generate similar large route rule talbe which keeps same depth
> and IP class distribution as previous one in test_lpm_routes.h .
> With the rule table auto-generated at run time, the performance
> of looking up keep similar to that from pervious constant talbe.
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>

Applied, thanks

There is a comment which may be difficult to understand for newcomers.
Indeed it refers to the old file app/test/test_lpm_routes.h.
However it is not really an issue as this file is a *huge* part of the
DPDK history ;)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-10-13 13:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-26  9:37 [dpdk-dev] [PATCH] app/test: remove large lpm test head file Wei Dai
2016-09-26  9:56 ` Thomas Monjalon
2016-09-26 13:07   ` Dai, Wei
2016-09-26 10:06 ` Bruce Richardson
2016-09-26 13:49   ` Dai, Wei
2016-09-27 17:38 ` [dpdk-dev] [PATCH v2] " Wei Dai
2016-09-28  8:41   ` Bruce Richardson
2016-09-28 15:19     ` Dai, Wei
2016-10-13 13:28   ` Thomas Monjalon

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).