(trunk libT) #3371 "experimental use of F_NOCACHE to ameliorate inactive memory on OS X"

This commit is contained in:
Charles Kerr 2010-06-27 17:44:34 +00:00
parent 77aaeb932b
commit acd27a8c3b
1 changed files with 18 additions and 0 deletions

View File

@ -399,6 +399,24 @@ TrOpenFile( tr_session * session,
}
#endif
#if defined( SYS_DARWIN )
/**
* 1. Enable readahead for reasons described above w/POSIX_FADV_SEQUENTIAL.
*
* 2. Disable OS-level caching due to user reports of adverse effects of
* excessive inactive memory. However this is experimental because
* previous attempts at this have *also* had adverse effects (see r8198)
*
* It's okay for this to fail silently, so don't let it affect errno
*/
{
const int err = errno;
fcntl( file->fd, F_NOCACHE, 1 );
fcntl( file->fd, F_RDAHEAD, 1 );
errno = err;
}
#endif
return 0;
}