[IO] Implement FileOptions.SequentialScan for Mac/BSD
authorMarius Ungureanu <marius.ungureanu@xamarin.com>
Thu, 29 Sep 2016 23:34:14 +0000 (02:34 +0300)
committerMarius Ungureanu <marius.ungureanu@xamarin.com>
Thu, 29 Sep 2016 23:34:14 +0000 (02:34 +0300)
The F_RDAHEAD define seems to be introduced in BSD, being the equivalent of POSIX_FADV_SEQUENTIAL.
This should improve sequential scanning speed by having the read ahead buffer doubled.

mono/io-layer/io.c

index 661067dc7b27b1461c9ee63858da5c519e0256f2..4ba61f4955b36a65d0ce1d6eb2e3ea8b6980899f 100644 (file)
@@ -1763,6 +1763,9 @@ gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
                posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
        if (attrs & FILE_FLAG_RANDOM_ACCESS)
                posix_fadvise (fd, 0, 0, POSIX_FADV_RANDOM);
+#elif defined(PLATFORM_MACOSX) || defined(PLATFORM_BSD)
+       if (attrs & FILE_FLAG_SEQUENTIAL_SCAN)
+               fcntl(fd, F_RDAHEAD, 1);
 #endif
        
 #ifndef S_ISFIFO