I had mentioned to Brian possibly using the compressed radix tree structure
I implemented in 44ripd; that is a both space- and time- efficient
structure for maintaining exactly this sort of data; since keys are 32-bit
integers but with a fixed prefix, operations (including additions, updates
and removals) are always strictly less than O(32) and may be thought of as
O(1) in the asymptote. I haven't benchmarked it and suspect the
coefficients would dominate over an array, but one could imagine an
"in-place" update process where one iterates over the input data, updates
the tree by either adding entries or updating a timestamp, then walks the
tree looking for old entries and making a note. These could then be removed
after the fact. Indeed, that's basically what 44ripd does, and while it is
currently single-threaded, one could extract the data structure and wrap it
in a read/write lock and then use the same method but process only each
individual removal operation while holding the write lock. There would be
no need to zero anything on an add or delete.
https://github.com/dancrossnyc/44ripd
Specifically look for the "IPMap" code:
https://github.com/dancrossnyc/44ripd/blob/master/dat.h (data structure
definitions)
https://github.com/dancrossnyc/44ripd/blob/master/fns.h (function
prototypes)
https://github.com/dancrossnyc/44ripd/blob/master/lib.c (function
implementations)
- Dan C.
On Tue, May 2, 2017 at 5:50 AM, Brian Kantor <Brian(a)ucsd.edu> wrote:
(Please trim inclusions from previous messages)
_______________________________________________
That is exactly what I'm doing. It is necessary to clear and reload the
global array if a subnet is added or deleted, but not when it is aged
(as part of the route expiry system) or the gateway next-hop address
is changed.
The delay is entirely caused by clearing the array. I'm using 'bzero()'
to do that, as that's the fastest way I know of to zero an existing
array, but it still takes 25ms to zero a vector of 16 million shorts.
(Stepping through it with a for loop takes roughly 5 times as long.)
Luckily most changes in the encap routing table are indeed just revisions
to the gateway next-hop address caused by gateways with dynamic addresses
that change. That only takes less than 3ms to do all 600+ subnets.
- Brian
On Tue, May 02, 2017 at 09:16:23AM +0200, Rob Janssen wrote:
Another possibility would be to first scan for
the "common case" of all
subnets
and gateways remaining the same but only the
endpoint address of one or
two
gateways changing, and in that case omit the
entire table setup and only
patch the
nexthop addresses of those gateways.
Rob
_________________________________________
44Net mailing list
44Net(a)hamradio.ucsd.edu
http://hamradio.ucsd.edu/mailman/listinfo/44net