dhcpcd-discuss

Re: [RFC]Routes are stored as a linked list

Roy Marples

Sun Mar 03 21:21:22 2019

On 03/03/2019 13:42, Donald Sharp wrote:
Hi Roy -
To generate these routes I used FRRouting (https://frrouting.org).
The code can be found here: https://github.com/frrouting/frr.git .
Documentation to build on NetBSD is here:
http://docs.frrouting.org/projects/dev-guide/en/latest/building-frr-for-netbsd7.html
.  Essentially I used a new utility daemon to generate the routes via
cli: http://docs.frrouting.org/en/latest/sharp.html .  This can be a
bit complicated to setup, if you are interested in setting it up and
run into issues feel free to reach out to me, I'll get you any help
you may need here.

I'll look into that next week maybe.

On to your questions about dhcpcd: I did see the rbtree()
functionality when I went searching for a replacement, but it is not
immediately available on linux..  I knew the rb_tree code would drop
right in as that we use it in our project.  Personally I don't have a
dog in this fight( hence the question in the original email ).  If you
want to use something else please do so, no skin off my back.  You'll
just need to point me at it if you want me to do the work :)

Size of original data structures:
(gdb) p sizeof(struct dhcpcd_ctx)
$1 = 600
(gdb) p sizeof(struct rt)
$2 = 160
(gdb)

1 million routes with original dhcpcd is ~19mb of main memory

Size w/ rb_tree:
(gdb) p sizeof(struct dhcpcd_ctx)
$1 = 904
(gdb) p sizeof(struct rt)
$2 = 176(gdb)

With 1 million routes with my code it's ~180mb of main memory.  This
implies I've introduced a memory leak, Looks like I'll need to look at
it this evening to see if I can figure out where I've gone wrong.  As
that an extra 16 bytes of memory per `struct rt` shouldn't be causing
this many problems.

I've implemented rbtree(3) into dhcpcd in a new branch here:
https://roy.marples.name/git/dhcpcd.git/commit/?h=rbtree&id=d1301b94bce1ab4f70ae4ef6222513bf93456b68
The commit message describes why it's not ready for production use.
It seems to work fine on NetBSD - you'll need the patch here if you try:
https://mail-index.netbsd.org/tech-userlevel/2019/03/03/msg011804.html

This saves ~5k on the binary size according to sizeof which is awesome!
Memory usage (with normal use) actually appears to be slightly lower by 100 bytes or so - I suspect my patch fixed a slight bug with the free route list to save on mallocs.

I'll look into adding some portability gunk so this can compile on Linux at least, again, sometime next week. Probably before I look at the frrouting.

Roy

Follow-Ups:
Re: [RFC]Routes are stored as a linked listRoy Marples
Re: [RFC]Routes are stored as a linked listRoy Marples
References:
[RFC]Routes are stored as a linked listDonald Sharp
Re: [RFC]Routes are stored as a linked listRoy Marples
Re: [RFC]Routes are stored as a linked listDonald Sharp
Archive administrator: postmaster@marples.name