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

27
5 Tuning Applications Using Programmatic Interfaces
5.1 sendfile()
The sendfile() system call allows the contents of a file to be transmitted directly over a TCP connection,
without the need to copy data to and from the calling application's buffers. This provides zero copy feature
for sending data to the remote side. Refer to the sendfile(2) manpage for details on syntax and usage
of sendfile.
In HP-UX 11i v3, sendfile() has been updated to use the Unified File Cache (UFC), which provides
kernel access to file data. There is no externally visible change related to this. However, kernel tunables
on 11i v1 and v2 used for tuning the buffer cache and sendfile memory usage will no longer have an effect
on HP-UX 11i v3 systems. Obsolete buffer cache tunables include bufcache_max_pct, bufpages,
dbc_min_pct, dbc_max_pct, and nbuf. The sendfile_max tunable is also obsolete. New
tunables are documented in filecache_max(5), filecache_min(5),
fcache_seqlimit_file(5), and fcache_seqlimit_system(5). Refer to the manpages in the
HP-UX Reference manual and the HP-UX 11i v3 Release Notes, in Chapter 6 under HP-UX File Systems
Architecture Enhancements (http://docs.hp.com/en/5991-6469/index.html) for more documentation of
these tunables.
sendfile() uses the file cache with sequential access for transmitting file data. Therefore, the
performance of sendfile() can be affected by how much of a given file can be cached based on the
size of the file cache (filecache_min/filecache_max) and the amount available for a file using
sequential access (fcache_seqlimit_file). If the entire file can be kept in the file cache between
sendfile calls, the second sendfile call will be able to operate at the speed of memory instead of being
delayed by disk I/O.
Conversely, in sizing the file cache, the performance of other applications should also be taken into
account. If a large file monopolizes the file cache after a sendfile() call, other files may be flushed from
the file cache, slowing non-sendfile file accesses.
The default tunable values should be optimal for most purposes. In the case where sendfile_max had
previously been changed from the default to a lower value to limit the amount of buffer cache available to
sendfile(), you may want to consider tuning fcache_seqlimit_file and/or
fcache_seqlimit_system to a lower value. In the case where sendfile_max had previously been
increased from the default value, and the size of a file(s) transmitted with sendfile() is close to the size
of the file cache or the size of physical memory, you may want to increase value of filecache_max. If
this can be done without causing a shortage of memory elsewhere in the system, it could improve the
performance of sendfile() by allowing the entire file to reside in the cache.
5.2 Polling Events
To monitor I/O conditions on multiple file descriptors, select()and poll() system calls are typically
used. Though poll() is preferred over select() as it allows various types of event to be monitored and
is more efficient compared to select(), using poll() can still affect performance when a large number
of file descriptors are monitored.
On HP-UX there is another mechanism called /dev/poll (event port) that can be used to monitor
the I/O events on a large number of file descriptors. In this mechanism, an application opens the