D7995: KDevelop: address dirwatching inefficiency (WIP/PoC)

René J.V. Bertin noreply at phabricator.kde.org
Wed Sep 27 15:17:20 UTC 2017


rjvbb added a comment.


  FreeBSD has kqueue which does sit at least partly in the kernel, no? Its main problem is that it uses resources that are limited (severely on some BSD versions). OS X has this same API, but fortunately it now also has FSEvents (or else I wouldn't have given up the idea to make dirwatching optional).
  
  I'm still applying a local patch to Qt5 which was useful for me under Qt4:
  
    diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_kqueue.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_kqueue.cpp
    index 4f6c83e..f53caf8 100644
    --- a/qtbase/src/corelib/io/qfilesystemwatcher_kqueue.cpp
    +++ b/qtbase/src/corelib/io/qfilesystemwatcher_kqueue.cpp
    @@ -101,6 +101,7 @@ QStringList QKqueueFileSystemWatcherEngine::addPaths(const QStringList &paths,
         while (it.hasNext()) {
             QString path = it.next();
             int fd;
    +        errno = 0;
     #if defined(O_EVTONLY)
             fd = qt_safe_open(QFile::encodeName(path), O_EVTONLY);
     #else
    @@ -109,12 +110,26 @@ QStringList QKqueueFileSystemWatcherEngine::addPaths(const QStringList &paths,
             if (fd == -1) {
                 perror("QKqueueFileSystemWatcherEngine::addPaths: open");
                 continue;
    +        } else {
    +            if (errno) {
    +                perror("QKqueueFileSystemWatcherEngine::addPaths: open returned valid descriptor but");
    +                ::close(fd);
    +                continue;
    +            }
             }
    +        errno = 0;
             if (fd >= (int)FD_SETSIZE / 2 && fd < (int)FD_SETSIZE) {
                 int fddup = fcntl(fd, F_DUPFD, FD_SETSIZE);
                 if (fddup != -1) {
                     ::close(fd);
                     fd = fddup;
    +            } else {
    +                perror("QKqueueFileSystemWatcherEngine::addPaths: fddup");
    +                if (errno = EMFILE) {
    +                    // it seems wise not to insist when we just hit the open file limit
    +                    ::close(fd);
    +                    continue;
    +                }
                 }
             }
             fcntl(fd, F_SETFD, FD_CLOEXEC);

REPOSITORY
  R32 KDevelop

REVISION DETAIL
  https://phabricator.kde.org/D7995

To: rjvbb, #kdevelop, mwolff
Cc: arrowdodger, kfunk, dfaure, mwolff, brauch, kdevelop-devel, geetamc, Pilzschaf, akshaydeo, surgenight
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170927/2a79f924/attachment.html>


More information about the KDevelop-devel mailing list