HP-UX TCP/IP Performance White Paper, March 2008

21
socket_caching_tcp tunable controls both IPv4 and IPv6 TCP connections. Please refer to the ndd help
text for more information. The ndd help text for socket_caching_tcp may be obtained by executing the
following command:
# ndd -h socket_caching_tcp
The number of elements to be cached for optimal performance depends upon the frequency of open/close
and on how the number of simultaneous connections changes over time. In most cases, the default value of
512 is acceptable, but if your application workload is such that large bursts of connections are opened and
closed quickly, then increasing the number of elements to be cached will improve the performance.
4.2.2.2 Performance Data
The publicly available netperf performance measurement tool can be used to measure the performance
improvement of the socket caching feature. In the netperf TCP_CRR test, which simulates short-lived
connections, the typical performance improvement is in the range of 15% - 20% when the socket caching
feature is enabled with the default number of elements (512) to be cached.
4.2.3 Tuning tcphashsz
The tcphashsz configuration variable specifies the size of the networking hash tables. A system such as
a Web server that constantly has a large number of TCP connections may benefit from increasing this
value.
There are several dynamically allocated hash lists in TCP and IP. The sizes of these lists are controlled by
the HP-UX configuration variable tcphashsz. Since this single variable controls the size of multiple lists, it
is treated as a relative scale factor, rather than as the actual size of any specific list. The relative sizes of
the individual lists are fixed. The absolute sizes are determined by the product of the scale factor and the
relative size.
For Web servers handling large number of TCP connections it is beneficial to increase this value in order to
avoid large hash chains. In addition, increasing the tcphashsz on systems with high number of CPUs will
improve scalability and avoid cache misses. The following simplified rule can be applied to tune the
tcphashsz:
tcphashsz = (number of CPUs * 1024)
However, the tcphashsz obtained from the above rule can be increased if the system workload is higher
than expected. The larger the number of hash buckets, better the efficiency. Having a larger number of
hash buckets in a hash table minimizes the chance of multiple connections of having their data structures
placed in the same bucket. More memory is used when this value is raised because it increases the size of
internal hash tables, but this should be an acceptable tradeoff since the memory increase is small compared
to the benefit in improved performance.
The size of hash tables used in the kernel by network protocols is changed by modifying the system
parameter tcphashsz using kctune(1M). The changes to the value of tcphashsz will take place only
after a reboot of the system. The tunable tcphashsz must be a power of two. If it is not specified as a
power of two, the system rounds it down to the nearest power of two. Prior to the 11iv3 0803 release, the
minimum value is 256, the maximum value is 65536, and the default is 2048.
Starting with the 11iv3 0803 (PHNE_36281) release, the tunable tcphashsz is now made auto-tunable
so that the system can decide the optimal value of tcphashsz at boot time. The default value of tcphashsz