[kde-freebsd] QFilesSystemWatcher instead of polling/FAM

Tijl Coosemans tijl at coosemans.org
Tue Jun 29 16:44:36 CEST 2010


On Tuesday 29 June 2010 14:41:00 Alberto Villa wrote:
> 2010/6/25 Tijl Coosemans <tijl at coosemans.org>:
>> 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.
> 
> the qt page on this has a warning:
> 
> The act of monitoring files and directories for modifications
> consumes system resources. This implies there is a limit to the
> number of files and directories your process can monitor
> simultaneously. On Mac OS X 10.4 and all BSD variants, for example,
> an open file descriptor is required for each monitored file. Some
> system limits the number of open file descriptors to 256 by default.
> This means that addPath() and addPaths() will fail if your process
> tries to add more than 256 files or directories to the file system
> monitor. Also note that your process may have other file descriptors
> open in addition to the ones for files being monitored, and these
> other open descriptors also count in the total.

It's true that kqueue uses open file descriptors, but the limit is far
higher than 256. On my system with only 1G ram the default is:

kern.maxfiles: 12328
kern.maxfilesperproc: 11095

> when it fails, on mac os it falls back to another backend, but it
> doesn't say anything about bsd... have you considered this problem?

As far as I can see there's no fallback on Mac OS X. It uses exactly
the same code as FreeBSD. There is some code for another backend on
OS X 10.5, but that code is currently disabled.

It would be nice if polling was used as a fallback though. That's what
gamin does. I've been looking into making a few small improvements to
QFileSystemWatcher. I'll add it to the list.

For now, I don't think the open file limit is really a problem. The
main problem is that kqueue doesn't work on network file systems such
as NFS and SMBFS, and QFileSystemWatcher doesn't know about that.


More information about the kde-freebsd mailing list