Command wrapper to call posix_fadvise(2) after open(2) automatically
C Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
Makefile
README.md
openfadvise.c
openfadvise.sh

README.md

openfadvise - Command wrapper to call posix_fadvise(2) after open(2)

Usage

$ openfadvise noreuse grep foo /path/to/largefile

or:

$ LD_PRELOAD=`pwd`/openfadvise.so OPENFADVISE_ADVISE=noreuse \
  grep foo /path/to/largefile

Available values for $OPENFADVISE_ADVISE (see posix_fadvise(2)):

  • normal
    • POSIX_FADV_NORMAL: Indicates that the application has no advice to give about its access pattern for the specified data.
  • sequential
    • POSIX_FADV_SEQUENTIAL: The application expects to access the specified data sequentially (with lower offsets read before higher ones).
  • random
    • POSIX_FADV_RANDOM: The specified data will be accessed in random order.
  • noreuse
    • POSIX_FADV_NOREUSE: The specified data will be accessed only once.
  • willneed
    • POSIX_FADV_WILLNEED: The specified data will be accessed in the near future.
  • dontneed
    • POSIX_FADV_DONTNEED: The specified data will not be accessed in the near future.

Note

I heard current Linux kernel does NOT support POSIX_FADV_NOREUSE.

See also:

GNU cat(1) calls fadvise64(fd, 0, 0, POSIX_FADV_SEQUENTIAL) after open(2) for all input files, thus openfadvise does not affect.

TODO

$ openfadvise noreuse="*.log" rsyslog ...
$ openfadvise noreuse="/var/log/" rsyslog ...