On Mon, 2003-11-03 at 01:07, Neil Conway wrote:
> (1) As Manfred originally noted, when we advance to a new XLOG segment,
> we can use POSIX_FADV_DONTNEED to let the kernel know we won't be
> accessing the old WAL segment anymore. I've attached a quick kludge of a
> patch that implements this. I haven't done any benchmarking of it yet,
> though (comments or benchmark results are welcome).

Woops, the patch is attached.

-Neil

Index: src/backend/access/transam/xlog.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/access/transam/xlog.c,v
retrieving revision 1.125
diff -c -r1.125 xlog.c
*** src/backend/access/transam/xlog.c	27 Sep 2003 18:16:35 -0000	1.125
--- src/backend/access/transam/xlog.c	3 Nov 2003 02:46:57 -0000
***************
*** 1043,1048 ****
--- 1043,1060 ----
  			 */
  			if (openLogFile >= 0)
  			{
+ 				/*
+ 				 * Let the kernel know that we're not going to need
+ 				 * this WAL segment anymore, so there's no need to
+ 				 * keep it in the I/O cache
+ 				 */
+ 				if (posix_fadvise(openLogFile, 0, 0, POSIX_FADV_DONTNEED) != 0)
+ 				{
+ 					ereport(WARNING,
+ 							(errcode_for_file_access(),
+ 							 errmsg("could not posix_fadvise() log file %u: %m", openLogId)));
+ 				}
+ 
  				if (close(openLogFile) != 0)
  					ereport(PANIC,
  							(errcode_for_file_access(),
***************
*** 1159,1164 ****
--- 1171,1188 ----
  			if (openLogFile >= 0 &&
  			 !XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg))
  			{
+ 				/*
+ 				 * Let the kernel know that we're not going to need
+ 				 * this WAL segment anymore, so there's no need to
+ 				 * keep it in the I/O cache
+ 				 */
+ 				if (posix_fadvise(openLogFile, 0, 0, POSIX_FADV_DONTNEED) != 0)
+ 				{
+ 					ereport(WARNING,
+ 							(errcode_for_file_access(),
+ 							 errmsg("could not posix_fadvise() log file %u: %m", openLogId)));
+ 				}
+ 
  				if (close(openLogFile) != 0)
  					ereport(PANIC,
  							(errcode_for_file_access(),
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to