Hi Ihor,
I tried to run that code but get errors for the elp-instrument-function calls
(both with my config and emacs -Q):
```
Debugger entered--Lisp error: (error "ELP cannot profile the function:
org-cite-basic--g...")
error("ELP cannot profile the function: %s" org-cite-basic--get-entry)
elp-instrument-function(org-cite-basic--get-entry)
(progn (elp-instrument-function #'org-cite-basic--get-entry))
elisp--eval-last-sexp(nil)
eval-last-sexp(nil)
funcall-interactively(eval-last-sexp nil)
command-execute(eval-last-sexp)
```
Best,
Jamie
________________________________
From: Ihor Radchenko <[email protected]>
Sent: Saturday, March 19, 2022 8:28 AM
To: Jamie Matthews <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: [BUG] org-cite: 10 second hang opening a ~4k org file with 10MB
bibtex library [9.5.2 (9.5.2-g91681f @
/home/jdm204/.config/emacs/straight/build/org/)]
Jamie Matthews <[email protected]> writes:
> # Issue
> Starting emacs with emacs -Q, then navigating to a minimal example org file
> with C-x C-f yields a ~10 second hang on an 8-core/16GB RAM machine with
> nothing else running. Also, scrolling commands like C-v are often laggy
> after the initial hang.
>
> The minimal org file begins:
> """
> #+bibliography: ~/cloud/library/lib.bib
>
> [cite:@tillyPrimaryAnaplasticLargeCell1997]
> """
> with another 80 citations afterwards, one-by-line, but nothing else. As
> mentioned in the title, the lib.bib file is ~10MB - if I swap this out for a
> non-existent or tiny bibtex file the problem goes away, and the in-buffer
> citations are rendered in a red face. Clearly from this and the below profile
> the issue is something to do with checking etc the citations for
> fontification purposes.
>
> # profile
>
> ## cpu
> 1,542,542,267 99% - org-cite-basic-activate
> 787,037,416 50% - org-cite-basic--get-entry
> 4,065,194 0% + org-cite-basic--parse-bibliography
> 754,769,872 48% - org-cite-basic--all-keys
Could you try the following:
1. Execute the following code:
(require 'elp)
(elp-restore-all)
(elp-instrument-function #'org-cite-basic--get-entry)
(elp-instrument-function #'org-cite-basic-activate)
(elp-instrument-function #'org-cite-basic--parse-bibliography)
(elp-instrument-function #'org-cite-basic--all-keys)
2. Open your org file where Emacs hangs
3. Run M-x elp-results
4. Report the ELP buffer contents here
Best,
Ihor