[PATCH 3/3] resolv: Optimize inet_ntop
Collin Funk
collin.funk1@gmail.com
Tue Jun 3 22:32:07 GMT 2025
Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> The performance results on aarch64 Neoverse1 with gcc 14.2.1:
>
> * master
>
> aarch64-linux-gnu-master$ ./benchtests/bench-inet_ntop_ipv4
> "inet_ntop_ipv4": {
> "workload-ipv4-random": {
> "duration": 1.43067e+09,
> "iterations": 8e+06,
> "reciprocal-throughput": 178.572,
> "latency": 179.096,
> "max-throughput": 5.59997e+06,
> "min-throughput": 5.58359e+06
> }
> aarch64-linux-gnu-master$ ./benchtests/bench-inet_ntop_ipv6
> "inet_ntop_ipv6": {
> "workload-ipv6-random": {
> "duration": 1.68539e+09,
> "iterations": 4e+06,
> "reciprocal-throughput": 421.307,
> "latency": 421.388,
> "max-throughput": 2.37357e+06,
> "min-throughput": 2.37311e+06
> }
> }
>
> * patched
>
> aarch64-linux-gnu$ ./benchtests/bench-inet_ntop_ipv4
> "inet_ntop_ipv4": {
> "workload-ipv4-random": {
> "duration": 1.06324e+09,
> "iterations": 4.4e+07,
> "reciprocal-throughput": 24.1509,
> "latency": 24.178,
> "max-throughput": 4.14063e+07,
> "min-throughput": 4.13599e+07
> }
> aarch64-linux-gnu$ ./benchtests/bench-inet_ntop_ipv6
> "inet_ntop_ipv6": {
> "workload-ipv6-random": {
> "duration": 1.08476e+09,
> "iterations": 2.4e+07,
> "reciprocal-throughput": 45.2794,
> "latency": 45.1174,
> "max-throughput": 2.20851e+07,
> "min-throughput": 2.21644e+07
> }
> }
>
> Checked on aarch64-linux-gnu and x86_64-linux-gnu.
> ---
> resolv/inet_ntop.c | 134 +++++++++++++++++++++++++++++----------------
> 1 file changed, 87 insertions(+), 47 deletions(-)
This part of the patch series looks good to me. So:
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
I see similar results as well:
$ grep '^model name' /proc/cpuinfo | sed 1q
model name : AMD Ryzen 7 3700X 8-Core Processor
$ gcc --version | sed 1q
gcc (GCC) 15.1.1 20250521 (Red Hat 15.1.1-2)
# Pre patch
$ cat benchtests/bench.out
{"timing_type": "hp_timing",
"functions": {
"inet_ntop_ipv4": {
"workload-ipv4-random": {
"duration": 3.94723e+09,
"iterations": 8e+06,
"reciprocal-throughput": 492.274,
"latency": 494.534,
"max-throughput": 2.03139e+06,
"min-throughput": 2.0221e+06
}
}
,
"inet_ntop_ipv6": {
"workload-ipv6-random": {
"duration": 4.67659e+09,
"iterations": 4e+06,
"reciprocal-throughput": 1164.13,
"latency": 1174.17,
"max-throughput": 859010,
"min-throughput": 851668
}
}
}
}
# Post patch
$ cat benchtests/bench.out
{"timing_type": "hp_timing",
"functions": {
"inet_ntop_ipv4": {
"workload-ipv4-random": {
"duration": 3.67214e+09,
"iterations": 8.4e+07,
"reciprocal-throughput": 43.7862,
"latency": 43.6457,
"max-throughput": 2.28382e+07,
"min-throughput": 2.29118e+07
}
}
,
"inet_ntop_ipv6": {
"workload-ipv6-random": {
"duration": 3.9483e+09,
"iterations": 3.6e+07,
"reciprocal-throughput": 109.916,
"latency": 109.434,
"max-throughput": 9.09786e+06,
"min-throughput": 9.13793e+06
}
}
}
}
Thanks,
Collin
More information about the Libc-alpha
mailing list