dirhash and dynamic memory allocation

Miroslav Lachman 000.fbsd at quip.cz
Sat Oct 22 09:52:04 UTC 2011


Doug Barton wrote:
> On 10/21/2011 20:04, Jeremy Chadwick wrote:
>> On Fri, Oct 21, 2011 at 07:16:27PM -0700, Doug Barton wrote:
>
>>> Isn't that what vfs.ufs.dirhash_minsize is for? I think given that there
>>> is a lot more memory in modern systems setting that higher by default is
>>> probably a good idea. Or maybe I'm misunderstanding what that knob does?
>>
>> I believe the function of that sysctl is different.  It's not the
>> "minimum amount of dirhash memory to retain", it's:
>>
>> $ sysctl -d vfs.ufs.dirhash_minsize
>> vfs.ufs.dirhash_minsize: minimum directory size in bytes for which to use hashed lookup
>
> Ah, silly me. I'm so used to 'sysctl -d' not working that I didn't even
> try it this time. Thanks for setting me straight.

sysctls are becoming a mess as new are added, but only few of them are 
good named or documented. Even if some have 'sysctl -d' description, the 
description is not helpfull for non-developer persons like me.
And the second aspect is that sometimes there is two sysctl OID with 
slightly different naming scheme doing the same (or having same description)

for example low_mem vs. lowmemcount:

# sysctl -a | egrep 'low_?mem'
kern.geom.journal.stats.low_mem: 46443
vfs.ufs.dirhash_lowmemcount: 46443

# sysctl -d {kern.geom.journal.stats.low_mem,vfs.ufs.dirhash_lowmemcount}

kern.geom.journal.stats.low_mem: Number of times low_mem hook was called.
vfs.ufs.dirhash_lowmemcount: number of times low memory hook called

And the problem for non-developer person is, that this description 
brings more questions than it answers. "What condition is causing it?, 
What low mem hook is doing? What should I do with it?..." (I already 
know it, not from a documentation, but from discussions in mailinglists)

FreeBSD is known to its good documentation, so it is sad that this 
important part of the system is lacking really good documentation. 
FreeBSD comes with not optimal default settings nor autotunes, so almost 
everybody needs to set something in loader.conf or sysctl.conf to 
achieve better performance. But it is hard without good sysctl 
documentation.
I know there were some atempts in the past (GSoC project and 
http://wiki.freebsd.org/IdeasPage#Document_all_sysctls) but none of them 
was successful.

Maybe it's time for stronger policy in committing new code to the tree - 
if something is adding new sysctl IOD, it must have 'sysctl -d' 
description and some documentation of its behavior in handbook or some 
wiki page - I don't know where is the right place to have all sysctls 
documented. (something like man rc.conf) Maybe wiki page with some 
tuning tips will be the best place, as more persons can edit it.

...I am sorry for being off-topic, this is really not related to my 
original dirhash problem. :)

> In that case I agree with the OP that a knob for minimum setting would
> be desirable.

Miroslav Lachman


More information about the freebsd-fs mailing list