[PATCH 3/6] Add hash support in cache mngr

Thomas Graf tgraf at suug.ch
Tue Nov 6 03:57:12 EST 2012


On 11/05/12 at 04:43pm, Roopa Prabhu wrote:
> We think route and neigh caches in some cases might grow to that size.
> The patch sets a smaller value to something like a link cache.
> It can be flipped too. Smaller common default size and something
> like route cache gets a larger default value.
> 
> But agreed, I would rather make this user configurable. Which i did
> try to do first time around. But this value should
> be specified at cache allocation time since hash table is allocated
> then. I did not find a clean way to do that. Its possible if we add
> a new cache alloc api or add a new api to add hashtable to an
> existing cache immediately after cache alloc.
> 
> Let me know if you have any preferences.
> 
> Any suggestions on the default hash size ?.

Let's keep the default at 1024 but make the default configurable
by the application:

	nl_config_set_default_htable_size(size_t nelems);

This keeps the default sane for existing users of which some
rely on small memory footprints such as Android while giving
routing daemons or applications a like the chance to user
larger hashtables by default.

We can also allow to resize the hashtable of existing caches. All
objects are on a list so just resize the table and repopulate it
by walking through the list. It's an expensive operation but that
shouldn't matter, we can mark it as such.



More information about the libnl mailing list