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)
Dec 22 2023, 10:02 PM
Unknown Object (File)
Sep 2 2023, 3:59 PM
Unknown Object (File)
Sep 2 2023, 3:56 PM
Unknown Object (File)
Sep 2 2023, 3:55 PM
Unknown Object (File)
Aug 27 2023, 8:19 PM
Unknown Object (File)
Jun 28 2023, 5:49 PM
Unknown Object (File)
Jun 28 2023, 5:47 PM
Unknown Object (File)
Jun 28 2023, 5:46 PM
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