Similar to madvise, the posix_fadvise() call hints the kernel to optimize file access. The options available are similar to madvise - POSIX_FADV_NORMAL/RANDOM/SEQUENTIAL/WILLNEED.
POSIX_FADV_NOREUSE indicates that the data are only used once.
POSIX_FADV_DONTNEED evicts pages in the range from the file cache.
In general, file advise can benefit application performance. Before reading, application an give FADV_WILLNEED and kernel will read the data block in asynchronously. When the application reach the point to read the data, blocking can be avoided. The FADV_DONTNEED hint can return pages to the file cache for other purpose. An application that intends to read in the whole files can use FADV_SEQUENTIAL hint to speed up the processing.
No comments:
Post a Comment