diff options
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/io/NativeIO.java')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/io/NativeIO.java | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/io/NativeIO.java b/vespajlib/src/main/java/com/yahoo/io/NativeIO.java index f69bdb4e3dd..109b7ff7943 100644 --- a/vespajlib/src/main/java/com/yahoo/io/NativeIO.java +++ b/vespajlib/src/main/java/com/yahoo/io/NativeIO.java @@ -54,19 +54,28 @@ public class NativeIO { } /** - * Will hint the OS that this is will not be accessed again and should hence be dropped from the buffer cache. + * Will hint the OS that data read so far will not be accessed again and should hence be dropped from the buffer cache. * @param fd The file descriptor to drop from buffer cache. */ - public void dropFileFromCache(FileDescriptor fd) { - try { - fd.sync(); - } catch (SyncFailedException e) { - logger.warning("Sync failed while dropping cache: " + e.getMessage()); + public void dropPartialFileFromCache(FileDescriptor fd, long offset, long len, boolean sync) { + if (sync) { + try { + fd.sync(); + } catch (SyncFailedException e) { + logger.warning("Sync failed while dropping cache: " + e.getMessage()); + } } if (initialized) { - posix_fadvise(getNativeFD(fd), 0, 0, POSIX_FADV_DONTNEED); + posix_fadvise(getNativeFD(fd), offset, len, POSIX_FADV_DONTNEED); } } + /** + * Will hint the OS that this is will not be accessed again and should hence be dropped from the buffer cache. + * @param fd The file descriptor to drop from buffer cache. + */ + public void dropFileFromCache(FileDescriptor fd) { + dropPartialFileFromCache(fd, 0, 0, true); + } /** * Will hint the OS that this is will not be accessed again and should hence be dropped from the buffer cache. |