From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Bug: Caching org-publish-find-date [8.2.10 (release_8.2.10 @ /opt/emacs/lisp/org/)] Date: Wed, 27 Dec 2017 23:48:57 +0100 Message-ID: <87r2rfyeg6.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUKVS-0000nM-Hl for emacs-orgmode@gnu.org; Wed, 27 Dec 2017 17:49:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eUKVR-0005ol-Jd for emacs-orgmode@gnu.org; Wed, 27 Dec 2017 17:49:02 -0500 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:58613) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eUKVR-0005nW-A0 for emacs-orgmode@gnu.org; Wed, 27 Dec 2017 17:49:01 -0500 In-Reply-To: (Lorenzo Bolla's message of "Wed, 27 Dec 2017 16:54:49 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Lorenzo Bolla Cc: emacs-orgmode@gnu.org Hello, Lorenzo Bolla writes: > When using `org-publish-project` I noticed that generating a sitemap > sorted (anti-)chronologically is very slow. It turns out that the > slowness is due to the sorting of sitemap entries, which calls > `org-publish-find-date` during the comparison. But > `org-publish-find-date` is not cached therefore it is called over and > over for each file during the sorting process. > By contrast, `org-publish-find-title` is cached and sorting > alphabetically is faster. > > To test this assumption, I've modified `ox-publish.el` to cache > `org-publish-find-date`, too, obtaining a substantial speed-up: > > (defun org-publish-find-date (file) > (or > (org-publish-cache-get-file-property file :date nil t) > (let ((date (org-publish-find-date-uncached file))) > (org-publish-cache-set-file-property file :date date) > date))) > > (defun org-publish-find-date-uncached (file) > "Find the date of FILE in project. > This function assumes FILE is either a directory or an Org file. > If FILE is an Org file and provides a DATE keyword use it. In > any other case use the file system's modification time. Return > time in `current-time' format." > ... > > Is there a reason why we should not cache the date of a file, in the > same way as we cache its title? That's post-mature optimization. When only cache results of a function when it is reported as horribly slow. I added a cache for `org-publish-find-date' in master branch. Thank you. Regards, -- Nicolas Goaziou