summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-12-04 14:15:28 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-12-04 14:15:28 +0000
commit5c26af9dca4f7ab0fda560e005101f103f3f1c4c (patch)
tree344c749a8bfecc210b825490f5b57f892da6d4d6 /sys
parentf1cbcfc347fef23cdc9e8052cee6fcbb301143d8 (diff)
Reduce the stride length of the tables by two and use a single page
allocator for the 4K heap. In this configuration a fullfeed BGP server for v4 and v6 consumes 10M more than with the radix tree. This double the depth of the tree and makes the lookup slower. But the ratio speed/memory can be adjusted in the future, for now we are interested in a lock-free route lookup. Tested by and ok benno@
Diffstat (limited to 'sys')
-rw-r--r--sys/net/art.c38
-rw-r--r--sys/net/art.h4
2 files changed, 21 insertions, 21 deletions
diff --git a/sys/net/art.c b/sys/net/art.c
index 747878fa34d..c1efaf0426e 100644
--- a/sys/net/art.c
+++ b/sys/net/art.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: art.c,v 1.10 2015/11/24 12:48:20 dlg Exp $ */
+/* $OpenBSD: art.c,v 1.11 2015/12/04 14:15:27 mpi Exp $ */
/*
* Copyright (c) 2015 Martin Pieuchot
@@ -83,16 +83,16 @@ int art_table_free(struct art_root *, struct art_table *);
int art_table_walk(struct art_root *, struct art_table *,
int (*f)(struct art_node *, void *), void *);
-struct pool at_pool, at_heap_8_pool, at_heap_16_pool;
+struct pool at_pool, at_heap_4_pool, at_heap_8_pool;
void
art_init(void)
{
pool_init(&at_pool, sizeof(struct art_table), 0, 0, 0, "art_table",
NULL);
- pool_init(&at_heap_8_pool, AT_HEAPSIZE(8), 0, 0, 0, "art_heap8", NULL);
- pool_init(&at_heap_16_pool, AT_HEAPSIZE(16), 0, 0, 0, "art_heap16",
- NULL);
+ pool_init(&at_heap_4_pool, AT_HEAPSIZE(4), 0, 0, 0, "art_heap4", NULL);
+ pool_init(&at_heap_8_pool, AT_HEAPSIZE(8), 0, 0, 0, "art_heap8",
+ &pool_allocator_single);
}
/*
@@ -112,17 +112,17 @@ art_alloc(unsigned int rtableid, int off)
switch (off) {
case 4: /* AF_INET && AF_MPLS */
ar->ar_alen = 32;
- ar->ar_nlvl = 3;
- ar->ar_bits[0] = 16;
- ar->ar_bits[1] = 8;
- ar->ar_bits[2] = 8;
+ ar->ar_nlvl = 7;
+ ar->ar_bits[0] = 8;
+ for (i = 1; i < ar->ar_nlvl; i++)
+ ar->ar_bits[i] = 4;
break;
#ifdef INET6
case 8: /* AF_INET6 */
ar->ar_alen = 128;
- ar->ar_nlvl = 16;
+ ar->ar_nlvl = 32;
for (i = 0; i < ar->ar_nlvl; i++)
- ar->ar_bits[i] = 8;
+ ar->ar_bits[i] = 4;
break;
#endif /* INET6 */
default:
@@ -661,12 +661,12 @@ art_table_get(struct art_root *ar, struct art_table *parent, int j)
return (NULL);
switch (AT_HEAPSIZE(ar->ar_bits[lvl])) {
+ case AT_HEAPSIZE(4):
+ at_heap = pool_get(&at_heap_4_pool, PR_NOWAIT|PR_ZERO);
+ break;
case AT_HEAPSIZE(8):
at_heap = pool_get(&at_heap_8_pool, PR_NOWAIT|PR_ZERO);
break;
- case AT_HEAPSIZE(16):
- at_heap = pool_get(&at_heap_16_pool, PR_NOWAIT|PR_ZERO);
- break;
default:
panic("incorrect stride length %u", ar->ar_bits[lvl]);
}
@@ -718,15 +718,15 @@ art_table_put(struct art_root *ar, struct art_table *at)
ar->ar_root = NULL;
}
- switch (AT_HEAPSIZE(ar->ar_bits[lvl])) {
+ switch (AT_HEAPSIZE(at->at_bits)) {
+ case AT_HEAPSIZE(4):
+ pool_put(&at_heap_4_pool, at->at_heap);
+ break;
case AT_HEAPSIZE(8):
pool_put(&at_heap_8_pool, at->at_heap);
break;
- case AT_HEAPSIZE(16):
- pool_put(&at_heap_16_pool, at->at_heap);
- break;
default:
- panic("incorrect stride length %u", ar->ar_bits[lvl]);
+ panic("incorrect stride length %u", at->at_bits);
}
pool_put(&at_pool, at);
diff --git a/sys/net/art.h b/sys/net/art.h
index 158987fb075..7d59f4df6ba 100644
--- a/sys/net/art.h
+++ b/sys/net/art.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: art.h,v 1.8 2015/12/03 16:27:32 mpi Exp $ */
+/* $OpenBSD: art.h,v 1.9 2015/12/04 14:15:27 mpi Exp $ */
/*
* Copyright (c) 2015 Martin Pieuchot
@@ -19,7 +19,7 @@
#ifndef _NET_ART_H_
#define _NET_ART_H_
-#define ART_MAXLVL 16 /* We currently use 16 levels for IPv6. */
+#define ART_MAXLVL 32 /* We currently use 32 levels for IPv6. */
/*
* Root of the ART tables, equivalent to the radix head.