Open ashiklom opened 3 years ago
Hey, thanks for sending the profiling data. Yes, the code for finding PDFs is in desperate need to be rewritten. Ideally there would be a plug-in infrastructure that people can use to mix and mash various ways of locating PDFs according to their needs. This would address a whole bunch of issues here. This way, if you're not referencing PDFs in some particular way, you'd just switch off that plugin and things would become faster as a result. Currently, the code tries all methods for locating PDFs no matter what. But some algorithms for locating PDFs could also be made more efficient. I just looked at the code for finding PDFs with the name BibTeX-key.pdf
and see that it's touching the filesystem much more than necessary. The time spent in f-file?
can be cut at least in half. This line is the worst offender I think. So in sum, I think there are better opportunities to shave off some processing time than to introduce new customization variables as a stop-gap solutions. I will try to make some improvements next week (but if you'd like to have a shot at it, you'd be most welcome to submit a PR).
The 576ms for insert-file-contents
is a big chunk but I'm afraid we won't get rid of it. That's just Emacs being slow when reading the bibliography file. (Although it may help to force this buffer to fundamental mode if it's not in that mode yet.)
Other than that I highly recommend switching to Emacs' new native-comp branch. On my system, helm-bibtex is about 3 times faster with native compilation.
For moderately large libraries (mine is ~3 MB) with lots of PDF files, the
bibtex-completion-find-pdf
call tobibtex-completion-prepare-entry
becomes a significant bottleneck (see profile under "Details"). It would be nice to be able to disable it with a variable such asbibtex-completion-do-not-find-pdf
. An easy modification would be to modify these lines:https://github.com/tmalsburg/helm-bibtex/blob/master/bibtex-completion.el#L824-L826
...to something like this:
The default for
bibtex-completion-do-not-find-pdf
would benil
to preserve existing behavior.