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, Apr 29, 7:13 PM
Unknown Object (File)
Mon, Apr 29, 6:51 PM
Unknown Object (File)
Jan 27 2024, 2:43 AM
Unknown Object (File)
Dec 20 2023, 2:23 AM
Unknown Object (File)
Dec 12 2023, 3:37 PM
Unknown Object (File)
Nov 9 2023, 3:46 PM
Unknown Object (File)
Nov 4 2023, 4:24 PM
Unknown Object (File)
Nov 2 2023, 6:44 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.