Date: Thu, 8 Oct 2015 16:27:28 -0500 From: Eric van Gyzen <vangyzen@FreeBSD.org> To: freebsd-arch@freebsd.org, Warner Losh <imp@bsdimp.com> Subject: Re: RFC: Automatically Reloading /etc/resolv.conf Message-ID: <5616DFC0.8070404@FreeBSD.org> In-Reply-To: <CANCZdfp7k8wwU%2B0ChXD8rVK0kWq5F%2BORpjCH46Gg5qUq9Fw3xw@mail.gmail.com> References: <5615886F.3060601@FreeBSD.org> <CANCZdfp7k8wwU%2B0ChXD8rVK0kWq5F%2BORpjCH46Gg5qUq9Fw3xw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5616DFC0.8070404>