helpful icon indicating copy to clipboard operation
helpful copied to clipboard

Speed up first load

Open ScottFreeCode opened this issue 5 years ago • 2 comments

The first time I call helpful-(callable|variable) I have to wait a couple seconds, whereas subsequent calls (to look up different symbols) have only half a second delay. Calling (require 'helpful) beforehand does not resolve this. Is it possible to preload something that would make the first helpful command as fast as the rest?

ScottFreeCode avatar Jan 14 '20 05:01 ScottFreeCode

It's possible that helpful--read-symbol is slow on your system as it offers completion for any symbol defined in the current Emacs instance.

Try this:

M-x profiler-start RET cpu RET
M-x helpful-callable # reproduce the slowness
M-x profiler-stop
M-x profiler-report

Does that show what's running slowly? Do you have e.g. an exotic helm setup?

Wilfred avatar Feb 02 '20 22:02 Wilfred

Got Ivy/Counsel rather than Helm; nothing unusual that I'm aware of, my customizations are pretty tame (just using the recommended format customization, activating selectable prompt, using helpful as the describing functions, rebinding a couple keys, and using ivy-rich).

Had to report before stop, but this looks like the culprit:

- helpful-callable                  1384  41%
 - helpful-update                   1384  41%
  - helpful--in-manual-p            1384  41%
   - info-lookup->completions       1384  41%
    - info-lookup-setup-mode        1384  41%
       info-lookup-make-completions 1384  41%

On a subsequent call I've got merely: helpful-callable 137 5%!

Looks like if I want to pay this initial cost early I can call:

(require 'info-look)
(info-lookup-setup-mode 'symbol 'emacs-lisp-mode)

That works for me. It's possible that Info lookup is particularly slow on Termux (it's also the only place I've run into that loading Emacs spits out a bunch of "loading this file, loading that file" for a few seconds). As far as I'm concerned this can be closed, but feel free to leave it open for tracking if you want to dig into the issue deeper (I'd be happy to try any other troubleshooting suggestions if it might be possible to narrow down why info lookup is slow and try a more proper fix).

ScottFreeCode avatar Feb 03 '20 03:02 ScottFreeCode