Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Mar 2006 09:23:32 -0500
From:      Chuck Swiger <cswiger@mac.com>
To:        Alex Dupre <ale@FreeBSD.org>
Cc:        David Syphers <dsyphers@u.washington.edu>, freebsd-ports@freebsd.org
Subject:   Re: gamin opens too many files
Message-ID:  <442A9864.9070500@mac.com>
In-Reply-To: <442A2779.4070708@FreeBSD.org>
References:  <200603282023.51439.dsyphers@u.washington.edu> <442A2779.4070708@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Alex Dupre wrote:
> David Syphers wrote:
>> I recently was getting messages about maxing out the number of open files on 
>> my system, and discovered that gam_server has gone crazy. Right after 
>> booting, opening KDE, I have nearly 2600 open files on my computer, and 2200 
>> of those are opened by gam_server, according to fstat. And clearly that 
>> number can go up to nearly 8000, as I've got kern.maxfiles at 8136.
> 
> That's absolutely normal for KDE. It will monitor many directories
> (/etc, your home, your desktop, some share dirs), so you have to
> increase the kern.maxfiles parameter as suggested by gamin's pkg-message.

Whoever wrote gamin should read "excessive use of fstat() considered harmful
when using distributed filesystems".  :-)

I don't expect to run KDE/gamin myself, so I'm not going write a specific patch,
but someone interested in fixing gamin to not consume thousands of file
descriptors could start with:

    struct rlimit rl;

    if (getrlimit(RLIMIT_NOFILE, 0) == 0) {
        printf("number of file descriptors available: %d\n", rl.rlim_cur);
    } else {
        perror("FATAL: getrlimit() call failed");
        exit(EX_OSERR);
    }

...and pay attention to rl.rlim_cur-- ie, monitor no more files than 80% of that
value.  If this gam_server is running with superuser permissions (why?), perhaps
consuming up to 50% of rl.rlim_max might not be completely unreasonable.

-- 
-Chuck



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?442A9864.9070500>