From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.devel Subject: gfile-based file notifications are not immediate Date: Sat, 25 Oct 2014 13:17:29 -0700 Message-ID: <87mw8jg9a1.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1414270504 24063 80.91.229.3 (25 Oct 2014 20:55:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 25 Oct 2014 20:55:04 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 25 22:54:58 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 1Xi8MU-0003Yk-Fw for ged-emacs-devel@m.gmane.org; Sat, 25 Oct 2014 22:54:58 +0200 Original-Received: from localhost ([::1]:54610 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi8MU-0003q4-7X for ged-emacs-devel@m.gmane.org; Sat, 25 Oct 2014 16:54:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi8MC-0003n1-H6 for emacs-devel@gnu.org; Sat, 25 Oct 2014 16:54:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xi8M6-0003DD-8O for emacs-devel@gnu.org; Sat, 25 Oct 2014 16:54:40 -0400 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:52919) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi8M6-0003D9-4j for emacs-devel@gnu.org; Sat, 25 Oct 2014 16:54:34 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id EC37E20788 for ; Sat, 25 Oct 2014 16:54:31 -0400 (EDT) Original-Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Sat, 25 Oct 2014 16:54:31 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:from:to:subject:date :message-id:mime-version:content-type; s=smtpout; bh=39aRVyLqtGp pDDUNgERstEyGecY=; b=QXrhz6RAwzoJUwXSPqZFN0kOvgujuf8KBYmnq8NUd5V +C1ACA4vkLZJ6McoyehFlrHSoCQOrVmfogKlERsycXG7XPHQSb4YfkppDFYx9IOu rJn5S0DU5CUyk5KumODTbZy7HCnnOK9d4rcVOpDanRLK4MqE4swgS/LzsOdZGJXg = X-Sasl-enc: VQSO8iiMuQ4Db9LRKOGNnGQC8RaGvElN82MOAE2r7woK 1414270471 Original-Received: from shorty.local (unknown [23.243.192.221]) by mail.messagingengine.com (Postfix) with ESMTPA id A33DDC0000E for ; Sat, 25 Oct 2014 16:54:31 -0400 (EDT) Original-Received: from ip6-localhost ([::1] helo=shorty.local) by shorty.local with esmtp (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1Xi8M2-0002yR-CU for emacs-devel@gnu.org; Sat, 25 Oct 2014 13:54:30 -0700 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.111.4.25 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:175838 Archived-At: Hi. In the last few days I started several threads about various details of file notification and auto-revert behavior. This one is about some incorrect behavior of notifications using the 'gfile' (gio from glib) backend. 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. Even if you kick the event loop in time, the notification is still delayed a few seconds (I verified this with some test code, outside of emacs; can post if anybody wants it). THIS is a separate issue that is likely a bug in glib. On Linux it uses inotify internally, so if one was using Linux, would there be any reason to use this notification scheme instead of using inotify directly? Are there OSs where emacs supports notifications ONLY through glib? Once again, I'm not posting to the bug tracker yet. dima