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)
Mon, Nov 25, 3:38 PM
Unknown Object (File)
Sun, Nov 24, 7:50 AM
Unknown Object (File)
Oct 16 2024, 3:02 AM
Unknown Object (File)
Oct 15 2024, 7:31 AM
Unknown Object (File)
Oct 13 2024, 9:37 AM
Unknown Object (File)
Oct 12 2024, 7:23 PM
Unknown Object (File)
Oct 11 2024, 2:05 PM
Unknown Object (File)
Oct 10 2024, 5:58 AM
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.