KDE/kdelibs

Jakub Stachowski qbast at go2.pl
Thu May 26 13:35:14 CEST 2005


SVN commit 418337 by qbast:

Give a hint to kernel about sequential way of copy/get operations
using posix_fadvise. It is for now only supported on linux kernels
>=2.5.60 and new glibc so configure check is needed.
This gives me 15% speedup on copying big file (600mb) on the same 
partition due to 2x bigger readahead.
Another possible 'hint' to consider is POSIX_FADV_DONTNEED used
to free cache associated with file (or file region). Possible use
would be trash:/ ioslave (if you delete file then it probably won't be 
accessed soon) or copying big files (to avoid trashing cache when copying
for example big .iso)

CCMAIL: kde-optimize at kde.org



 M  +2 -0      configure.in.in  
 M  +10 -0     kioslave/file/file.cc  


--- trunk/KDE/kdelibs/configure.in.in #418336:418337
@@ -242,6 +242,8 @@
   AC_DEFINE(HAVE_MITSHM,1,[Define if you want MIT-SHM support])
 fi
 
+AC_CHECK_FUNC(posix_fadvise,[AC_DEFINE(HAVE_FADVISE,1,[Define is 
posix_fadvise is supported] )])
+
 AC_SUBST(ICE_SUBDIR, 'ICE')
 AC_SUBST(ICE_RLIB, 'ICE/libkICE.la')
 
--- trunk/KDE/kdelibs/kioslave/file/file.cc #418336:418337
@@ -203,6 +203,10 @@
         return;
     }
 
+#ifdef HAVE_FADVISE
+    posix_fadvise( fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+#endif
+
     // Determine the mimetype of the file to be retrieved, and emit it.
     // This is mandatory in all slaves (for KRun/BrowserRun to work).
     KMimeType::Ptr mt = KMimeType::findByURL( url, buff.st_mode, true /* 
local URL */ );
@@ -542,6 +546,9 @@
 	return;
     }
 
+#ifdef HAVE_FADVISE
+    posix_fadvise(src_fd,0,0,POSIX_FADV_SEQUENTIAL);
+#endif
     // WABA: Make sure that we keep writing permissions ourselves,
     // otherwise we can be in for a surprise on NFS.
     mode_t initialMode;
@@ -562,6 +569,9 @@
         return;
     }
 
+#ifdef HAVE_FADVISE
+    posix_fadvise(dest_fd,0,0,POSIX_FADV_SEQUENTIAL);
+#endif
     totalSize( buff_src.st_size );
 
     KIO::filesize_t processed_size = 0;



More information about the Kde-optimize mailing list