[kde-freebsd] QFilesSystemWatcher instead of polling/FAM

Tijl Coosemans tijl at coosemans.org
Fri Jun 25 18:37:53 CEST 2010


Hi,

KDE currently uses polling to detect file and directory changes on
FreeBSD, which can use up cpu time (and laptop battery power). The
kded4 process seems to make heavy use of this and currently
continuously consumes about 5% of my cpu and often causes it to be
throttled up by powerd.

I've attached a patch that makes KDE use QFileSystemWatcher on FreeBSD
which uses kqueue instead of stat. I've been using it for the past few
days and it seems to work rather well.

One thing I'm not sure about is whether it works with NFS, so it could
use some more testing. If you'd like to test it, replace
/usr/ports/x11/kdelibs4/files/patch-kio-kio-kdirwatch.cpp with the
attached patch and reinstall kdelibs.
-------------- next part --------------
--- kio/CMakeLists.txt.orig	2010-06-24 14:08:17.000000000 +0200
+++ kio/CMakeLists.txt	2010-06-24 14:08:42.000000000 +0200
@@ -28,11 +28,9 @@
 
 check_include_files(sys/inotify.h SYS_INOTIFY_H_FOUND)
 macro_bool_to_01(SYS_INOTIFY_H_FOUND HAVE_SYS_INOTIFY_H)
-if(WIN32)
- # currently for win32 only --> enable it for all in 4.1?
- option(USE_QFILESYSTEMWATCHER "Use QFileSystemWatcher instead polling for KDirWatch" ON)
- macro_bool_to_01(USE_QFILESYSTEMWATCHER HAVE_QFILESYSTEMWATCHER)
-endif(WIN32)
+
+option(USE_QFILESYSTEMWATCHER "Use QFileSystemWatcher instead polling for KDirWatch" ON)
+macro_bool_to_01(USE_QFILESYSTEMWATCHER HAVE_QFILESYSTEMWATCHER)
 
 configure_file(kio/config-kdirwatch.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kio/config-kdirwatch.h )
 configure_file(kio/config-strigi.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kio/config-strigi.h )
--- kio/kio/kdirwatch.cpp.orig	2010-02-26 19:30:10.000000000 +0100
+++ kio/kio/kdirwatch.cpp	2010-06-24 14:46:54.000000000 +0200
@@ -91,12 +91,10 @@
   } else if (method == "QFSWatch") {
     return KDirWatchPrivate::QFSWatch;
   } else {
-#ifdef Q_OS_WIN
-    return KDirWatchPrivate::QFSWatch;
-#elif defined(Q_OS_FREEBSD)
-    return KDirWatchPrivate::Stat;
-#else
+#ifdef Q_OS_LINUX
     return KDirWatchPrivate::INotify;
+#else
+    return KDirWatchPrivate::QFSWatch;
 #endif
   }
 }
--- kio/kio/kdirwatch_p.h.orig	2010-06-24 15:21:37.000000000 +0200
+++ kio/kio/kdirwatch_p.h	2010-06-24 15:21:58.000000000 +0200
@@ -102,7 +102,7 @@
   QHash<QString,QFileSystemWatcher*> m_paths;
 };
 #else
-typedef KFileSystemWatcher QFileSystemWatcher;
+typedef QFileSystemWatcher KFileSystemWatcher;
 #endif
 #endif
 


More information about the kde-freebsd mailing list