Page MenuHomeFreeBSD

Speed up rctl(8) rule retrieval.
ClosedPublic

Authored by trasz on Nov 1 2015, 8:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 16, 10:55 AM
Unknown Object (File)
Mar 17 2024, 1:57 AM
Unknown Object (File)
Mar 17 2024, 1:57 AM
Unknown Object (File)
Dec 25 2023, 1:38 PM
Unknown Object (File)
Dec 20 2023, 1:03 AM
Unknown Object (File)
Nov 29 2023, 9:13 AM
Unknown Object (File)
Nov 2 2023, 11:33 PM
Unknown Object (File)
Oct 25 2023, 5:14 PM
Subscribers

Details

Summary

Speed up rctl(8) rule retrieval; the difference shows mostly in "rctl -n",
as otherwise most of the time is spent resolving UIDs to names.

Diff Detail

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

Event Timeline

trasz retitled this revision from to Speed up rctl(8) rule retrieval..
trasz updated this object.
trasz edited the test plan for this revision. (Show Details)

I disagree with this approach. Userspace can pass arbitrarily large buffer which is not checked.

Current code expands the buffer until it is big enough.

The speedup can be achieved without sacrificing this functionality. For instance, one can start with min(RCTL_DEFAULT_BUFSIZE, uap->outbuflen) and grow it to uap->outbuflen tops. With the define increased this should give the same speedup, while not allowing way too much memory just because userspace asked for it.

The lack of limit is on purpuse - the API is root-only (and would require serious review if made non-root), and having a limit would introduce a new failure mode, where the admin needs to bump some sysctl to list rules.

As for the speedup - we cannot do this with looping, because each loop always traverses all the rules. In other words, if we start with a small value, we'll have to make multiple passes in the kernel.

trasz edited edge metadata.

Add bufsize cap.

mjg edited edge metadata.
This revision is now accepted and ready to land.Nov 7 2015, 7:52 PM
This revision was automatically updated to reflect the committed changes.