From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: footnote fontify causing massive slowdown Date: Sat, 05 Dec 2015 15:55:48 +0000 Message-ID: <87bna43n5n.fsf@gmail.com> References: <87egf1qcgn.fsf@nicolasgoaziou.fr> <87h9jx2eiy.fsf@gmail.com> <87610crjr7.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5FBi-0008Qb-Bo for emacs-orgmode@gnu.org; Sat, 05 Dec 2015 10:55:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a5FBf-0000Hz-4y for emacs-orgmode@gnu.org; Sat, 05 Dec 2015 10:55:54 -0500 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:38682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5FBe-0000Hs-Ur for emacs-orgmode@gnu.org; Sat, 05 Dec 2015 10:55:51 -0500 Received: by wmec201 with SMTP id c201so100745789wme.1 for ; Sat, 05 Dec 2015 07:55:50 -0800 (PST) In-Reply-To: <87610crjr7.fsf@nicolasgoaziou.fr> 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou , Derek Feichtinger Cc: emacs-orgmode@gnu.org Hi Nicolas, 2015ko abenudak 5an, Nicolas Goaziou-ek idatzi zuen: >=20 > Hello, >=20 > Aaron Ecay writes: >=20 >> Indeed. However, this code was needlessly slow because it failed to >> take advantage of short-circuit evaluation. >=20 > According to the profile report, I don't understand the logic of your > patch. >=20 >>>> - org-footnote-in-valid-context-p 4106 44% >>>> + org-inside-LaTeX-fragment-p 2380 25% >>>> + org-in-block-p 1563 16% >>>> + org-in-verbatim-emphasis 159 1% >=20 > ISTM that `org-in-block-p' is marginally slower (15%) than > `org-inside-LaTeX-fragment-p' (9%). I=E2=80=99m not sure where 15 and 9 come from. The way I read the report, org-footnote-in-valid-context-p takes 44% of the cumulative time, which is composed of org-inside-LaTeX-fragment-p (25%) + org-in-block-p (16%) + other stuff (3%). So org-inside-LaTeX-fragment-p accounts for >50% of the time spent in org-footnote-in-valid-context-p. >=20 > Of course, in OP's report, `org-in-block-p' is the test returning early, > so pushing it earlier is faster since you don't call > `org-inside-LaTeX-fragment-p', but this is only a very specific > optimization made at the expense of other cases (and contradicts your > commit message). Am I missing something? ...no, you=E2=80=99re not missing anything. I looked at my patch again, an= d it seems completely dumb. I should not write code before finishing my morning cup of tea. I reverted in a198d81. >=20 > I don't understand either the benefit of adding `not' calls all over the > place. I generally use de Morgan's law the other way and save a few > primcalls. >=20 >> Do [1]-type footnotes present other performance problems today? >=20 > The main problem of plain footnotes isn't really their performance, but > false positives'. Anytime something looks like a footnote in a buffer, > you get a performance hit. This happens much more often with plain > footnotes than with other footnote types. >=20 > Moreover, false positives can introduce not-so-subtle problems during > export (see for example 2c66e40c). >=20 > Note that suggesting to not use them (the default value, actually, per > `org-footnote-auto-label') doesn't help, since false positives are the > problem, not real footnotes. >=20 > Eventually, removing them doesn't remove any feature to Org. Of course, > this is an incompatible change, and some users will need to update > documents using plain footnotes. We can provide a function for that, and > use `org-lint' to check for obsolete footnotes. The benefit is to avoid > a whole class of problems. I see. Eventually it sounds like a good idea, indeed. Maybe we should use something a bit stronger than org-lint to warn of the deprecation. What if opening a document with plain footnotes generated a warning? Thanks, --=20 Aaron Ecay