emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tim Frana <tfr@mailbox.org>
To: tfr@mailbox.org
Cc: emacs-orgmode@gnu.org
Subject: Bug: performance issue in org-font-lock-add-priority-faces related to org-priority-regexp [9.4 (9.4-7-g3eccc5-elpaplus @ /home/standard/.emacs.d/elpa/26.3/develop/org-plus-contrib-20200921/)]
Date: Wed, 7 Oct 2020 23:09:40 +0200	[thread overview]
Message-ID: <d157dad4-7d64-15aa-89cd-1431b3813e08@mailbox.org> (raw)
In-Reply-To: <87bbd664-2da6-0551-25f1-9ff287fed9f2%40mailbox.org>

Apologies, the extreme slowdown for the regex in my setup is mostly 
credited to a very long line in my org file (~100k characters). I 
inserted a snippet from a log file to a quote block, without realizing 
that a large base64 string was hiding at the end of one line.
The old regex could exclude that line early on, because it wasn't a 
header line, so I didn't notice a performance hit back then.

With that line deleted (org file shrinks to ~300KB), I measured 
performance with the new and old regex (new on 1st line vs old on 2nd line):

(elp-instrument-function 'org-font-lock-add-priority-faces)
(elp-reset-all)
;; open org file
(elp-results)


      Function Name                     Call Count  Elapsed Time Average 
Time
new: org-font-lock-add-priority-faces  28          0.0228787000 0.0008170964
old: org-font-lock-add-priority-faces  28          0.0007937999 2.834...e-05

So the new one is still considerably slower, but probably not noticeable 
unless the file is really large and/or it contains long lines.


One last remark, my workaround from the last mail is flawed, e.g. it 
broke priority sorting in my agendas. This one worked better:

(defun adv--org-font-lock-add-priority-faces (wrapped-func &rest args)
   (let ((org-priority-regexp "^\\*+ .*?\\(\\[#\\([A-Z0-9]+\\)\\] ?\\)"))
     (apply wrapped-func args)))
(advice-add 'org-font-lock-add-priority-faces :around 
#'adv--org-font-lock-add-priority-faces)



       reply	other threads:[~2020-10-07 21:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87bbd664-2da6-0551-25f1-9ff287fed9f2%40mailbox.org>
2020-10-07 21:09 ` Tim Frana [this message]
2020-09-24 12:59 Tim Frana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d157dad4-7d64-15aa-89cd-1431b3813e08@mailbox.org \
    --to=tfr@mailbox.org \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: Bug: performance issue in org-font-lock-add-priority-faces related to org-priority-regexp [9.4 (9.4-7-g3eccc5-elpaplus @ /home/standard/.emacs.d/elpa/26.3/develop/org-plus-contrib-20200921/)]' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this 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).