RFC: Automatically Reloading /etc/resolv.conf
Eric van Gyzen
vangyzen at FreeBSD.org
Thu Oct 8 21:27:31 UTC 2015
On 10/08/2015 11:13, Warner Losh wrote:
>
> Make sure you rate limit it.
Agreed. As I just wrote in my other reply, calling stat() on every
query reduces queries-per-second by 15.87%. Rate-limiting to one stat()
every ten seconds fixes it. That is, by manually running three or four
benchmarks with and without my changes, I see no real difference. This
was on amd64 where the cost of clock_gettime() is trivialized by vdso.
>> Disadvantage: This would persistently allocate an open file and a
>> kqueue for every thread that ever uses the resolver, for the life of the
>> thread. This seems fairly expensive.
>>
>
> Why does this follow? Can't you have a global one for the process?
Well, gee, that seems like a good compromise, now that you mention it.
;-) Seriously, I simply didn't consider that.
Given that the rate-limited stat() approach is so cheap, I wonder if
it's worth the trouble to try the global kqueue approach.
>> NetBSD uses this approach. It mitigates most of the space-cost by using
>> a shared pool of res_state objects, instead of one per thread [that uses
>> the resolver]. On each query, a thread allocates/borrows a res_state
>> from the pool, uses it, and returns it. So, the number of objects is
>> only the high water mark of the number of threads _concurrently_ issuing
>> resolver queries.n
>>
>
> What's the locking scaleability here when resolv.conf changes?
The mutex is only held during one or two SLIST operations, so the
locking is independent of resolv.conf changing. Maybe I misunderstood
your question?
>> FYI, I'm leaning toward the "stat" approach.
>>
>
> It sounds simpler to implement, but likely a higher overhead than the
> kqueue approach. resolv.conf changes on an time scale measured in minutes
> or hours for the mobile user, and on the scale of years for servers.
> Polling on the scale of seconds (at least two orders of magnitude faster
> than the rate of change) seems like a lot of extra work over the life of
> resolv.conf.
On the other hand, when changes _are_ needed, you don't want to restart
critical services in order to make them effective. (This is my
motivation, in fact.) It would be trivial to add a "no-reload" option
so performance-sensitive users can turn it off. In fact, I half
expected this request from someone focused on embedded work, such as
yourself. ;-)
Eric
More information about the freebsd-arch
mailing list