Page MenuHomeFreeBSD

resolver: abuse _res a little less
ClosedPublic

Authored by vangyzen on Oct 14 2015, 2:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Sep 5, 6:09 PM
Unknown Object (File)
Sat, Sep 5, 6:08 PM
Unknown Object (File)
Sat, Sep 5, 10:52 AM
Unknown Object (File)
Thu, Sep 3, 11:41 PM
Unknown Object (File)
Thu, Sep 3, 10:36 AM
Unknown Object (File)
Thu, Sep 3, 5:32 AM
Unknown Object (File)
Thu, Sep 3, 4:56 AM
Unknown Object (File)
Wed, Sep 2, 2:48 PM
Subscribers

Details

Summary

In the past, _res was a global variable. Now, it's multiple function calls.
Several functions in the resolver use _res multiple times and therefore
call the function(s) far more than necessary.

Fix those callers to store the result of _res in a local variable.

Diff Detail

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

Event Timeline

vangyzen retitled this revision from to resolver: abuse _res a little less.
vangyzen updated this object.
vangyzen edited the test plan for this revision. (Show Details)
vangyzen added subscribers: kp, jilles.
jilles requested changes to this revision.Oct 18 2015, 2:42 PM
jilles added a reviewer: jilles.

Reading the code, this looks OK, but in compilation an undesirable side effect can be seen. This is on amd64 with 11-current's default clang. The improvements to res_init() cause it to fall below a threshold and be inlined everywhere, leading to a 15% code size increase rather than the expected decrease (in the "text" column of size(1)).

Adding __noinline to the definition of res_init() fixes this, giving a code size decrease of 3%.

A further function could be extracted with the check for -1 and RES_SET_H_ERRNO(statp, NETDB_INTERNAL); for further size reduction.

__predict_false might have a similar effect (I have not tried this) but the comments in <sys/cdefs.h> discourage its use for this purpose.

This revision now requires changes to proceed.Oct 18 2015, 2:42 PM
vangyzen edited edge metadata.

Add __noinline to the definition of res_init() to avoid the code bloat
that these changes would have otherwise incurred. (Thanks, jilles.)

jilles edited edge metadata.
This revision is now accepted and ready to land.Oct 22 2015, 11:52 PM
This revision was automatically updated to reflect the committed changes.