[kde-freebsd] QFilesSystemWatcher instead of polling/FAM
Tijl Coosemans
tijl at coosemans.org
Thu Jul 8 23:47:51 CEST 2010
On Thursday 08 July 2010 01:19:26 Jason E. Hale wrote:
> On Friday, June 25, 2010 12:37:53 Tijl Coosemans wrote:
>> 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.
>
> I tried this patch with KDE 4.4.4 and 4.4.5 on FreeBSD 8.0/i386 and
> plasma-desktop crashes every time I try to open a file through dolphin
> that I haven't used recently. If I run plasma-desktop in the
> foreground I get many lines like this when I open a file:
>
> QFileSystemWatcher: failed to add paths: /usr/home/Jason/.kde4/share/apps/RecentDocuments
> QFileSystemWatcher: failed to add paths: /usr/home/Jason/.kde4/share/apps/RecentDocuments
> QFileSystemWatcher: failed to add paths: /usr/home/Jason/.kde4/share/apps/RecentDocuments
> QFileSystemWatcher: failed to add paths: /usr/home/Jason/.kde4/share/apps/RecentDocuments
> QFileSystemWatcher: failed to add paths: /usr/home/Jason/.kde4/share/apps/RecentDocuments
> QFileSystemWatcher: failed to add paths: /usr/home/Jason/.kde4/share/apps/RecentDocuments
> QFileSystemWatcher: failed to add paths: /usr/home/Jason/.kde4/share/apps/RecentDocuments
> Illegal instruction: 4 (core dumped)
Could you give the attached patch a try? It replaces the previous
patch.
-------------- 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-07-08 23:05:23.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
}
}
@@ -1595,8 +1593,7 @@
EntryMap::Iterator it;
it = m_mapEntries.find(path);
if(it != m_mapEntries.end()) {
- Entry entry = *it; // deep copy to not point to uninialized data (can happen inside emitEvent() )
- Entry *e = &entry;
+ Entry *e = &(*it);
e->dirty = true;
int ev = scanEntry(e);
if (ev != NoChange)
--- 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