From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.bugs Subject: bug#18958: 25.0.50; auto-revert-mode reacts slowly even if using an event-driven backend Date: Wed, 05 Nov 2014 11:01:12 -0800 Message-ID: <878ujpcw07.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1415214150 19006 80.91.229.3 (5 Nov 2014 19:02:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Nov 2014 19:02:30 +0000 (UTC) To: 18958@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 05 20:02:20 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1Xm5qV-000570-G6 for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Nov 2014 20:02:19 +0100 Original-Received: from localhost ([::1]:48105 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm5qV-0000ip-6G for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Nov 2014 14:02:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm5qM-0000ih-Q1 for bug-gnu-emacs@gnu.org; Wed, 05 Nov 2014 14:02:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xm5qF-0003YX-2V for bug-gnu-emacs@gnu.org; Wed, 05 Nov 2014 14:02:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm5qE-0003YQ-VD for bug-gnu-emacs@gnu.org; Wed, 05 Nov 2014 14:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Xm5qE-0006fK-LD for bug-gnu-emacs@gnu.org; Wed, 05 Nov 2014 14:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Nov 2014 19:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 18958 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.141521409425583 (code B ref -1); Wed, 05 Nov 2014 19:02:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Nov 2014 19:01:34 +0000 Original-Received: from localhost ([127.0.0.1]:50349 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xm5pm-0006eY-3Z for submit@debbugs.gnu.org; Wed, 05 Nov 2014 14:01:34 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:51636) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xm5pj-0006eQ-Vj for submit@debbugs.gnu.org; Wed, 05 Nov 2014 14:01:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xm5pe-0002zi-8D for submit@debbugs.gnu.org; Wed, 05 Nov 2014 14:01:31 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:39983) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm5pe-0002zc-5v for submit@debbugs.gnu.org; Wed, 05 Nov 2014 14:01:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm5pZ-0000aF-0U for bug-gnu-emacs@gnu.org; Wed, 05 Nov 2014 14:01:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xm5pT-0002sg-Sh for bug-gnu-emacs@gnu.org; Wed, 05 Nov 2014 14:01:20 -0500 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:49474) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm5pT-0002ro-FE for bug-gnu-emacs@gnu.org; Wed, 05 Nov 2014 14:01:15 -0500 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id AC75320706 for ; Wed, 5 Nov 2014 14:01:13 -0500 (EST) Original-Received: from frontend2 ([10.202.2.161]) by compute6.internal (MEProxy); Wed, 05 Nov 2014 14:01:13 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=x-sasl-enc:from:to:subject:date:message-id:mime-version :content-type; s=mesmtp; bh=urVA5/lrmutaZT24g3D3dmYihys=; b=CfMJ LEdRM5vliBBx0BqW1hZgrFhkHG6pzUHFduw1GlsDVPwUhERxP6YYowU+AgiPtYuv 39cUjEaNCGYWlz/TJ6UZRLVHiQ69k/MSqMINNPgtUPpza22enKKmbi1beg7s2/5+ 4Y3tM5Ng42ECejIoBgZGB/sS2MGyNyOgLhZAt5E= 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=urVA5/lrmut aZT24g3D3dmYihys=; b=ICSL10XGg6ZACd+YejGE/T66E9EDGHy2hfnhEMO5DrQ lAq7/Kr6CubX7iHyaJq0Fak/SFYVfWflJmD+tcjbrikWnxGV1lKjkCuQ13fa7w2w z2FV4WVVZmhNDDl6DYJQvSWmVIfqouZSaa+CK+PGxQn8e+FX7N87YFdFTNeOZdcI = X-Sasl-enc: nEW11O+zykyz4LeVlavBZ0uH1f9n3CBNXBB/hbhkbbIP 1415214073 Original-Received: from shorty.local (unknown [76.91.145.213]) by mail.messagingengine.com (Postfix) with ESMTPA id 648B268019B for ; Wed, 5 Nov 2014 14:01:13 -0500 (EST) Original-Received: from dima by shorty.local with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1Xm5pQ-0007v5-BS for bug-gnu-emacs@gnu.org; Wed, 05 Nov 2014 11:01:12 -0800 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:95563 --=-=-= Content-Type: text/plain This is a tracker entry for a report and patch in an emacs-devel mailing list thread: http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00727.html The issue is that auto-revert-mode reacts to modifications on a timer, even if its backend is event-driven. There is a prototype patch in that thread, attached here also. On Linux, the two available backends have issues, so this patch wouldn't be completely effective until those are resolved. The gfile backend has a problem where emacs isn't using glib correctly, and the gfile backend itself, in turn, adds artificial delays in how it deals with inotify. Those are discussed (and partly patched) here: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18861 The inotify backend has an issue where it doesn't deal with more than one monitored file in a directory correctly: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18880 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-auto-revert-mode-can-now-revert-immediately-in-respo.patch >From 567d8469dfb143786890c65de58bf2ce887e9ebd Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Fri, 24 Oct 2014 19:44:43 -0700 Subject: [PATCH] auto-revert-mode can now revert immediately in response to a change event If we have file notifications, we want to update the auto-revert buffers immediately when a notification occurs. Since file updates can happen very often, we want to skip some revert operations so that we don't spend all our time reverting the buffer. We do this by reverting immediately in response to the first in a flurry of notifications. We suppress subsequent notifications until the next time `auto-revert-buffers' is called (this happens on a timer with a period set by `auto-revert-interval'). --- lisp/autorevert.el | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/lisp/autorevert.el b/lisp/autorevert.el index f1074e2..7de6ec1 100644 --- a/lisp/autorevert.el +++ b/lisp/autorevert.el @@ -531,6 +531,34 @@ will use an up-to-date value of `auto-revert-interval'" ;; Fallback to file checks. (set (make-local-variable 'auto-revert-use-notify) nil)))) + + +;; If we have file notifications, we want to update the auto-revert buffers +;; immediately when a notification occurs. Since file updates can happen very +;; often, we want to skip some revert operations so that we don't spend all our +;; time reverting the buffer. +;; +;; We do this by reverting immediately in response to the first in a flurry of +;; notifications. We suppress subsequent notifications until the next time +;; `auto-revert-buffers' is called (this happens on a timer with a period set by +;; `auto-revert-interval'). +(defvar auto-revert-buffers-counter 1 + "Incremented each time `auto-revert-buffers' is called") +(defvar auto-revert-buffers-counter-lockedout 0 + "Buffer-local value to indicate whether we should immediately +update the buffer on a notification event or not. If + + (= auto-revert-buffers-counter-lockedout + auto-revert-buffers-counter) + +then the updates are locked out, and we wait until the next call +of `auto-revert-buffers' to revert the buffer. If no lockout is +present, then we revert immediately and set the lockout, so that +no more reverts are possible until the next call of +`auto-revert-buffers'") +(make-variable-buffer-local 'auto-revert-buffers-counter-lockedout) + + (defun auto-revert-notify-handler (event) "Handle an EVENT returned from file notification." (with-demoted-errors @@ -566,6 +594,14 @@ will use an up-to-date value of `auto-revert-interval'" (file-name-nondirectory buffer-file-name))))) ;; Mark buffer modified. (setq auto-revert-notify-modified-p t) + + ;; Revert the buffer now if we're not locked out + (when (/= auto-revert-buffers-counter-lockedout + auto-revert-buffers-counter) + (auto-revert-handler) + (setq auto-revert-buffers-counter-lockedout + auto-revert-buffers-counter)) + ;; No need to check other buffers. (cl-return))))))))) @@ -686,6 +722,10 @@ are checked first the next time this function is called. This function is also responsible for removing buffers no longer in Auto-Revert mode from `auto-revert-buffer-list', and for canceling the timer when no buffers need to be checked." + + (setq auto-revert-buffers-counter + (1+ auto-revert-buffers-counter)) + (save-match-data (let ((bufs (if global-auto-revert-mode (buffer-list) -- 2.0.0 --=-=-=--