Large slowdown for acronym decorations
With org-ref version 3.0 (according to the version statement in org-ref.el) I experience slowdowns on typing to the point of unusability, when I have more than just a few acronyms in a paragraph. The builtin profiler directly points me to org-ref-acronym-face-fn:
32136 89% - redisplay_internal (C function)
31984 88% - jit-lock-function
31984 88% - jit-lock-fontify-now
31984 88% - jit-lock--run-functions
31984 88% - run-hook-wrapped
31984 88% - #<compiled 0x19b66f4dbbc4777d>
31984 88% - font-lock-fontify-region
31984 88% - font-lock-default-fontify-region
31984 88% - font-lock-fontify-keywords-region
31976 88% - org-activate-links
31908 88% + org-ref-acronym-face-fn
36 0% + org-ref-cite-activate
4 0% org-element-link-parser
4 0% + org-remove-flyspell-overlays-in
I had a brief look into this function and believe the culprit is org-parse-acronym-entry which is repeatedly called in order to determine, whether the acronym is a valid entry, or not. Indeed, statically assigning the org-ref-acronym-face for all acronym links, indifferent whether they are valid or not, resolves this issue for me. For me this workaround is doable.
(cl-dolist (mapping org-ref-acronym-types)
(org-link-set-parameters (cl-first mapping)
:face 'org-ref-acronym-face))
One possible long term solution that I can imagine would probably to cache all acronym entries instead of frequently reparsing the file.
Nevertheless, I'm a huge fan of your work, thanks a lot :)
This is a regression. You are right that the two options are not validating or using a cache. I think I used to do that, but in the rewrite took it out because it was complicated, especially to figure out when to invalidate it. I will probably have a need to fix this in the next month or so, and hopefully that will improve it for you.
@empwilli I think the commits above should go a long way to improving performance here. Let me know how they work for you.