Page MenuHomeFreeBSD

Don't stat nsswitch.conf all the time.
ClosedPublic

Authored by trasz on Nov 10 2018, 1:51 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 3:47 AM
Unknown Object (File)
Oct 3 2024, 10:53 PM
Unknown Object (File)
Sep 10 2024, 12:33 PM
Unknown Object (File)
Sep 4 2024, 4:53 AM
Unknown Object (File)
Aug 18 2024, 10:01 AM
Unknown Object (File)
Aug 18 2024, 12:54 AM
Unknown Object (File)
Aug 15 2024, 6:22 PM
Unknown Object (File)
Jun 29 2024, 1:09 AM
Subscribers

Details

Summary

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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Nov 10 2018, 2:18 AM
bcr added a subscriber: bcr.

OK from manpages. Thanks for the work!

This revision was automatically updated to reflect the committed changes.

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.

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.

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

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