From owner-freebsd-questions@FreeBSD.ORG Mon Oct 25 10:03:13 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F9301065674 for ; Mon, 25 Oct 2010 10:03:13 +0000 (UTC) (envelope-from freebsd-questions@m.gmane.org) Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mx1.freebsd.org (Postfix) with ESMTP id E9E878FC12 for ; Mon, 25 Oct 2010 10:03:12 +0000 (UTC) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PAJtU-0000c9-B6 for freebsd-questions@freebsd.org; Mon, 25 Oct 2010 12:03:08 +0200 Received: from lara.cc.fer.hr ([161.53.72.113]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 25 Oct 2010 12:03:08 +0200 Received: from ivoras by lara.cc.fer.hr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 25 Oct 2010 12:03:08 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-questions@freebsd.org From: Ivan Voras Date: Mon, 25 Oct 2010 12:02:57 +0200 Lines: 24 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: lara.cc.fer.hr User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.1.12) Gecko/20101018 Thunderbird/3.0.8 In-Reply-To: X-Enigmail-Version: 1.0.1 X-Mailman-Approved-At: Mon, 25 Oct 2010 11:09:47 +0000 Subject: Re: EVFILT_VNODE doesn't scale to large directory trees? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Oct 2010 10:03:13 -0000 On 10/25/10 03:05, Kenton Varda wrote: > Hi all, > > I am trying to write some code which monitors a possibly-large directory > tree for changes. Specifically, it's a build system, and I want it to > automatically start rebuilding whenever I modify a source file. > > So far the approach I've taken is to use EVFILT_VNODE to watch every file > and directory in the tree. This seems to work OK so far, but it worries me > that I have to open() every single file. When I ran the same code on > Darwin, it promptly hit the open file descriptor limit, and I'm worried that > FreeBSD will do the same on larger code trees. > > Is there any better way to accomplish this? Hate to say it, but Linux's > inotify() seems more scalable here. From what I can tell from the docs, it > doesn't require opening the watched files and it will even watch all files > in a directory with one call. Short answer: no. Long answer: There should be. There were past discussions on writing such a facility to e.g. receive events for all files on per-mountpoint basis (which you could filter...), but we're not there yet.