From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: Remote display-time-mail-file Date: Thu, 30 Sep 2010 15:07:34 +0200 Message-ID: <878w2jv0q1.fsf@gmx.de> References: <837hil355j.fsf@gnu.org> <83zkvh1m4j.fsf@gnu.org> <87pqwdbdxs.fsf@gmx.de> <83r5gs1th2.fsf@gnu.org> <87ocbwnmkz.fsf@gmx.de> <87aangnl1j.fsf@gmx.de> <83sk18yrj6.fsf@gnu.org> <83r5grzaei.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1285852083 28537 80.91.229.12 (30 Sep 2010 13:08:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 30 Sep 2010 13:08:03 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 30 15:07:58 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P1Ird-0004Qh-SW for ged-emacs-devel@m.gmane.org; Thu, 30 Sep 2010 15:07:58 +0200 Original-Received: from localhost ([127.0.0.1]:43818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P1Ird-0003p9-8S for ged-emacs-devel@m.gmane.org; Thu, 30 Sep 2010 09:07:57 -0400 Original-Received: from [140.186.70.92] (port=43134 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P1IrS-0003mq-PU for emacs-devel@gnu.org; Thu, 30 Sep 2010 09:07:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P1IrQ-0003Up-B8 for emacs-devel@gnu.org; Thu, 30 Sep 2010 09:07:46 -0400 Original-Received: from mailout-de.gmx.net ([213.165.64.22]:60480 helo=mail.gmx.net) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1P1IrP-0003U7-Q6 for emacs-devel@gnu.org; Thu, 30 Sep 2010 09:07:44 -0400 Original-Received: (qmail invoked by alias); 30 Sep 2010 13:07:40 -0000 Original-Received: from p4FC18A28.dip0.t-ipconnect.de (EHLO detlef.gmx.de) [79.193.138.40] by mail.gmx.net (mp054) with SMTP; 30 Sep 2010 15:07:40 +0200 X-Authenticated: #3708877 X-Provags-ID: V01U2FsdGVkX18NNRA0K20N2TZMQrrlJKoVep0CUUIlwv+TvZZQMI tEPTsXqqHWqCby User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:131105 Archived-At: Eli Zaretskii writes: >> From: Stefan Monnier >> Cc: Michael Albinus , emacs-devel@gnu.org >> Date: Sat, 18 Sep 2010 11:00:27 +0200 >> >> > Maybe I'm missing something, but I don't see how this can help. For >> > starters, time.el needs Tramp to check the remote every time, so the >> > cache just gets in the way. >> >> But each use from time.el might end up calling some internal Tramp >> functions several times, so the cache may still speed things up. > > That's true, but my conclusion from this is different: we probably > should have finer granularity of the cache setting. > > I guess some of the internal Tramp functions need not be called any > time soon after the first call, for example those that find out which > method to use to access the remote and which scripts to run on the > remote side. Other internal functions will need to run every time > display-time-file-nonempty-p is called. And there could be those in > between. So perhaps these internal functions should be categorized in > some reasonable manner, and then corresponding values added to the > repertoire of tramp-cache-inhibit-cache's values, so that Lisp > programs could have finer control on what is being cached and when the > cache is refreshed. I did some tests. It is hard to predict, which primitive functions are called where, and in majority thes are file-attributes, file-exists-p, file-readable-p, file-writable-p. Other primitive functions do profit from those cached values, or they aren't called as much that it is worth to spend extra handling for caching. Therefore, I propose the following patch: --8<---------------cut here---------------start------------->8--- *** /home/albinus/src/emacs/lisp/files.el.~101670~ 2010-09-30 15:02:06.590646221 +0200 --- /home/albinus/src/emacs/lisp/files.el 2010-09-30 14:24:08.655019756 +0200 *************** *** 934,939 **** --- 934,968 ---- (funcall handler 'file-remote-p file identification connected) nil))) + (defcustom remote-file-name-inhibit-cache 10 + "Inhibit remote file name cache read access, when `t'. + `nil' means to accept cache entries unconditionally. An integer + prevents using of cache entries if they are older than this + amount of seconds. + + File attributes of remote files are cached for better performance. + If they are changed out of Emacs' control, the cached values + become invalid, and must be invalidated. + + In case a remote file is checked regularly, it might be + reasonable to let-bind this variable to a value less then the + time period between two checks. + + Example: + + \(defun display-time-file-nonempty-p \(file) + \(let \(\(remote-file-name-inhibit-cache \(- display-time-interval 5))) + \(and \(file-exists-p file) + \(< 0 \(nth 7 \(file-attributes \(file-chase-links file)))))))" + :group 'files + :version "24.1" + :type `(choice + (const :tag "Do not inhibit file name cache" nil) + (const :tag "Do not use file name cache" t) + (integer :tag "Do not use file name cache" + :format "Do not use file name cache older then %v seconds" + :value 10))) + (defun file-local-copy (file) "Copy the file FILE into a temporary file on this machine. Returns the name of the local copy, or nil, if FILE is directly --8<---------------cut here---------------end--------------->8--- Tramp would be adapted accordingly, of course. Best regards, Michael.