[kde-freebsd] QFilesSystemWatcher instead of polling/FAM

Tijl Coosemans tijl at coosemans.org
Fri Jun 25 23:15:20 CEST 2010


On Friday 25 June 2010 19:41:11 Kris Moore wrote:
> On 06/25/2010 12:37, 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.
>
> Just built with this patch here. It does greatly improve my kdeinit4
> processes, went from a constant 8-10% to 0-1%.
>
> However, it does mess up NFS. When browsing my NFS mounts it doesn't
> show any directory/file changes until I manually refresh the view.
> Is this something fixable?

It can be fixed in Qt or in KDE. Both already provide polling as a
fallback and it would be easy to add some logic similar to what
devel/gamin does (call statfs(2) on the given path and use kqueue when
MNT_LOCAL is set, polling otherwise).

For now, you can also add the following to your ~/.kderc:

[DirWatch]
nfsPreferredMethod=Stat


More information about the kde-freebsd mailing list