Improve IPAddress::toFullyQualified() CPU performance
Summary:
Currently IPAddress::toFullyQualified() is fairly slow for IPv6.
Change here implements more lightweight in_addr/in6_addr to string functions.
I also added a benchmark for comparison with inet_ntop.
This makes IPAddressV6::toFullyQualified() significantly faster than inet_ntop, and makes IPAddressV4::str() ~20ns faster than previous impementation (previously ~80ns).
Previous benchmark:
============================================================================
folly/test/IPAddressBenchmark.cpp relative time/iter iters/s
============================================================================
ipv4_to_string_inet_ntop 238.91ns 4.19M
ipv4_to_fully_qualified 289.96% 82.39ns 12.14M
----------------------------------------------------------------------------
ipv6_to_string_inet_ntop 780.72ns 1.28M
ipv6_to_fully_qualified 51.11% 1.53us 654.59K
============================================================================
With this change:
============================================================================
folly/test/IPAddressBenchmark.cpp relative time/iter iters/s
============================================================================
ipv4_to_string_inet_ntop 238.06ns 4.20M
ipv4_to_fully_qualified 364.76% 65.26ns 15.32M
----------------------------------------------------------------------------
ipv6_to_string_inet_ntop 770.74ns 1.30M
ipv6_to_fully_qualified 791.63% 97.36ns 10.27M
============================================================================
Test Plan:
fbconfig folly/test:network_address_test folly/test:network_address_benchmark
fbmake runtests_opt
Reviewed By: simpkins@fb.com
Subscribers: ps, bmatheny
FB internal diff:
D1477925
Tasks:
4832974