From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Porter Subject: Re: How to make agenda generation faster Date: Tue, 09 Oct 2018 01:37:46 -0500 Message-ID: <87o9c34ocl.fsf@alphapapa.net> References: <87h8hy1ho5.fsf@mbork.pl> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9lei-0006He-4k for emacs-orgmode@gnu.org; Tue, 09 Oct 2018 02:38:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g9lee-0007vb-W1 for emacs-orgmode@gnu.org; Tue, 09 Oct 2018 02:38:08 -0400 Received: from [195.159.176.226] (port=44907 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g9lee-0007vE-Od for emacs-orgmode@gnu.org; Tue, 09 Oct 2018 02:38:04 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1g9lcR-0005rK-Sy for emacs-orgmode@gnu.org; Tue, 09 Oct 2018 08:35:47 +0200 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: emacs-orgmode@gnu.org Hi Marcin, My feedback is: there be dragons. ;) The Agenda code is very complicated and hard to follow, and it's hard to optimize something that is hard to understand. In the long run, to get significant speed improvements, I think it may be necessary to reimplement the Agenda. However, due to the nature of it (i.e. regexp searches through buffers to find entries), I don't know how much faster it can be made. I don't mean that I doubt it can be--I mean that, truly, I don't know, because it's hard to understand the flow of the code. I think that it is already fairly well optimized, given its limitations. However, an example of a potential improvement would be to refactor it to work with lexical-binding enabled (which didn't exist when it was first created); I can't say how much of an improvement it would make, but my understanding is that code that runs with lexical-binding enabled is generally faster. But doing that would be a non-trivial project, I think, requiring the fixing of many inevitable regressions in the process. If you haven't seen them already, you may find my org-ql and org-ql-agenda code useful. org-ql-agenda presents an Agenda-like buffer. N.B. It does *not* implement most of the Agenda features, but it does emulate an Org Agenda buffer by setting the appropriate text properties on entries and formatting them in a similar way. It's built on org-ql, which provides per-buffer query caching, which means that generating an org-ql-agenda view for Org buffers that haven't changed since the last view was generated is very fast. It's also written in a more functional way, which I think is easier to follow and modify. Performance of uncached queries/buffers depends on the query--some are relatively fast, while others are slower than the "real" Org Agenda. I think there is significant potential for optimizations, and I'm hoping to implement some in the future. Your feedback would be appreciated! https://github.com/alphapapa/org-ql