emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: Caching org-publish-find-date [8.2.10 (release_8.2.10 @ /opt/emacs/lisp/org/)]
@ 2017-12-27 16:54 Lorenzo Bolla
  2017-12-27 22:48 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Bolla @ 2017-12-27 16:54 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1780 bytes --]

Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     http://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org-mode mailing list.
------------------------------------------------------------------------

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?

Thanks,
Lorenzo

Emacs  : GNU Emacs 25.1.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.23)
 of 2016-11-01
Package: Org-mode version 8.2.10 (release_8.2.10 @ /opt/emacs/lisp/org/)

[-- Attachment #2: Type: text/html, Size: 2101 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug: Caching org-publish-find-date [8.2.10 (release_8.2.10 @ /opt/emacs/lisp/org/)]
  2017-12-27 16:54 Bug: Caching org-publish-find-date [8.2.10 (release_8.2.10 @ /opt/emacs/lisp/org/)] Lorenzo Bolla
@ 2017-12-27 22:48 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2017-12-27 22:48 UTC (permalink / raw)
  To: Lorenzo Bolla; +Cc: emacs-orgmode

Hello,

Lorenzo Bolla <lbolla@gmail.com> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-27 22:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-27 16:54 Bug: Caching org-publish-find-date [8.2.10 (release_8.2.10 @ /opt/emacs/lisp/org/)] Lorenzo Bolla
2017-12-27 22:48 ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).