From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: gfile-based file notifications are not immediate Date: Sun, 26 Oct 2014 18:02:49 +0200 Message-ID: <83mw8i4y52.fsf@gnu.org> References: <87mw8jg9a1.fsf@secretsauce.net> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1414339417 14077 80.91.229.3 (26 Oct 2014 16:03:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 26 Oct 2014 16:03:37 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dima Kogan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 26 17:03:30 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XiQHx-00013X-IQ for ged-emacs-devel@m.gmane.org; Sun, 26 Oct 2014 17:03:29 +0100 Original-Received: from localhost ([::1]:57216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XiQHx-0004mJ-5h for ged-emacs-devel@m.gmane.org; Sun, 26 Oct 2014 12:03:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XiQHe-0004mA-VK for emacs-devel@gnu.org; Sun, 26 Oct 2014 12:03:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XiQHY-0001dY-5q for emacs-devel@gnu.org; Sun, 26 Oct 2014 12:03:10 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:43548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XiQHX-0001dO-UA for emacs-devel@gnu.org; Sun, 26 Oct 2014 12:03:04 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0NE200I006Y1YU00@a-mtaout20.012.net.il> for emacs-devel@gnu.org; Sun, 26 Oct 2014 18:03:02 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NE200IS7791NH70@a-mtaout20.012.net.il>; Sun, 26 Oct 2014 18:03:01 +0200 (IST) In-reply-to: <87mw8jg9a1.fsf@secretsauce.net> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.166 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:175862 Archived-At: > From: Dima Kogan > Date: Sat, 25 Oct 2014 13:17:29 -0700 > > As in the inotify thread, I set up a simple test. I built emacs using > > ./configure --with-file-notification=inotify > > I then ran > > ./emacs --eval "`cat /tmp/tstnotify.el`" -Q -nw > > with tstnotify.el being > > (progn > (require 'filenotify) > > (dolist (fil '("/tmp/tst1" "/tmp/tst2")) > (file-notify-add-watch fil '(change attribute-change) > (lambda (event) > (message "notify event %s" event))) > (find-file fil)) > (switch-to-buffer "*Messages*")) > > > Here I ask for notifications for two files, and print out the events as > they come in. While emacs is running this way, I modify those two files > using an external tool. I would expect to see modification events for > both of these files, as soon as these modifications happen. Instead, the > notifications come in either 30 seconds later, or whenever anything goes > through emacs's input queue. So the notification is greatly delayed if > the user is not touching their emacs. > > The reason is that when emacs is idle, it's blocking in the pselect() > call in xg_select() in process.c. pselect() is an operating-system call, > not a glib one. Later on in xg_select() there's some code to kick the > glib event loop, but as long as we're sitting in the pselect(), that > secondary event loop remains untouched. Maybe I'm confused, but are you saying that even though you specifically requested for inotify notifications, and even though the configure script shows Does Emacs use a file notification library? yes -lglibc (inotify) when it finishes, Emacs still uses glib file notifications, and the functions in inotify.c are never called? When functions in inotify.c are called, they add a file descriptor to the set monitored by pselect (see the call to add_read_fd in inotofy.c), so we shouldn't be waiting for glib event loop, I think. Oh, maybe this all happens because ytour build is with GTK, and therefore HAVE_GLIB is defined, so we call xg_select instead (I think because some unwanted interference between these two mechanisms). So perhaps try building without GTK (or any other optional features that pull in glib).