Commit e6308be85afee685347fa3440bed10faaa5d6c1a
Committed by
David S. Miller
1 parent
87bf9c97b4
Exists in
master
and in
7 other branches
[IPV4]: fib_trie root-node expansion
The patch below introduces special thresholds to keep root node in the trie large. This gives a flatter tree at the cost of a modest memory increase. Overall it seems to be gain and this was also proposed by one the authors of the paper in recent a seminar. Main table after loading 123 k routes. Aver depth: 3.30 Max depth: 9 Root-node size 12 bits Total size: 4044 kB With the patch: Aver depth: 2.78 Max depth: 8 Root-node size 15 bits Total size: 4150 kB An increase of 8-10% was seen in forwading performance for an rDoS attack. Signed-off-by: Robert Olsson <robert.olsson@its.uu.se> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 21 additions and 2 deletions Side-by-side Diff
net/ipv4/fib_trie.c
... | ... | @@ -286,6 +286,8 @@ |
286 | 286 | |
287 | 287 | static int halve_threshold = 25; |
288 | 288 | static int inflate_threshold = 50; |
289 | +static int halve_threshold_root = 15; | |
290 | +static int inflate_threshold_root = 25; | |
289 | 291 | |
290 | 292 | |
291 | 293 | static void __alias_free_mem(struct rcu_head *head) |
... | ... | @@ -449,6 +451,8 @@ |
449 | 451 | int i; |
450 | 452 | int err = 0; |
451 | 453 | struct tnode *old_tn; |
454 | + int inflate_threshold_use; | |
455 | + int halve_threshold_use; | |
452 | 456 | |
453 | 457 | if (!tn) |
454 | 458 | return NULL; |
455 | 459 | |
... | ... | @@ -541,10 +545,17 @@ |
541 | 545 | |
542 | 546 | check_tnode(tn); |
543 | 547 | |
548 | + /* Keep root node larger */ | |
549 | + | |
550 | + if(!tn->parent) | |
551 | + inflate_threshold_use = inflate_threshold_root; | |
552 | + else | |
553 | + inflate_threshold_use = inflate_threshold; | |
554 | + | |
544 | 555 | err = 0; |
545 | 556 | while ((tn->full_children > 0 && |
546 | 557 | 50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >= |
547 | - inflate_threshold * tnode_child_length(tn))) { | |
558 | + inflate_threshold_use * tnode_child_length(tn))) { | |
548 | 559 | |
549 | 560 | old_tn = tn; |
550 | 561 | tn = inflate(t, tn); |
551 | 562 | |
... | ... | @@ -564,10 +575,18 @@ |
564 | 575 | * node is above threshold. |
565 | 576 | */ |
566 | 577 | |
578 | + | |
579 | + /* Keep root node larger */ | |
580 | + | |
581 | + if(!tn->parent) | |
582 | + halve_threshold_use = halve_threshold_root; | |
583 | + else | |
584 | + halve_threshold_use = halve_threshold; | |
585 | + | |
567 | 586 | err = 0; |
568 | 587 | while (tn->bits > 1 && |
569 | 588 | 100 * (tnode_child_length(tn) - tn->empty_children) < |
570 | - halve_threshold * tnode_child_length(tn)) { | |
589 | + halve_threshold_use * tnode_child_length(tn)) { | |
571 | 590 | |
572 | 591 | old_tn = tn; |
573 | 592 | tn = halve(t, tn); |