Page MenuHomeFreeBSD

Speed up rctl(8) rule retrieval.

Authored by trasz on Nov 1 2015, 8:43 PM.



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

rS FreeBSD src repository - subversion
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; 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.