Page MenuHomeFreeBSD

Don't stat nsswitch.conf all the time.

Authored by trasz on Nov 10 2018, 1:51 AM.



Don't call stat(2) on nsswitch.conf(5) every time nsdispatch(3)
and dependent functions (eg getpwname(3)) get called. This can
improve performance of bbinaries that perform a lot of name
lookups, such as gssd(8). It also matches documented behaviour
of Linux and Solaris.

The old code is left in place, should anyone need it, guarded
by #ifdef NS_REREAD_CONF.

Relnotes: yes

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

trasz created this revision.Nov 10 2018, 1:51 AM
trasz added reviewers: imp, des.Nov 10 2018, 1:52 AM
imp accepted this revision.Nov 10 2018, 2:18 AM
This revision is now accepted and ready to land.Nov 10 2018, 2:18 AM
bcr accepted this revision.Nov 10 2018, 11:06 AM
bcr added a subscriber: bcr.

OK from manpages. Thanks for the work!

This revision was automatically updated to reflect the committed changes.
des reopened this revision.Nov 27 2018, 9:35 AM

I would have rejected this change if I had noticed it in time. It is a huge POLA violation, especially on laptops that aren't running their own resolver. There's an intermediate solution, which is to stat the file every M requests and / or N seconds. The caveat is that the latter is very fast on i386, amd64, arm, and arm64, which us a vDSO, but slow on other platforms.

trasz added a comment.Nov 27 2018, 1:15 PM

How does it affect laptops without their own resolver? My assumption was the nsswitch.conf is pretty much only ever changed once, during system setup.

des accepted this revision.Nov 27 2018, 3:20 PM

Never mind, I was thinking of resolv.conf...

This revision is now accepted and ready to land.Nov 27 2018, 3:20 PM
trasz closed this revision.Nov 27 2018, 3:39 PM