Skip to content

Commit

Permalink
Add posix_fadvise(FADV_DONTNEED) to flush buffered pages
Browse files Browse the repository at this point in the history
Summary:
When InnoDB opens a .ibd or log file in O_DIRECT mode, request the os to
flush the buffer cache. Otherwise, direct IO is serialized when buffered
pages for the file existing within the filesystem cache.

Reviewed By: alxyang

Differential Revision: D5100237

fbshipit-source-id: bbbd3db
  • Loading branch information
Herman Lee authored and facebook-github-bot committed May 22, 2017
1 parent ad90bf7 commit ab9d60b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions storage/innobase/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ Created 10/21/1995 Heikki Tuuri
#include <libaio.h>
#endif

/* Ignore posix_fadvise() on those platforms where it does not exist */
#if defined __WIN__
# define posix_fadvise(fd, offset, len, advice) /* nothing */
#endif /* __WIN__ */

#define max(a,b) ((a)>(b)?(a):(b))

/* Configurable histogram step sizes */
Expand Down Expand Up @@ -1703,6 +1708,11 @@ os_file_set_nocache(
}
return -1;
}
#ifdef POSIX_FADV_DONTNEED
/* Request the filesystem to flush cached pages. Otherwise,
DIRECTIO requests are serialized. */
posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
#endif /* POSIX_FADV_DONTNEED */
#endif /* defined(UNIV_SOLARIS) && defined(DIRECTIO_ON) */
return 0;
}
Expand Down

0 comments on commit ab9d60b

Please sign in to comment.