]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Merge branch 'oz-trie-table'
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Sun, 6 Feb 2022 22:32:15 +0000 (23:32 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Sun, 6 Feb 2022 22:42:10 +0000 (23:42 +0100)
1  2 
doc/bird.sgml
filter/data.h
filter/test.conf
filter/trie_test.c
proto/bgp/attrs.c
proto/bgp/bgp.c
proto/bgp/bgp.h
proto/bgp/config.Y
proto/bgp/packets.c

diff --cc doc/bird.sgml
Simple merge
diff --cc filter/data.h
Simple merge
Simple merge
index b2b3671644bff2f384254a34205c9b6f5e65368f,c7775006bf794d8c7925894ffe4b7dc6f12977fa..cae8699527faa85c9cf83ced0e87c74d193ffc02
@@@ -134,6 -521,99 +521,99 @@@ t_match_outer_net(void
    return 1;
  }
  
 -  size_t trie_size = rmemsize(lp1) * 1000 / (1024*1024);
+ /*
+  * Read prefixes from @filename, build set of tries, prepare test data and do
+  * PREFIX_BENCH_NUM trie lookups. With @plus = 0, use random subset of known
+  * prefixes as test data, with @plus = 1, use randomly generated /32 prefixes
+  * as test data.
+  */
+ static int
+ benchmark_trie_dataset(const char *filename, int plus)
+ {
+   int n = 0;
+   linpool *lp0 = lp_new_default(&root_pool);
+   linpool *lp1 = lp_new_default(&root_pool);
+   list *data[TRIE_BUFFER_SIZE];
+   struct f_trie *trie[TRIE_BUFFER_SIZE];
+   net_addr *nets;
+   bt_reset_suite_case_timer();
+   bt_log_suite_case_result(1, "Reading %s", filename, n);
+   n = read_prefix_file(filename, plus, lp0, lp1, data, trie);
+   bt_log_suite_case_result(1, "Read prefix data, %d lists, ", n);
++  size_t trie_size = rmemsize(lp1).effective * 1000 / (1024*1024);
+   bt_log_suite_case_result(1, "Trie size %u.%03u MB",
+                          (uint) (trie_size / 1000), (uint) (trie_size % 1000));
+   int t = PREFIX_BENCH_NUM / n;
+   int tb = MIN(t, TEST_BUFFER_SIZE);
+   nets = lp_alloc(lp0, tb * sizeof(net_addr));
+   if (!plus)
+     select_random_prefix_subset(data, nets, n, tb);
+   else
+     make_random_addresses(nets, tb);
+   bt_log_suite_case_result(1, "Make test data, %d (%d) tests", t, tb);
+   bt_reset_suite_case_timer();
+   /*
+   int match = 0;
+   for (int i = 0; i < t; i++)
+     for (int j = 0; j < n; j++)
+       test_match_net(data[j], trie[j], &nets[i]);
+   */
+   int match = 0;
+   for (int i = 0; i < t; i++)
+     for (int j = 0; j < n; j++)
+       if (trie_match_net(trie[j], &nets[i % TEST_BUFFER_SIZE]))
+       match++;
+   bt_log_suite_case_result(1, "Matching done, %d / %d matches", match, t * n);
+   rfree(lp0);
+   rfree(lp1);
+   return 1;
+ }
+ static int UNUSED
+ t_bench_trie_datasets_subset(void)
+ {
+   bt_bird_init();
+   bt_config_parse(BT_CONFIG_SIMPLE);
+   /* Specific datasets, not included */
+   benchmark_trie_dataset("trie-data-bgp-1", 0);
+   benchmark_trie_dataset("trie-data-bgp-10", 0);
+   benchmark_trie_dataset("trie-data-bgp-100", 0);
+   benchmark_trie_dataset("trie-data-bgp-1000", 0);
+   bt_bird_cleanup();
+   return 1;
+ }
+ static int UNUSED
+ t_bench_trie_datasets_random(void)
+ {
+   bt_bird_init();
+   bt_config_parse(BT_CONFIG_SIMPLE);
+   /* Specific datasets, not included */
+   benchmark_trie_dataset("trie-data-bgp-1", 1);
+   benchmark_trie_dataset("trie-data-bgp-10", 1);
+   benchmark_trie_dataset("trie-data-bgp-100", 1);
+   benchmark_trie_dataset("trie-data-bgp-1000", 1);
+   bt_bird_cleanup();
+   return 1;
+ }
  static int
  t_trie_same(void)
  {
Simple merge
diff --cc proto/bgp/bgp.c
Simple merge
diff --cc proto/bgp/bgp.h
Simple merge
index 7cbc9985fdc00e4464935563bc80e0f34cb60876,27c352c54de885ee7920e1b1662dbcaf460a2474..241aa7c294ee6b82ed4c954607a16ad933916391
@@@ -31,7 -31,7 +31,7 @@@ CF_KEYWORDS(BGP, LOCAL, NEIGHBOR, AS, H
        STRICT, BIND, CONFEDERATION, MEMBER, MULTICAST, FLOW4, FLOW6, LONG,
        LIVED, STALE, IMPORT, IBGP, EBGP, MANDATORY, INTERNAL, EXTERNAL, SETS,
        DYNAMIC, RANGE, NAME, DIGITS, BGP_AIGP, AIGP, ORIGINATE, COST, ENFORCE,
-       FIRST, FREE)
 -      FIRST, VALIDATE, BASE)
++      FIRST, FREE, VALIDATE, BASE)
  
  %type <i> bgp_nh
  %type <i32> bgp_afi
Simple merge